增加光源配置

merge-requests/5/merge
yiming 4 years ago
parent 3bdf944396
commit cc458312dc

@ -51,13 +51,13 @@ public class StreetController {
@PostMapping("") @PostMapping("")
@ApiOperation(value = "巷道新增") @ApiOperation(value = "巷道新增")
public Result add(@RequestBody Street street){ public Result add(@RequestBody StreetVO street){
return Result.success(streetService.add(street)); return Result.success(streetService.add(street));
} }
@PutMapping("") @PutMapping("")
@ApiOperation(value = "巷道修改") @ApiOperation(value = "巷道修改")
public Result edit(@RequestBody Street street){ public Result edit(@RequestBody StreetVO street){
streetService.edit(street); streetService.edit(street);
return Result.success(); return Result.success();
} }

@ -9,4 +9,8 @@ public class StreetVO extends Street {
private String camera1Name; private String camera1Name;
private String camera2Name; private String camera2Name;
private String lightSourceIp;
private Integer lightSourcePort;
} }

@ -17,7 +17,7 @@ public class PlcCmdInfo {
/** /**
* 1 2 * 1 2
*/ */
private Integer inOut1; private Integer side1;
/** /**
* 1 2 * 1 2
@ -34,12 +34,16 @@ public class PlcCmdInfo {
*/ */
private Integer row1; private Integer row1;
/**
* 1
* 2
*/
private Integer separation1; private Integer separation1;
/** /**
* 1 2 * 1 2
*/ */
private Integer inOut2; private Integer side2;
/** /**
* 1 2 * 1 2
@ -62,13 +66,13 @@ public class PlcCmdInfo {
private String plcId; private String plcId;
public PlcCmdInfo(String plcId, String taskId, Integer inOut1, Integer leftRight1, Integer column1, Integer row1,Integer separation1, Integer inOut2, Integer leftRight2, Integer column2, Integer row2, Integer separation2) { public PlcCmdInfo(String plcId, String taskId, Integer side1, Integer leftRight1, Integer column1, Integer row1, Integer separation1, Integer side2, Integer leftRight2, Integer column2, Integer row2, Integer separation2) {
this.taskId = taskId; this.taskId = taskId;
this.inOut1 = inOut1; this.side1 = side1;
this.leftRight1 = leftRight1; this.leftRight1 = leftRight1;
this.column1 = column1; this.column1 = column1;
this.row1 = row1; this.row1 = row1;
this.inOut2 = inOut2; this.side2 = side2;
this.leftRight2 = leftRight2; this.leftRight2 = leftRight2;
this.column2 = column2; this.column2 = column2;
this.row2 = row2; this.row2 = row2;
@ -87,4 +91,15 @@ public class PlcCmdInfo {
return ""; return "";
} }
} }
//针对单双伸货架 单身的是空,双伸且为外侧为 Out
public String getInOutStr(int times){
if (times <= 2) {
return separation1 == 1 ? "" : "-Out";
} else if(times <= 4) {
return separation2 == 1 ? "" : "-Out";
}else {
return "";
}
}
} }

@ -101,7 +101,7 @@ public class PlcService {
order.setStatus(0); order.setStatus(0);
order.setStartTime(LocalDateTime.now()); order.setStartTime(LocalDateTime.now());
order.setStreetId(street.getId()); order.setStreetId(street.getId());
order.setInOut1(plcCmdInfo.getInOut1()); order.setInOut1(plcCmdInfo.getSide1());
order.setLeftRight1(plcCmdInfo.getLeftRight1()); order.setLeftRight1(plcCmdInfo.getLeftRight1());
order.setColumn1(plcCmdInfo.getColumn1()); order.setColumn1(plcCmdInfo.getColumn1());
order.setRow1(plcCmdInfo.getRow1()); order.setRow1(plcCmdInfo.getRow1());
@ -135,7 +135,7 @@ public class PlcService {
Order update = new Order(); Order update = new Order();
update.setId(order.getId()); update.setId(order.getId());
update.setEndTime(endTime); update.setEndTime(endTime);
update.setInOut2(plcCmdInfo.getInOut2()); update.setInOut2(plcCmdInfo.getSide2());
update.setLeftRight2(plcCmdInfo.getLeftRight2()); update.setLeftRight2(plcCmdInfo.getLeftRight2());
update.setColumn2(plcCmdInfo.getColumn2()); update.setColumn2(plcCmdInfo.getColumn2());
update.setRow2(plcCmdInfo.getRow2()); update.setRow2(plcCmdInfo.getRow2());
@ -442,18 +442,18 @@ public class PlcService {
public void kescTest6(PlcCmdInfo plcCmdInfo,String code,String wmsCode){ public void kescTest6(PlcCmdInfo plcCmdInfo,String code,String wmsCode){
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
// log.info("test startTime",startTime); log.info("test startTime",startTime);
// check(plcCmdInfo,"C2-L",wmsCode); check(plcCmdInfo,"C2-L",wmsCode,"2");
// plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1); plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1);
// check(plcCmdInfo,"C3-L",wmsCode); check(plcCmdInfo,"C3-L",wmsCode,"2");
// plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1); plcCmdInfo.setColumn1(plcCmdInfo.getColumn1());
// check(plcCmdInfo,"C4-L",wmsCode); check(plcCmdInfo,"C4-L",wmsCode,"2");
// plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1); plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1);
// check(plcCmdInfo,"C5",wmsCode); check(plcCmdInfo,"C5",wmsCode,"2");
// plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1); plcCmdInfo.setColumn1(plcCmdInfo.getColumn1()+1);
// check(plcCmdInfo,"E1",wmsCode); check(plcCmdInfo,"E1",wmsCode,"2");
// long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
//log.info("test endTime:{},time:{}millisecond",endTime,(endTime - startTime)); log.info("test endTime:{},time:{}millisecond",endTime,(endTime - startTime));
} }
public void check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){ public void check(PlcCmdInfo plcCmdInfo,String cmdCode,String wmsCode,String wmsTrayCode){

@ -1,15 +1,20 @@
package com.zhehekeji.web.service; package com.zhehekeji.web.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zhehekeji.core.util.Assert; import com.zhehekeji.core.util.Assert;
import com.zhehekeji.web.entity.LightSource;
import com.zhehekeji.web.entity.Street; import com.zhehekeji.web.entity.Street;
import com.zhehekeji.web.mapper.LightSourceMapper;
import com.zhehekeji.web.mapper.StreetMapper; import com.zhehekeji.web.mapper.StreetMapper;
import com.zhehekeji.web.pojo.street.StreetSearch; import com.zhehekeji.web.pojo.street.StreetSearch;
import com.zhehekeji.web.pojo.street.StreetType; import com.zhehekeji.web.pojo.street.StreetType;
import com.zhehekeji.web.pojo.street.StreetVO; import com.zhehekeji.web.pojo.street.StreetVO;
import com.zhehekeji.web.service.robotic.NettyClient; import com.zhehekeji.web.service.robotic.NettyClient;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -31,24 +36,34 @@ public class StreetService {
private StreetMapper streetMapper; private StreetMapper streetMapper;
@Resource @Resource
private NettyClient nettyClient; private NettyClient nettyClient;
@Resource
private LightSourceMapper lightSourceMapper;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Caching( @Caching(
put = { put = {
@CachePut(value = {"street"},key = "#street.id"), @CachePut(value = {"street"},key = "#streetVO.id"),
@CachePut(value = {"streetByPlcId"},key = "#street.plcId"), @CachePut(value = {"streetByPlcId"},key = "#streetVO.plcId"),
}, },
evict = { evict = {
@CacheEvict(value = "getStreetCount") @CacheEvict(value = "getStreetCount")
} }
) )
public Street add(Street street) { public Street add(StreetVO streetVO) {
Street street = new Street();
BeanUtils.copyProperties(streetVO,street);
List<String> shelves = check(street); List<String> shelves = check(street);
street.setCreateTime(LocalDateTime.now()); street.setCreateTime(LocalDateTime.now());
street.setUpdateTime(LocalDateTime.now()); street.setUpdateTime(LocalDateTime.now());
street.setVideoStyleRow(1); street.setVideoStyleRow(1);
street.setVideoStyleColumn(1); if(street.getCamera2Id() != null && street.getCamera2Id() != 0 && street.getCamera1Id() != null && street.getCamera1Id() != 0){
//如果两个球机 就显示2列
street.setVideoStyleColumn(2);
}else {
street.setVideoStyleColumn(1);
}
try { try {
streetMapper.insert(street); streetMapper.insert(street);
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
@ -67,6 +82,11 @@ public class StreetService {
} }
}); });
thread.start(); thread.start();
LightSource lightSource = new LightSource();
lightSource.setStreetId(street.getId());
lightSource.setIp(streetVO.getLightSourceIp());
lightSource.setPort(streetVO.getLightSourcePort());
lightSourceMapper.insert(lightSource);
return street; return street;
} }
@ -127,17 +147,40 @@ public class StreetService {
@Caching( @Caching(
evict = { evict = {
@CacheEvict(value = "street",key="#street.id"), @CacheEvict(value = "street",key="#streetVO.id"),
@CacheEvict(value = "streetByPlcId",key="#street.plcId"), @CacheEvict(value = "streetByPlcId",key="#streetVO.plcId"),
} }
) )
public void edit(Street street) { public void edit(StreetVO streetVO) {
Street street = new Street();
BeanUtils.copyProperties(streetVO,street);
check(street); check(street);
if(street.getCamera2Id() != null && street.getCamera2Id() != 0 && street.getCamera1Id() != null && street.getCamera1Id() != 0){
//如果两个球机 就显示2列
street.setVideoStyleColumn(2);
}else {
street.setVideoStyleColumn(1);
}
try { try {
streetMapper.updateById(street); streetMapper.updateById(street);
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
Assert.isTrue(false, "PLC ID已存在"); Assert.isTrue(false, "PLC ID已存在");
} }
List<LightSource> list = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
if(list.size() == 0){
LightSource lightSource = new LightSource();
lightSource.setPort(streetVO.getLightSourcePort());
lightSource.setIp(streetVO.getLightSourceIp());
lightSource.setStreetId(street.getId());
lightSourceMapper.insert(lightSource);
}else {
LightSource lightSource = new LightSource();
lightSource.setPort(streetVO.getLightSourcePort());
lightSource.setIp(streetVO.getLightSourceIp());
lightSourceMapper.update(lightSource,new UpdateWrapper<LightSource>().eq("street_id",street.getId()));
}
} }
@Cacheable(value = "street",key = "#id") @Cacheable(value = "street",key = "#id")

@ -72,7 +72,7 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
if (Cmd.isBaseAction(code)) { if (Cmd.isBaseAction(code)) {
//执行动作,需要保存执行到第几步了 //执行动作,需要保存执行到第几步了
Integer times = GoodsActionTimes.put(plcCmdInfo.getOrderNum()); Integer times = GoodsActionTimes.put(plcCmdInfo.getOrderNum());
code = code + "-" + plcCmdInfo.getLeftRightStr(times); code = code + "-" + plcCmdInfo.getLeftRightStr(times) + plcCmdInfo.getInOutStr(times);
//执行动作 //执行动作
plcService.action(plcCmdInfo, times, code); plcService.action(plcCmdInfo, times, code);
}else { }else {

@ -3,8 +3,9 @@
<mapper namespace="com.zhehekeji.web.mapper.StreetMapper"> <mapper namespace="com.zhehekeji.web.mapper.StreetMapper">
<select id="list" parameterType="com.zhehekeji.web.pojo.street.StreetSearch" resultType="com.zhehekeji.web.pojo.street.StreetVO"> <select id="list" parameterType="com.zhehekeji.web.pojo.street.StreetSearch" resultType="com.zhehekeji.web.pojo.street.StreetVO">
select t.*,c1.name as camera1Name,c2.name as camera2Name select t.*,c1.name as camera1Name,c2.name as camera2Name,l.ip as lightSourceIp,l.port as lightSourcePort
from street t from street t
left join light_source l on l.street_id = t.id
left join camera c1 on t.camera1_id = c1.id left join camera c1 on t.camera1_id = c1.id
left join camera c2 on t.camera2_id = c2.id left join camera c2 on t.camera2_id = c2.id
order by t.id desc order by t.id desc

Loading…
Cancel
Save