diff --git a/int-api/src/main/java/com/foreverwin/iep/integration/dto/OperationOutRequestDTO.java b/int-api/src/main/java/com/foreverwin/iep/integration/dto/OperationOutRequestDTO.java deleted file mode 100644 index 673f0aa..0000000 --- a/int-api/src/main/java/com/foreverwin/iep/integration/dto/OperationOutRequestDTO.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.foreverwin.iep.integration.dto; - -import lombok.Data; - -import java.math.BigDecimal; -import java.util.List; - -/** - * 工序出站接口请求DTO - * - * @author hechuan.liao - * @date 2024-07-31 09:47:44 - */ -@Data -public class OperationOutRequestDTO { - - /** - * 站点 - */ - private String site; - - /** - * 自定义字段名 - */ - private String fieldName; - - /** - * 资源 - */ - private String resrce; - - /** - * 工序 - */ - private String operation; - - /** - * 工序描述 - */ - private String operationDescription; - - /** - * 工单 - */ - private String shopOrder; - - /** - * 工单 - */ - private List shopOrderList; - - /** - * 工单数量 - */ - private BigDecimal qty; - - /** - * 计划物料 - */ - private String item; - - /** - * 计划物料描述 - */ - private String itemDescription; - - /** - * 生产订单剩余数量 - */ - private BigDecimal remainQty; - - /** - * 班制 - */ - private String userWorkShift; - - /** - * 原膜条码 - */ - private String membraneCode; - - /** - * 原膜米数 - */ - private BigDecimal membraneMeter; - - /** - * 原膜剩余米数 - */ - private BigDecimal membraneRemainMeter; - - /** - * 原膜等级 - */ - private String membraneLevel; - - /** - * 原膜宽度 - */ - private String membraneWidth; - - /** - * 原膜类型 - */ - private String membraneType; - - /** - * 扫描条码号 - */ - private String barCode; - - /** - * 条码数 - */ - private int barCodeNum; - - /** - * 膜卷类型 - */ - private String rollType; - - /** - * 作业规则工序列表 - */ - private List operationList; - - /** - * 作业规则自动出站工序列表 - */ - private List autoOperationList; - - /** - * 作业规则自动出站设备 - */ - private String autoResource; - - /** - * 工序出站列表 - */ - private List operationOutListRequestDTOList; - - /** - * 作业规则扣料判断是否附属设备 - */ - private String eqpCombineFeeding; - - /** - * 创建人员(接口用) - */ - private String creator; -} diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/controller/InvokeController.java b/int-core/src/main/java/com/foreverwin/iep/integration/controller/InvokeController.java index 5199d13..86ba80a 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/controller/InvokeController.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/controller/InvokeController.java @@ -2,6 +2,7 @@ package com.foreverwin.iep.integration.controller; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.foreverwin.iep.common.utils.DateUtils; @@ -19,20 +20,15 @@ import com.foreverwin.mom.common.data.tenant.TenantContextHolder; import com.foreverwin.mom.common.log.annotation.SysLog; import com.foreverwin.mom.common.security.annotation.Inner; import com.foreverwin.mom.common.security.util.SecurityUtils; +import io.seata.common.util.CollectionUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.UUID; -import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; - @RestController @RequiredArgsConstructor @Api(value = "invoke", tags = "整合服務接口") @@ -304,4 +300,36 @@ public class InvokeController { return response; } + + /* + SH 呼叫地址 + */ + @PostMapping(value = {"/shInvoke", "/{service}/shInvoke"}) + public JSONObject shInvoke(@PathVariable(value = "service", required = false) String service,@RequestBody JSONObject jsonBody) { + String requestText = jsonBody.toJSONString(); + SecurityUtils.setUserName(Msg.USER); + InvokeRequest request = JSONObject.parseObject(requestText, InvokeRequest.class); + request.setMessageContent(requestText); + request.setSrcRequestBody(requestText); + + InvokeResponse invokeResponse = invoke.execute(service, request); + + JSONObject response = new JSONObject(); + response.put("REQ_ID", invokeResponse.getTransSid()); + response.put("RESULT", invokeResponse.getResult()); + response.put("MESSAGE", invokeResponse.getMessageContent()); + + JSONObject objectResponse = invokeResponse.getObjectResponse(); + if (ObjectUtil.isNotNull(objectResponse)) { + for (String key : objectResponse.keySet()) { + response.put(key, objectResponse.getString(key)); + } + } + + JSONArray arrayResponse = invokeResponse.getArrayResponse(); + if (CollectionUtils.isNotEmpty(arrayResponse)) { + response.put("DETAILS", arrayResponse); + } + return response; + } } diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotOut.java b/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotOut.java index 98bc60a..329a5f4 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotOut.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotOut.java @@ -2,19 +2,28 @@ package com.foreverwin.iep.integration.handler.def.sh; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.foreverwin.iep.integration.constant.Msg; import com.foreverwin.iep.integration.domain.InvokeRequest; import com.foreverwin.iep.integration.domain.InvokeResponse; +import com.foreverwin.iep.integration.dto.OperationOutListRequestDTO; +import com.foreverwin.iep.integration.mapper.IntInDataMapper; import com.foreverwin.iep.integration.service.HandlerService; import com.foreverwin.iep.integration.utils.JS; +import com.foreverwin.iep.wip.dto.OperationOutDTO; +import com.foreverwin.iep.wip.dto.OperationOutListDTO; import com.foreverwin.iep.wip.feign.RemoteWipService; import com.foreverwin.mom.common.core.util.I18nUtil; import lombok.AllArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; /** * 出站接口 @@ -25,15 +34,41 @@ public class LotOut implements HandlerService { private final RemoteWipService remoteWipService; + private final IntInDataMapper intInDataMapper; + @Override public InvokeResponse call(InvokeRequest invokeRequest) { -// String messageContent = invokeRequest.getMessageContent(); -// // 将json对象jsonObject转成EapExtrudeRecordRequest对象 -// NlvStartRequest startRequest = JSONObject.parseObject(messageContent, NlvStartRequest.class); -// remoteWipService.lotStart(startRequest).getData(); + String messageContent = invokeRequest.getMessageContent(); + JSONObject jsonObject = JS.parseObject(messageContent); + OperationOutDTO operationOutDTO = new OperationOutDTO(); + operationOutDTO.setSite(invokeRequest.getSite()); + operationOutDTO.setCreator(invokeRequest.getFromSystem()); + operationOutDTO.setResrce(jsonObject.getString("RESOURCE")); + operationOutDTO.setOperation(jsonObject.getString("OPERATION")); + JSONArray details = jsonObject.getJSONArray("DETAILS"); + List shopOrderList = new ArrayList<>(); + shopOrderList.add(details.getJSONObject(0).getString("SHOP_ORDER")); + operationOutDTO.setShopOrderList(shopOrderList); + List operationOutListDTOList = new ArrayList<>(); + // 获取LOT信息 + OperationOutListRequestDTO operationOutListRequestDTO = intInDataMapper.readLotInfo(invokeRequest.getSite(), details.getJSONObject(0).getString("LOT_NO")); + if (operationOutListRequestDTO != null) { + // 属性copy + OperationOutListDTO operationOutListDTO = new OperationOutListDTO(); + BeanUtils.copyProperties(operationOutListRequestDTO, operationOutListDTO); + if (StrUtil.isNotBlank(details.getJSONObject(0).getString("SUB_QTY"))) { + operationOutListDTO.setOutWeight(new BigDecimal(details.getJSONObject(0).getString("SUB_QTY"))); + } + if (StrUtil.isNotBlank(details.getJSONObject(0).getString("METER_COUNT"))) { + operationOutListDTO.setOutMeter(new BigDecimal(details.getJSONObject(0).getString("METER_COUNT"))); + } + operationOutListDTOList.add(operationOutListDTO); + } + operationOutDTO.setOperationOutListDTOList(operationOutListDTOList); + remoteWipService.operationOut(operationOutDTO).getData(); InvokeResponse response = new InvokeResponse(invokeRequest); response.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - response.setResult("S"); + response.setResult(Msg.S); response.setMessageContent(Msg.SUCCESS); return response; } @@ -46,10 +81,21 @@ public class LotOut implements HandlerService { return I18nUtil.getI18nText("int.invoke.iMES.in.error1"); } // 校验 - StringBuilder msg = new StringBuilder(); - if (StrUtil.isBlank(jsonObject.getString("SITE"))) { - msg.append("SITE不能为空!"); + JSONArray details = jsonObject.getJSONArray("DETAILS"); + if(details == null || details.size() == 0) { + return "DETAILS不能为空"; } - return msg.toString(); + jsonObject.put("SITE", invokeRequest.getSite()); + if (StrUtil.isBlank(jsonObject.getString("SITE"))) { + return "SITE不能为空"; + } + if(StrUtil.isBlank(jsonObject.getString("OPERATION"))) { + return "OPERATION不能为空"; + } + if(StrUtil.isBlank(jsonObject.getString("RESOURCE"))) { + return "RESOURCE不能为空"; + } + invokeRequest.setKeyValue(details.getJSONObject(0).getString("LOT_NO")); + return null; } } diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotStart.java b/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotStart.java index 7a6fcdc..6bd297b 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotStart.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/handler/def/sh/LotStart.java @@ -7,10 +7,14 @@ import com.alibaba.fastjson.JSONObject; import com.foreverwin.iep.integration.constant.Msg; import com.foreverwin.iep.integration.domain.InvokeRequest; import com.foreverwin.iep.integration.domain.InvokeResponse; +import com.foreverwin.iep.integration.dto.OperationOutListRequestDTO; +import com.foreverwin.iep.integration.mapper.IntInDataMapper; import com.foreverwin.iep.integration.service.HandlerService; import com.foreverwin.iep.integration.utils.JS; import com.foreverwin.iep.wip.domain.NlvStartRequest; import com.foreverwin.iep.wip.domain.NlvStartResponse; +import com.foreverwin.iep.wip.domain.StartResponse; +import com.foreverwin.iep.wip.entity.LotState; import com.foreverwin.iep.wip.feign.RemoteWipService; import com.foreverwin.mom.common.core.util.I18nUtil; import io.seata.common.util.CollectionUtils; @@ -19,6 +23,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.List; /** * 进站接口 @@ -29,6 +34,8 @@ public class LotStart implements HandlerService { private final RemoteWipService remoteWipService; + private final IntInDataMapper intInDataMapper; + @Override public InvokeResponse call(InvokeRequest invokeRequest) { String messageContent = invokeRequest.getMessageContent(); @@ -37,11 +44,30 @@ public class LotStart implements HandlerService { NlvStartResponse nlvStartResponse = remoteWipService.lotStart(startRequest).getData(); InvokeResponse response = new InvokeResponse(invokeRequest); response.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - response.setResult("S"); + response.setResult(Msg.S); response.setMessageContent(Msg.SUCCESS); - if (CollectionUtils.isNotEmpty(nlvStartResponse.getShopOrderReleaseItemInfoList())) { - + JSONArray arrayResponse = new JSONArray(); + StartResponse startResponse = nlvStartResponse.getStartResponse(); + if (startResponse != null) { + List lotStateList = startResponse.getLotStateList(); + if (CollectionUtils.isNotEmpty(lotStateList)) { + for (LotState lotState : lotStateList) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("LOT_NO", lotState.getLotNo()); + jsonObject.put("SUB_QTY", lotState.getWeightQty()); + jsonObject.put("METER_COUNT", lotState.getQty()); + // 获取条码的工单或物料信息 + OperationOutListRequestDTO operationOutListRequestDTO = intInDataMapper.readLotInfo(invokeRequest.getSite(), lotState.getLotNo()); + if (operationOutListRequestDTO != null) { + jsonObject.put("ITEM_NAME", operationOutListRequestDTO.getItem()); + jsonObject.put("ITEM_DESCRIPTION", operationOutListRequestDTO.getItemDescription()); + jsonObject.put("SHOP_ORDER", operationOutListRequestDTO.getShopOrder()); + } + arrayResponse.add(jsonObject); + } + } } + response.setArrayResponse(arrayResponse); return response; } diff --git a/int-db/src/main/java/com/foreverwin/iep/integration/mapper/IntInDataMapper.java b/int-db/src/main/java/com/foreverwin/iep/integration/mapper/IntInDataMapper.java index f4817fe..29637ec 100644 --- a/int-db/src/main/java/com/foreverwin/iep/integration/mapper/IntInDataMapper.java +++ b/int-db/src/main/java/com/foreverwin/iep/integration/mapper/IntInDataMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.foreverwin.iep.common.base.FrontPage; import com.foreverwin.iep.integration.dto.IntInDataDTO; +import com.foreverwin.iep.integration.dto.OperationOutListRequestDTO; import com.foreverwin.iep.integration.entity.IntInData; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,4 +27,6 @@ public interface IntInDataMapper extends BaseMapper { List distinctFromSystem(@Param("dto") IntInDataDTO dto); List distinctToSystem(@Param("dto") IntInDataDTO dto); + + OperationOutListRequestDTO readLotInfo(@Param("site") String site, @Param("lotNo") String lotNo); } diff --git a/int-db/src/main/resources/integration/mapper/IntInDataMapper.xml b/int-db/src/main/resources/integration/mapper/IntInDataMapper.xml index e85e6f2..f0929e3 100644 --- a/int-db/src/main/resources/integration/mapper/IntInDataMapper.xml +++ b/int-db/src/main/resources/integration/mapper/IntInDataMapper.xml @@ -86,4 +86,74 @@ order by a.TO_SYSTEM + + +