plc点位初始化,出库增加判断,地图增加字段

main
Comair 9 months ago
parent 9152c51450
commit 5ff9a07bd1
  1. 2
      shkj-common/src/main/java/com/shkj/common/constant/RedisConstant.java
  2. 8
      shkj-wms/src/main/java/com/shkj/wcs/plc/PlcEventTask.java
  3. 3
      shkj-wms/src/main/java/com/shkj/wcs/plc/PlcInit.java
  4. 15
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinOutInPlanServiceImpl.java
  5. 4
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinPlcExceptionServiceImpl.java
  6. 4
      shkj-wms/src/main/java/com/shkj/wms/vo/BaseMoldVo.java
  7. 2
      shkj-wms/src/main/resources/mapper/wms/SysStockDetailMapper.xml

@ -20,6 +20,8 @@ public class RedisConstant {
public static String redisReqWare ="reqWare:"; public static String redisReqWare ="reqWare:";
//请求接料 //请求接料
public static String redisReqMate ="reqMate:"; public static String redisReqMate ="reqMate:";
//出库
public static String redisOutBound ="outBound:";
//任务对应的plc连接Id //任务对应的plc连接Id
public static String redistaskPlc ="taskPlcId:"; public static String redistaskPlc ="taskPlcId:";

@ -79,7 +79,7 @@ public class PlcEventTask {
@Autowired @Autowired
PlcInit plcInit; PlcInit plcInit;
// @Scheduled(fixedDelay = 5000) @Scheduled(fixedDelay = 5000)
public void init() { public void init() {
//查询需要连接的PLC,初始化连接对象 //查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList =(List<WcsPlcConnectVo>) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect); List<WcsPlcConnectVo> plcList =(List<WcsPlcConnectVo>) redisTemplate.opsForValue().get(RedisConstant.redisPlcListConnect);
@ -101,7 +101,7 @@ public class PlcEventTask {
//输送线心跳 //输送线心跳
// @Scheduled(fixedDelay = 4000) @Scheduled(fixedDelay = 4000)
public void writePlcheartbeatDps() { public void writePlcheartbeatDps() {
//根据连接的plcId获取属性 //根据连接的plcId获取属性
PlcOperate plcOperate = plcInit.getPlcOperate_dps(); PlcOperate plcOperate = plcInit.getPlcOperate_dps();
@ -130,7 +130,7 @@ public class PlcEventTask {
} }
//堆垛机心跳 //堆垛机心跳
// @Scheduled(fixedDelay = 4000) @Scheduled(fixedDelay = 4000)
public void writePlcheartbeatStk() { public void writePlcheartbeatStk() {
//根据连接的plcId获取属性 //根据连接的plcId获取属性
PlcOperate plcOperate = plcInit.getPlcOperate_stk(); PlcOperate plcOperate = plcInit.getPlcOperate_stk();
@ -210,7 +210,7 @@ public class PlcEventTask {
String address = property.getAddress(); String address = property.getAddress();
businPlcException = new BusinPlcException(); businPlcException = new BusinPlcException();
if (pointType.equals("99")) { if (pointType.equals("99")) {
log.info("地址:"+address+" 报警内容:"+devpName); //log.info("地址:"+address+" 报警内容:"+devpName);
if (pointMap.containsKey(address) && Boolean.valueOf((pointMap.get(address).toString()))) { if (pointMap.containsKey(address) && Boolean.valueOf((pointMap.get(address).toString()))) {
String message = MessageUtils.message(devpName); String message = MessageUtils.message(devpName);
log.info("报警内容转多语言:"+message); log.info("报警内容转多语言:"+message);

@ -47,6 +47,9 @@ public class PlcInit {
if (plcList.size() == 0) { if (plcList.size() == 0) {
return; return;
} }
//初始化系統时,把plc点位信息写入Redis
redisTemplate.opsForValue().set(RedisConstant.redisPlcListConnect,plcList);
for (WcsPlcConnectVo conn : plcList) { for (WcsPlcConnectVo conn : plcList) {
redisTemplate.opsForValue().set(RedisConstant.redisPlcConnect+conn.getDevCode(),conn); redisTemplate.opsForValue().set(RedisConstant.redisPlcConnect+conn.getDevCode(),conn);
PlcHelper plc = new PlcHelper(conn.getPlcType(), conn.getPlcIp(), conn.getPlcFactory(), conn.getPort()); PlcHelper plc = new PlcHelper(conn.getPlcType(), conn.getPlcIp(), conn.getPlcFactory(), conn.getPort());

@ -621,6 +621,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
//出库成功写入wcs异常点位为0 //出库成功写入wcs异常点位为0
outEliminateAlarms(layer); outEliminateAlarms(layer);
Long containerId = updList.get(0).getContainerId();
redisTemplate.delete(RedisConstant.redisOutBound + containerId);
}catch (Exception e){ }catch (Exception e){
log.info("出库确认异常 手动回滚 {}", bos+e.getMessage()); log.info("出库确认异常 手动回滚 {}", bos+e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@ -711,6 +713,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
throw new RuntimeException("业务处理中,请稍后再试"); throw new RuntimeException("业务处理中,请稍后再试");
} }
try { try {
Long containerId = null;
List<String> moldBarcodeList = bo.getMoldBarcodeList(); List<String> moldBarcodeList = bo.getMoldBarcodeList();
List<BaseMold> baseMoldBarcodeList = baseMoldService.queryByMoldBarcodeList(moldBarcodeList); List<BaseMold> baseMoldBarcodeList = baseMoldService.queryByMoldBarcodeList(moldBarcodeList);
if (CollectionUtils.isEmpty(baseMoldBarcodeList)) { if (CollectionUtils.isEmpty(baseMoldBarcodeList)) {
@ -755,6 +758,14 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
return Result.err().msg(voResult.getMsg()); return Result.err().msg(voResult.getMsg());
} }
SysStockDetailVo data = voResult.getData(); SysStockDetailVo data = voResult.getData();
// 查询redis
containerId = data.getContainerId();
Integer layer = (Integer) redisTemplate.opsForValue().get(RedisConstant.redisOutBound + containerId);
if (layer != null) {
if(!bo.getLayer().equals(layer)){
return Result.err().msg("此托盘已存在"+layer+"层的出库任务!");
}
}
outPlan.setLocationId(data.getLocationId()); outPlan.setLocationId(data.getLocationId());
outPlan.setContainerId(data.getContainerId()); outPlan.setContainerId(data.getContainerId());
outPlan.setContainerCode(data.getContainerCode()); outPlan.setContainerCode(data.getContainerCode());
@ -809,6 +820,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
} }
this.updateBatchById(outPlans); this.updateBatchById(outPlans);
//存入redis
redisTemplate.opsForValue().set(RedisConstant.redisOutBound + containerId,bo.getLayer());
} finally { } finally {
//释放锁 //释放锁
lockTemplate.releaseLock(lockInfo); lockTemplate.releaseLock(lockInfo);
@ -836,6 +849,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
} }
return Result.err().msg(sb.substring(0,sb.length()-1)+"已存在出库计划"); return Result.err().msg(sb.substring(0,sb.length()-1)+"已存在出库计划");
} }
//根据所做的出库模具,查询模具所在的托盘,根据所在的托盘生成不同的单据 //根据所做的出库模具,查询模具所在的托盘,根据所在的托盘生成不同的单据
List<SysStockDetail> sysStockDetails = sysStockDetailService.queryByMoldBarcodeLocationList(moldBarcodeList); List<SysStockDetail> sysStockDetails = sysStockDetailService.queryByMoldBarcodeLocationList(moldBarcodeList);
@ -879,7 +893,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper,
} }
this.saveBatch(outPlans); this.saveBatch(outPlans);
} catch (Exception e){ } catch (Exception e){
log.error("新增出库计划失败:"+e.getMessage()); log.error("新增出库计划失败:"+e.getMessage());
} }

@ -23,6 +23,8 @@ import com.shkj.wms.service.IBusinPlcExceptionService;
import javax.annotation.Resource; import javax.annotation.Resource;
import static com.shkj.common.constant.RedisConstant.redisPlcExecMsg;
/** /**
* PLC异常内容Service业务层处理 * PLC异常内容Service业务层处理
* *
@ -121,7 +123,7 @@ public class BusinPlcExceptionServiceImpl extends ServiceImpl<BusinPlcException
List<SysDictData> sysDictDataList = iSysDictDataService.selectDictDataList(sysDictData); List<SysDictData> sysDictDataList = iSysDictDataService.selectDictDataList(sysDictData);
List<BusinPlcException> allList = new ArrayList<>(); List<BusinPlcException> allList = new ArrayList<>();
for (SysDictData dictData : sysDictDataList) { for (SysDictData dictData : sysDictDataList) {
List<BusinPlcException> businPlcExceptionList = (List<BusinPlcException>)redisTemplate.opsForValue().get(RedisConstant.redisPlcExecMsg + dictData.getDictValue()); List<BusinPlcException> businPlcExceptionList = (List<BusinPlcException>)redisTemplate.opsForValue().get(redisPlcExecMsg + dictData.getDictValue());
if(businPlcExceptionList != null){ if(businPlcExceptionList != null){
for (BusinPlcException businPlcException : businPlcExceptionList) { for (BusinPlcException businPlcException : businPlcExceptionList) {
businPlcException.setExecMsg(MessageUtils.message(businPlcException.getExecMsg())); businPlcException.setExecMsg(MessageUtils.message(businPlcException.getExecMsg()));

@ -38,4 +38,8 @@ public class BaseMoldVo extends BaseMold {
* 托盘编号 * 托盘编号
*/ */
private String containerName; private String containerName;
/**
* 货位编号
*/
private String locationName;
} }

@ -376,7 +376,7 @@
</select> </select>
<select id="getLocationMoldByLocationCode" parameterType="String" resultType="com.shkj.wms.vo.BaseMoldVo"> <select id="getLocationMoldByLocationCode" parameterType="String" resultType="com.shkj.wms.vo.BaseMoldVo">
select mold.*,detail.in_time from sys_stock_detail detail select mold.*,detail.in_time,location.location_name from sys_stock_detail detail
inner join base_mold mold on detail.mold_id=mold.id inner join base_mold mold on detail.mold_id=mold.id
inner join base_location location on detail.location_id=location.id inner join base_location location on detail.location_id=location.id
where location.location_code = #{locationCode} where location.location_code = #{locationCode}

Loading…
Cancel
Save