| | |
| | | import com.zy.asrs.domain.param.ApplyInDevpDto; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CrnStatusParam; |
| | | import com.zy.asrs.entity.param.PreStoragePallet; |
| | | import com.zy.asrs.entity.param.TaskCreateParam; |
| | | import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.OpenServiceImpl; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Autowired |
| | | private BasCrnErrorService basCrnErrorService; |
| | | |
| | | // WMSå
¥åºåä¸åç çä¿¡æ¯ |
| | | @PostMapping("/preStoragePallet") |
| | | public R preStoragePallet(@RequestHeader String appkey, @RequestBody PreStoragePallet preStoragePallet, HttpServletRequest request) { |
| | | auth(appkey, preStoragePallet, request); |
| | | if(Cools.isEmpty(preStoragePallet.getSite(),preStoragePallet.getLx(),preStoragePallet.getLev())) { |
| | | return R.error("åæ°ä¸å®æ´ï¼è¯·æ£æ¥ï¼" + preStoragePallet); |
| | | } |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(preStoragePallet.getSite()); |
| | | if (staProtocol == null) { |
| | | return R.error("ç«ç¹çº¿ç¨ä¸åå¨ï¼" + preStoragePallet.getSite()); |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | staProtocol.setMp((short) (preStoragePallet.getLev() > 1 ? 1 : 2)); |
| | | staProtocol.setLev(preStoragePallet.getLev()); |
| | | staProtocol.setLx(OpenServiceImpl.getGzlx(preStoragePallet.getLx())); |
| | | |
| | | boolean offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(3, staProtocol)); |
| | | if(!offer) { |
| | | return R.error("æ¨ééå失败"); |
| | | } |
| | | return R.ok("å
¥åºåä¸åç çä¿¡æ¯æå"); |
| | | } |
| | | |
| | | //åå»ºä»»å¡ |
| | | @PostMapping("/taskCreate") |
| | | @Transactional |
| | |
| | | @TableField("type") |
| | | private String type; |
| | | |
| | | // 1ï¼ç çã 2ä¸ç ç |
| | | @TableField("mp") |
| | | private short mp; |
| | | |
| | |
| | | @TableField("lev") |
| | | private short lev; |
| | | |
| | | @TableField("mp_completed_report") |
| | | private Integer mpCompletedReport; |
| | | |
| | | public TaskWrk() { |
| | | } |
| | | |
| | |
| | | @TableField("lev") |
| | | private short lev; |
| | | |
| | | @TableField("mp_completed_report") |
| | | private Integer mpCompletedReport; |
| | | |
| | | public TaskWrkLog() { |
| | | } |
| | | |
New file |
| | |
| | | package com.zy.asrs.entity.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author pang.jiabao |
| | | * @description ç«ç¹ç çä¿¡æ¯ |
| | | * @createDate 2025/10/21 14:29 |
| | | */ |
| | | @Data |
| | | public class PreStoragePallet { |
| | | |
| | | /** |
| | | * ç«ç¹ |
| | | */ |
| | | private int site; |
| | | |
| | | /** |
| | | * å·¥è£
ç±»å WMSä¸å N65/N87/G4X/B10 WCS转æ¢ä¸º4ï¼N74/PPE 转æ¢ä¸º3 |
| | | */ |
| | | private String lx; |
| | | |
| | | /** |
| | | * ç ç屿° |
| | | */ |
| | | private short lev; |
| | | |
| | | } |
| | |
| | | private Integer crn; |
| | | |
| | | /** |
| | | * 1ï¼ç çã 2ä¸ç ç |
| | | * å·¥è£
ç±»å |
| | | */ |
| | | private short mp; |
| | | |
| | | /** |
| | | * ç§ç±»1 æ°¸è¿ä¸å çï¼2å 2å±ï¼3å ä¸å±ï¼4å åå± |
| | | */ |
| | | private short lx; |
| | | private String lx; |
| | | |
| | | /** |
| | | * ç ç屿° |
| | |
| | | storageEscalationParam.setBarcode(BoxNo); |
| | | storageEscalationParam.setMatIdList(staProtocol.getMatIdList()); |
| | | storageEscalationParam.setFullPlt(staProtocol.isFullPlt() ? 1 : 0); |
| | | storageEscalationParam.setMpHigh(staProtocol.getMpHigh()); |
| | | storageEscalationParam.setMpHigh((short) (staProtocol.getSiteId() < 200 ? 1 :staProtocol.isHigh() ? 2 : staProtocol.isLow() ? 1 : 0)); // é«åº¦ï¼ä¾§é¢ç ççé«åº¦ ä½1ï¼é«2 |
| | | log.info("ç»æå
¥åº={}", storageEscalationParam); |
| | | TaskWrk taskWrk = toWmsService.getLocNoFromWms(storageEscalationParam); |
| | | if (taskWrk == null) { |
| | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | /** |
| | | * å·¥è£
ç±»å WMSä¸å N65/N87/G4X/B10 WCS转æ¢ä¸º4ï¼N74/PPE 转æ¢ä¸º3 |
| | | */ |
| | | public static short getGzlx(String lx) { |
| | | if (Cools.isEmpty(lx)) { |
| | | return 0; |
| | | } |
| | | switch (lx) { |
| | | case "N74": |
| | | case "PPE": |
| | | return 3; |
| | | case "N65": |
| | | case "N87": |
| | | case "B10": |
| | | return 4; |
| | | default: |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public HashMap<String, Object> taskCreate(TaskCreateParam param) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | |
| | | taskWrk.setBarcode(param.getBarcode());//æ¡ç |
| | | taskWrk.setCrnNo(locMast.getCrnNo()); |
| | | taskWrk.setType(param.getType()); |
| | | taskWrk.setMp(param.getMp()); |
| | | taskWrk.setLx(param.getLx()); |
| | | taskWrk.setMp((short) (param.getLev() > 1 ? 1 : 2)); |
| | | taskWrk.setLx(getGzlx(param.getLx())); |
| | | taskWrk.setLev(param.getLev()); |
| | | if (param.getIoType() == 1) { |
| | | taskWrk.setWrkSts(1); |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 宿¶å°ä»»å¡(宿ãåæ¶)è½¬ææ¥å¿ |
| | |
| | | @Value("${wms.completeDevpTask}") |
| | | private String completeDevpTask; |
| | | |
| | | @Value("${wms.reportPalletizingCompleted}") |
| | | private String reportPalletizingCompleted; |
| | | |
| | | @Resource |
| | | private TaskWrkMapper taskWrkMapper; |
| | | |
| | |
| | | add(301);add(302);add(303);add(304);add(305);add(306);add(307);add(308); |
| | | }}; |
| | | |
| | | // ä¾§é¢ç ç宿䏿¥wms |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | public synchronized void reportPalletizingCompleted() { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | if (devpThread != null) { |
| | | Map<Integer, StaProtocol> staProtocolMap = devpThread.getStation(); |
| | | int[] siteArray = new int[]{203, 207, 212}; |
| | | for (int site : siteArray) { |
| | | StaProtocol staProtocol = staProtocolMap.get(site); |
| | | if (staProtocol != null) { |
| | | short mpCompletedFlag = staProtocol.getMpCompletedFlag(); |
| | | if (mpCompletedFlag == 1) { |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(staProtocol.getWorkNo())); |
| | | if (taskWrk != null) { |
| | | |
| | | // 请æ±ä½ |
| | | JSONObject request = new JSONObject(); |
| | | request.put("site", site); |
| | | |
| | | String response = ""; |
| | | boolean bool = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(reportPalletizingCompleted) |
| | | .setJson(JSON.toJSONString(request)) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (Integer.parseInt(String.valueOf(jsonObject.get("code"))) == 200) { |
| | | bool = true; |
| | | // æ¨ééå |
| | | boolean offer = MessageQueue.offer(SlaveType.Devp, 4, new Task(1, staProtocol)); |
| | | if (offer) { |
| | | // æ´æ°æ°æ®åº |
| | | taskWrk.setMpCompletedReport(1); |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } else { |
| | | log.error("ä¾§é¢ç ç宿䏿¥wmsæ¨ééå失败ï¼ç«ç¹ï¼{}ï¼ä»»å¡å·ï¼{}", site, staProtocol.getWorkNo()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("ä¾§é¢ç ç宿䏿¥wms失败{},è¿åå¼={}", taskWrk, response); |
| | | } finally { |
| | | apiLogService.save("ä¾§é¢ç ç宿䏿¥wms" |
| | | , wmsUrl + reportPalletizingCompleted |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(request) |
| | | , response |
| | | , bool |
| | | ); |
| | | } |
| | | } else { |
| | | log.error("ä¾§é¢ç ç宿䏿¥wmsæ²¡ææ¾å°è¯¥ä»»å¡ï¼ç«ç¹ï¼{}ï¼ä»»å¡å·ï¼{}", site, staProtocol.getWorkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // WMSåé
å
¥åºåºä½å¼å¸¸ä¸æ¥ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Transactional |
| | |
| | | // æ¡ç ï¼ä¾§é¢åºåºç»è¾é线 |
| | | private String barcode; |
| | | |
| | | // é«åº¦ï¼ä¾§é¢ç ççé«åº¦ |
| | | private short mpHigh; |
| | | |
| | | /** |
| | | * 1ï¼ç çã 2ä¸ç ç |
| | | */ |
| | | private short mp; |
| | | |
| | | /** |
| | | * ç§ç±»1 æ°¸è¿ä¸å çï¼2å 2å±ï¼3å ä¸å±ï¼4å åå± |
| | | * å·¥è£
ç±»å WMSä¸å N65/N87/G4X/B10 WCS转æ¢ä¸º4ï¼N74/PPE 转æ¢ä¸º3 |
| | | */ |
| | | private short lx; |
| | | |
| | |
| | | */ |
| | | private short lev; |
| | | |
| | | /** |
| | | * ç ç宿æ è¯ 0.æªå®æï¼1.宿 |
| | | */ |
| | | private short mpCompletedFlag; |
| | | |
| | | // å¤å½¢æ£æµ ------------------------------------------------------------------------ |
| | | |
| | | // åè¶
é |
| | |
| | | write3((StaProtocol) task.getData()); |
| | | read(); |
| | | break; |
| | | // ä¾§é¢ç ç宿䏿¥wmsæååéç½®plc |
| | | case 4: |
| | | write4((StaProtocol) task.getData()); |
| | | read(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 读侧é¢ç çå®æä¿¡å· |
| | | OperateResultExOne<byte[]> resultMp = siemensS7Net.Read("DB79.362", (short) 4); |
| | | if (resultMp.IsSuccess) { |
| | | StaProtocol staProtocol207 = station.get(207); |
| | | StaProtocol staProtocol212 = station.get(212); |
| | | staProtocol207.setMpCompletedFlag(siemensS7Net.getByteTransform().TransInt16(resultMp.Content, 0)); |
| | | staProtocol212.setMpCompletedFlag(siemensS7Net.getByteTransform().TransInt16(resultMp.Content, 2)); |
| | | } |
| | | |
| | | // è¯»åæ£é¢æ¡ç |
| | |
| | | OperateResult writeResult3 = siemensS7Net.Write(addressPre + lev, staProtocol.getLev()); // ç ç屿° |
| | | if (writeResult1.IsSuccess && writeResult2.IsSuccess && writeResult3.IsSuccess) { |
| | | writeFlag = true; |
| | | log.info("ç çä¿¡æ¯åå
¥è¾é线å½ä»¤åè¿åæåï¼å¹¶ä¸å读æåãè¾é线plcç¼å·={}ï¼{}ï¼åå
¥æ¬¡æ°={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | log.info("ç çä¿¡æ¯åå
¥è¾é线å½ä»¤åè¿åæåã{},{},{},{}ãï¼å¹¶ä¸å读æåï¼åå
¥æ¬¡æ°={}", staProtocol.getSiteId(),staProtocol.getMp(),staProtocol.getLx(),staProtocol.getLev(), writeCount); |
| | | break; |
| | | } else { |
| | | writeCount++; |
| | |
| | | } |
| | | |
| | | //åå½ä»¤å°è¯äº5æ¬¡è¿æ¯å¤±è´¥äº |
| | | if (!writeFlag) { |
| | | //éæ°æ·»å æ°æ®å°ä»»å¡éå |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(3, staProtocol)); |
| | | log.error("ç çä¿¡æ¯åå
¥è¾é线å½ä»¤å°è¯5æ¬¡å¤±è´¥éæ°æ¨ééåãè¾é线plcç¼å·={}ï¼ç«ç¹æ°æ®={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | // if (!writeFlag) { |
| | | // //éæ°æ·»å æ°æ®å°ä»»å¡éå |
| | | // MessageQueue.offer(SlaveType.Devp, 1, new Task(3, staProtocol)); |
| | | // log.error("ç çä¿¡æ¯åå
¥è¾é线å½ä»¤å°è¯5æ¬¡å¤±è´¥éæ°æ¨ééåãè¾é线plcç¼å·={}ï¼ç«ç¹æ°æ®={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | // } |
| | | } |
| | | |
| | | private void write4(StaProtocol staProtocol){ |
| | | |
| | | int offset = 0; |
| | | |
| | | switch (staProtocol.getSiteId()) { |
| | | case 207: offset = 362;break; |
| | | case 212: offset = 364 ;break; |
| | | default: |
| | | log.error("éç½®ç çä¿¡å·ç«ç¹æè¯¯ï¼{}" , staProtocol.getSiteId()); |
| | | return; |
| | | } |
| | | |
| | | String addressPre = "DB79."; |
| | | |
| | | //ä»»å¡ä¸åæ¬¡æ° |
| | | int writeCount = 0; |
| | | while (writeCount < 5) { |
| | | OperateResult writeResult1 = siemensS7Net.Write(addressPre + offset, (short) 0); |
| | | if (writeResult1.IsSuccess) { |
| | | log.info("ä¾§é¢ç ç宿䏿¥wmsæååé置信å·åå
¥è¾é线å½ä»¤åè¿åæåã{}ãï¼å¹¶ä¸å读æåï¼åå
¥æ¬¡æ°={}", staProtocol.getSiteId(), writeCount); |
| | | break; |
| | | } else { |
| | | writeCount++; |
| | | log.error("ä¾§é¢ç ç宿䏿¥wmsæååé置信å·åå
¥è¾é线å½ä»¤å¤±è´¥ãè¾é线plcç¼å·={}ï¼ç«ç¹æ°æ®={},åå
¥æ¬¡æ°={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | executionStatusReport: /executionStatusReport |
| | | # å¤ç½®è¾é线æµå¨å°ä½ä¸æ¥wms |
| | | completeDevpTask: /completeDevpTask |
| | | # ä¾§é¢åºåºç ç宿䏿¥wms |
| | | reportPalletizingCompleted: /taskStateReport |
| | | # æµè¯ç¯å¢ |
| | | # url: http://127.0.0.1:8080/ghlnwms |
| | | # taskStatusFeedbackPath: api/StereoscopicCallBack/TaskExecCallback |
| | |
| | | <result column="mp" property="mp"/> |
| | | <result column="lx" property="lx"/> |
| | | <result column="lev" property="lev"/> |
| | | <result column="mp_completed_report" property="mpCompletedReport"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | <result column="mp" property="mp"/> |
| | | <result column="lx" property="lx"/> |
| | | <result column="lev" property="lev"/> |
| | | |
| | | <result column="mp_completed_report" property="mpCompletedReport"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectByTaskNo" resultMap="BaseResultMap"> |