| | |
| | | package com.zy.asrs.task.handler; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.GwmsGenerateInventoryDto; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.mapper.OrderDetlMapper; |
| | | import com.zy.asrs.mapper.OrderMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | @Resource |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Resource |
| | | private OrderMapper orderMapper; |
| | |
| | | locDetl.setBarcode(wrkMast.getBarcode()); |
| | | locDetl.setModiTime(now); |
| | | locDetl.setAppeTime(now); |
| | | locDetl.setBatch(""); |
| | | // locDetl.setBatch(""); |
| | | if (!locDetlService.insert(locDetl)) { |
| | | // exceptionHandle("全板入库 ===>> 添加库存明细失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | |
| | | return FAIL.setMsg("全板入库 ===>> 修改库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]"); |
| | | } |
| | | } |
| | | // 入库完成上报mes |
| | | inBoundCompletePushMes(wrkMast,wrkDetls); |
| | | break; |
| | | // 拣料入库 |
| | | case 53: |
| | |
| | | return SUCCESS; |
| | | } |
| | | |
| | | private void inBoundCompletePushMes(WrkMast wrkMast, List<WrkDetl> wrkDetls) { |
| | | GwmsGenerateInventoryDto gwmsGenerateInventoryDto = new GwmsGenerateInventoryDto(); |
| | | gwmsGenerateInventoryDto.setWarehouseType(4); |
| | | gwmsGenerateInventoryDto.setBarcode(wrkMast.getBarcode()); |
| | | gwmsGenerateInventoryDto.setPalletizingNo(wrkMast.getStaNo()); |
| | | gwmsGenerateInventoryDto.setGroupOrderNumber(wrkMast.getMemo()); |
| | | List<GwmsGenerateInventoryDto.MatList> matLists = new ArrayList<>(); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | boolean flag = true; |
| | | for (GwmsGenerateInventoryDto.MatList matList : matLists) { |
| | | if (matList.getPackageGroupNo().equals(wrkDetl.getBrand())) { |
| | | matList.getRolls().add(new GwmsGenerateInventoryDto.Rolls(wrkDetl.getModel(), |
| | | wrkDetl.getUnit(), wrkDetl.getMaktx(), wrkDetl.getLength(), |
| | | Integer.parseInt(wrkDetl.getSpecs()), wrkDetl.getWeight(), wrkDetl.getVolume(), |
| | | wrkDetl.getManuDate())); |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | if (flag) { |
| | | GwmsGenerateInventoryDto.MatList matList = new GwmsGenerateInventoryDto.MatList(); |
| | | matList.setBoxPos(wrkDetl.getOrigin()); |
| | | matList.setPackageGroupNo(wrkDetl.getBrand()); |
| | | matList.setOutOrIn("in"); |
| | | matList.setStockType(wrkMast.getWhsType() == 1 ? "返修入库" : "成品入库"); |
| | | matList.setBoxType(wrkDetl.getColor()); |
| | | matList.setRollType(wrkDetl.getManu()); |
| | | matList.setWideInWidth(wrkDetl.getSku()); |
| | | matList.setThickness(wrkDetl.getItemNum()); |
| | | List<GwmsGenerateInventoryDto.Rolls> rollsList = new ArrayList<>(); |
| | | GwmsGenerateInventoryDto.Rolls roll = new GwmsGenerateInventoryDto.Rolls(wrkDetl.getModel(), |
| | | wrkDetl.getUnit(), wrkDetl.getMaktx(), wrkDetl.getLength(), |
| | | Integer.parseInt(wrkDetl.getSpecs()), wrkDetl.getWeight(), wrkDetl.getVolume(), |
| | | wrkDetl.getManuDate()); |
| | | rollsList.add(roll); |
| | | matList.setRolls(rollsList); |
| | | matLists.add(matList); |
| | | } |
| | | } |
| | | gwmsGenerateInventoryDto.setMatList(matLists); |
| | | |
| | | |
| | | boolean success = false; |
| | | // 获取请求头 |
| | | Map<String, Object> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json;charset=UTF-8"); |
| | | |
| | | // 构造请求体 |
| | | String body = JSON.toJSONString(gwmsGenerateInventoryDto); |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.MES_CC_IP_PORT) |
| | | .setPath(MesConstant.MES_CC_FXRK_URL) |
| | | .setHeaders(headers) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | JSONObject jsonObject1 = JSONObject.parseObject(response); |
| | | int code = (int) jsonObject1.get("code"); |
| | | boolean state = jsonObject1.getBoolean("state"); |
| | | if (code == 200 && state) { |
| | | success = true; |
| | | } |
| | | } else { |
| | | log.error("入库完成推送mes失败!!!url:{};request:{};response:{}", MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_FXRK_URL, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("入库完成推送mes异常:{}", e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "入库完成推送mes", |
| | | MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_FXRK_URL, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ReturnT<String> doOut(WrkMast wrkMast){ |
| | | Date now = new Date(); |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |