From 7b20aca84226700d86717525e56eea86c60a9e6c Mon Sep 17 00:00:00 2001 From: psh Date: Wed, 17 Apr 2024 16:13:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basedriver/ssx_site/ItemProtocol.java | 25 ++++++ .../ssx_site/SsxSiteDeviceDriver.java | 76 +++++++++++++++++-- .../acs/ext/wms/service/AcsToWmsService.java | 2 +- .../wms/service/impl/AcsToWmsServiceImpl.java | 6 +- .../wms/board/controller/BoardController.java | 22 ++---- .../nl/wms/board/service/BoardService.java | 4 +- .../nl/wms/board/service/dao/dto/CzDto.java | 23 ++++++ .../board/service/dao/mapper/BoardMapper.java | 3 + .../board/service/dao/mapper/BoardMapper.xml | 32 ++++++-- .../board/service/impl/BoardServiceImpl.java | 60 ++++++++++----- .../ext/service/impl/AcsToWmsServiceImpl.java | 23 ++---- 11 files changed, 209 insertions(+), 67 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/dto/CzDto.java diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java index 40ac160..a784c6f 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java @@ -19,6 +19,11 @@ public class ItemProtocol { public static String item_weight = "weight"; public static String item_sub_tray = "sub_tray"; public static String item_mother_tray = "mother_tray"; + public static String item_error_code="error_code"; + public static String item_device_type="device_type"; + public static String item_frame_type="frame_type"; + public static String item_mother_type="mother_type"; + public static String item_sub_type="sub_type"; public static String item_to_command = "to_command"; public static String item_to_target = "to_target"; public static String item_to_task = "to_task"; @@ -60,6 +65,26 @@ public class ItemProtocol { return this.getOpcStringValue(item_mother_tray); } + public Integer getErrorCode() { + return this.getOpcIntegerValue(item_error_code); + } + + public Integer getDeviceType() { + return this.getOpcIntegerValue(item_device_type); + } + + public Integer getFrameType() { + return this.getOpcIntegerValue(item_frame_type); + } + + public Integer getMotherType() { + return this.getOpcIntegerValue(item_mother_type); + } + + public Integer getSubType() { + return this.getOpcIntegerValue(item_sub_type); + } + public int getToCommand() { return this.getOpcIntegerValue(item_to_command); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/SsxSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/SsxSiteDeviceDriver.java index bc34c2a..4f0a74a 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/SsxSiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/SsxSiteDeviceDriver.java @@ -23,10 +23,7 @@ import org.nl.acs.task.service.mapper.TaskMapper; import org.nl.config.SpringContextHolder; import org.openscada.opc.lib.da.Server; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 检测站点驱动 @@ -130,6 +127,17 @@ public class SsxSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devi String devicecode; + int device_type=0; + int last_device_type=0; + int frame_type=0; + int last_frame_type=0; + int mother_type=0; + int last_mother_type=0; + int sub_type=0; + int last_sub_type=0; + int error_code=0; + int last_error_code=0; + @Override public Device getDevice() { return this.device; @@ -149,6 +157,11 @@ public class SsxSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devi weight = this.itemProtocol.getWeight(); mother_tray = this.itemProtocol.getMotherTray(); sub_tray = this.itemProtocol.getSubTray(); + device_type = this.itemProtocol.getDeviceType(); + frame_type = this.itemProtocol.getFrameType(); + mother_type = this.itemProtocol.getMotherType(); + sub_type = this.itemProtocol.getSubType(); + error_code = this.itemProtocol.getErrorCode(); if (mode != last_mode) { this.setRequireSucess(false); if(mode==2){ @@ -159,10 +172,56 @@ public class SsxSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devi if (error != last_error) { } - if (mode != last_mode) { - this.setRequireSucess(false); + + if (move != last_move) { + JSONObject json = new JSONObject(); + json.put("point_qty", move); + acsToWmsService.notify(json); + } + + if (!Objects.equals(mother_tray, last_mother_tray)) { + JSONObject json = new JSONObject(); + json.put("mother_tray", mother_tray); + acsToWmsService.notify(json); + } + + if (!Objects.equals(sub_tray, last_sub_tray)) { + JSONObject json = new JSONObject(); + json.put("sub_tray", sub_tray); + acsToWmsService.notify(json); + } + + if (device_type != last_device_type) { + JSONObject json = new JSONObject(); + json.put("device_type", device_type); + acsToWmsService.notify(json); } + if (frame_type != last_frame_type) { + JSONObject json = new JSONObject(); + json.put("frame_type", frame_type); + acsToWmsService.notify(json); + } + + if (mother_type != last_mother_type) { + JSONObject json = new JSONObject(); + json.put("sub_type", sub_type); + acsToWmsService.notify(json); + } + + if (sub_type != last_sub_type) { + JSONObject json = new JSONObject(); + json.put("sub_type", sub_type); + acsToWmsService.notify(json); + } + + if (error_code != last_error_code) { + JSONObject json = new JSONObject(); + json.put("error", error_code); + acsToWmsService.notify(json); + } + + } catch (Exception var17) { return; @@ -222,6 +281,11 @@ public class SsxSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devi last_sub_tray = sub_tray; last_mother_tray = mother_tray; last_action = action; + last_device_type=device_type; + last_frame_type=frame_type; + last_mother_type=mother_type; + last_sub_type=sub_type; + last_error_code=error_code; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index e3af8f8..c062641 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -126,7 +126,7 @@ public interface AcsToWmsService { /** * ACS向WMS反馈任务状态 */ - String notify(BaseRequest request); + String notify(JSONObject param); /** * 任务阶段反馈最新点位 diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index e473525..9fb96b2 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -580,12 +580,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } @Override - public String notify(BaseRequest requestParam) { + public String notify(JSONObject param) { try { MDC.put(log_file_type, log_type); String api = addressService.findByCode("notify").getMethods_url(); - log.info("notify-----输入参数{}", JSON.toJSONString(requestParam, SerializerFeature.DisableCircularReferenceDetect)); - String result = LmsUtil.notifyAcs(api, requestParam); + log.info("notify-----输入参数{}", param); + String result = LmsUtil.notifyAcs(api, param); log.info("notify-----输出参数{}", result); return result; } finally { diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/controller/BoardController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/controller/BoardController.java index 9e92775..c2ff751 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/controller/BoardController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/controller/BoardController.java @@ -42,7 +42,7 @@ public class BoardController { @ApiOperation("称重看板") @SaIgnore public ResponseEntity cz(@RequestBody JSONObject param){ - return new ResponseEntity<>(boardService.cz(param), HttpStatus.OK); + return new ResponseEntity<>(boardService.cz(), HttpStatus.OK); } @PostMapping("/rk") @@ -54,21 +54,11 @@ public class BoardController { } - @PostMapping("/sc/pt") - @Log("生产看板普通回温") - @ApiOperation("生产看板普通回温") + @PostMapping("/sc") + @Log("生产看板") + @ApiOperation("生产看板") @SaIgnore - public ResponseEntity pt(){ - return new ResponseEntity<>(boardService.sc("HW"), HttpStatus.OK); + public ResponseEntity sc(){ + return new ResponseEntity<>(boardService.sc(), HttpStatus.OK); } - - - @PostMapping("/sc/ks") - @Log("生产看板快速回温") - @ApiOperation("生产看板快速回温") - @SaIgnore - public ResponseEntity ks(){ - return new ResponseEntity<>(boardService.sc("HWK"), HttpStatus.OK); - } - } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/BoardService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/BoardService.java index 2e3f769..befe07f 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/BoardService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/BoardService.java @@ -9,10 +9,10 @@ import org.nl.wms.pda.service.dao.vo.PdaResponseVo; import java.util.List; public interface BoardService { - PdaResponseVo cz(JSONObject param); + JSONObject cz(); JSONObject rk(); - List sc(String region_code); + JSONObject sc(); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/dto/CzDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/dto/CzDto.java new file mode 100644 index 0000000..e417ff8 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/dto/CzDto.java @@ -0,0 +1,23 @@ +package org.nl.wms.board.service.dao.dto; + +import lombok.Data; + +@Data +public class CzDto { + private String sub_tray; + private String mother_tray; + private String material_code; + private String material_name; + private Integer number; + private Float qty; + private String simtType; + private String locationCode; + private String supplierName; + private String point_qty; + private Integer device_type; + private Integer frame_type; + private Integer mother_type; + private Integer sub_type; + private Integer error; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.java index 12c5010..29c6e9d 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.java @@ -8,6 +8,9 @@ import java.util.List; import java.util.logging.Handler; public interface BoardMapper { + + CzDto cz(String sub_tray); + List sc(String region_code); List kn(); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.xml index 5b354f5..005d846 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/dao/mapper/BoardMapper.xml @@ -60,11 +60,11 @@ + + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/impl/BoardServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/impl/BoardServiceImpl.java index 4914bc7..87112db 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/impl/BoardServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/board/service/impl/BoardServiceImpl.java @@ -1,12 +1,11 @@ package org.nl.wms.board.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; +import org.nl.common.utils.RedisUtils; import org.nl.wms.board.service.BoardService; -import org.nl.wms.board.service.dao.dto.HwDto; -import org.nl.wms.board.service.dao.dto.KcDto; -import org.nl.wms.board.service.dao.dto.ScDto; -import org.nl.wms.board.service.dao.dto.WlDto; +import org.nl.wms.board.service.dao.dto.*; import org.nl.wms.board.service.dao.mapper.BoardMapper; import org.nl.wms.pda.service.dao.vo.PdaResponseVo; import org.springframework.beans.factory.annotation.Autowired; @@ -19,25 +18,50 @@ import java.util.List; public class BoardServiceImpl implements BoardService { @Autowired private BoardMapper boardMapper; - public PdaResponseVo cz(JSONObject param){ - return PdaResponseVo.pdaResultOk("回温状态查询成功"); + @Autowired + private RedisUtils redisUtils; + + public JSONObject cz() { + CzDto czDto = boardMapper.cz(String.valueOf(redisUtils.get("sub_tray"))); + if (czDto == null) { + czDto = new CzDto(); + } + redisUtils.set("mother_tray",0); + redisUtils.set("sub_tray",0); + redisUtils.set("device_type",0); + redisUtils.set("frame_type",0); + redisUtils.set("mother_type",0); + redisUtils.set("sub_type",0); + redisUtils.set("point_qty",0); + + czDto.setMother_tray(String.valueOf(redisUtils.get("mother_tray"))); + czDto.setPoint_qty(String.valueOf(redisUtils.get("point_qty"))); + czDto.setDevice_type((Integer) redisUtils.get("device_type")); + czDto.setFrame_type((Integer) redisUtils.get("frame_type")); + czDto.setMother_type((Integer) redisUtils.get("mother_type")); + czDto.setSub_type((Integer) redisUtils.get("sub_type")); + czDto.setError((Integer) redisUtils.get("error")); + return JSONObject.parseObject(JSON.toJSONString(czDto)); } - public JSONObject rk(){ - KcDto kcDto=boardMapper.kc(); + public JSONObject rk() { + KcDto kcDto = boardMapper.kc(); kcDto.setList(boardMapper.wuliao()); - HwDto hwDto=boardMapper.hw(); - List knList= boardMapper.kn(); - List wrkList=boardMapper.wrk(); - JSONObject jsonObject=new JSONObject(); - jsonObject.put("kc",kcDto); - jsonObject.put("hw",hwDto); - jsonObject.put("kn",knList); - jsonObject.put("wrk",wrkList); + HwDto hwDto = boardMapper.hw(); + List knList = boardMapper.kn(); + List wrkList = boardMapper.wrk(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("kc", kcDto); + jsonObject.put("hw", hwDto); + jsonObject.put("kn", knList); + jsonObject.put("wrk", wrkList); return jsonObject; } - public List sc(String region_code){ - return boardMapper.sc(region_code); + public JSONObject sc() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("pt", boardMapper.sc("HW")); + jsonObject.put("ks", boardMapper.sc("HWK")); + return jsonObject; } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java index ea8ef2a..4b02429 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.RedisUtils; import org.nl.system.service.logicflow.dao.Stage; import org.nl.system.service.notice.ISysNoticeService; import org.nl.system.service.param.ISysParamService; @@ -43,6 +44,7 @@ import javax.annotation.PostConstruct; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -73,6 +75,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { private ISysNoticeService noticeService; @Autowired private PointMapper pointMapper; + @Autowired + private RedisUtils redisUtils; // 初始化反射方法 @PostConstruct @@ -166,22 +170,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { public BaseResponse notify(JSONObject param) { String requestNo = param.getString("requestNo"); log.info("notifyAcs - 请求参数 {}", param); - Integer type=param.getInteger("type"); - String device_code = param.getString("device_code"); - String state = param.getString("state"); - switch(type) { - case 1: - //自动门反馈设备状态,将对应十个固化室工位的状态修改为传入状态 - String ghs_device_code="GHS"+device_code.substring(device_code.length()-2); - pointMapper.updatePointStatus(ghs_device_code,state); - break; - case 2: - //正极板对接位反馈设备有无货 - device_code=device_code.substring(0,device_code.length()-2); - pointMapper.updatePointVehicleQty(device_code,state); - break; - default: - break; + // 遍历所有键 + for(String key:param.keySet()){ + redisUtils.set(key,param.getString(key)); } return BaseResponse.responseOk(requestNo, "反馈成功!"); }