feat(检验项目同步接口):新增

refs:#43889

(cherry picked from commit 8e2b896603)
This commit is contained in:
liaohechuan 2024-11-13 17:25:11 +08:00 committed by 彭枝刚
parent 248e0acc75
commit aeb215f6d0
9 changed files with 237 additions and 30 deletions

View File

@ -0,0 +1,104 @@
package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 检验项目接口DTO
*
* @author hechuan.liao
* @date 2024-11-13 13:06:57
*/
@Data
public class SapExamineItemDTO {
/**
* 站点
*/
private String site;
/**
* 接口批次ID
*/
private String batchId;
/**
* 检验类型
*/
@SerializedName("INSPEC_TYPE")
@NotBlank(message = "INSPEC_TYPE不能为空!")
private String inspecType;
/**
* 检验项目编号
*/
@SerializedName("QC_ITEM")
@NotBlank(message = "QC_ITEM不能为空!")
private String qcItem;
/**
* 说明
*/
@SerializedName("DESCRIPTION")
private String description;
/**
* 品管方式
*/
@SerializedName("ITEM_TYPE")
@NotBlank(message = "ITEM_TYPE不能为空!")
private String itemType;
/**
* 仪器类型
*/
@SerializedName("EQP_CATEGORY_BO")
private String eqpCategoryBo;
/**
* 检测说明
*/
@SerializedName("QC_DESCRIPTION")
private String qcDescription;
/**
* 计量单位
*/
@SerializedName("UNITS")
private String units;
/**
* 状态
*/
@SerializedName("STATUS")
@NotBlank(message = "STATUS不能为空!")
private String status;
/**
* 规格管控
*/
@SerializedName("CONTROL_MODE")
@NotBlank(message = "CONTROL_MODE不能为空!")
private String controlMode;
/**
* 管制图
*/
@SerializedName("CHART_CONTROL")
private String chartControl;
/**
* 样本数
*/
@SerializedName("SAMPLE_SIZE")
private String sampleSize;
/**
* 不合格代码
*/
@SerializedName("NC_CODE")
private String ncCode;
}

View File

@ -3,7 +3,7 @@ package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
/**
* 工单同步调用接口BOM组件自定义数据DTO
@ -25,13 +25,13 @@ public class SapInShopOrderBomComponentCustomFieldsDTO {
* 预留
*/
@SerializedName("RESERVED")
@NotNull(message = "BOM组件自定义字段RESERVED不能为空")
@NotBlank(message = "BOM组件自定义字段RESERVED不能为空")
private String reserved;
/**
* 预留行号
*/
@SerializedName("RESERVED_SEQ")
@NotNull(message = "BOM组件自定义字段RESERVED_SEQ不能为空")
@NotBlank(message = "BOM组件自定义字段RESERVED_SEQ不能为空")
private String reservedSeq;
/**
* 销售订单

View File

@ -3,7 +3,7 @@ package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
@ -16,13 +16,13 @@ public class SapInShopOrderBomComponentDTO {
* 装配顺序
*/
@SerializedName("SEQUENCE")
@NotNull(message = "BOM组件SEQUENCE不能为空")
@NotBlank(message = "BOM组件SEQUENCE不能为空")
private String sequence;
/**
* 组件物料号
*/
@SerializedName("COMPONENT")
@NotNull(message = "BOM组件COMPONENT不能为空")
@NotBlank(message = "BOM组件COMPONENT不能为空")
private String component;
/**
* 装配数量
@ -33,25 +33,25 @@ public class SapInShopOrderBomComponentDTO {
* 装配工序
*/
@SerializedName("OPERATION")
@NotNull(message = "BOM组件OPERATION不能为空")
@NotBlank(message = "BOM组件OPERATION不能为空")
private String operation;
/**
* 标准数量
*/
@SerializedName("QTY")
@NotNull(message = "BOM组件QTY不能为空")
@NotBlank(message = "BOM组件QTY不能为空")
private String qty;
/**
* 单位数量
*/
@SerializedName("UNIT_QTY")
@NotNull(message = "BOM组件UNIT_QTY不能为空")
@NotBlank(message = "BOM组件UNIT_QTY不能为空")
private String unitQty;
/**
* 组件类型
*/
@SerializedName("BOM_COMPONENT_TYPE")
@NotNull(message = "BOM组件BOM_COMPONENT_TYPE不能为空")
@NotBlank(message = "BOM组件BOM_COMPONENT_TYPE不能为空")
private String bomComponentType;
/**
* BOM组件对应自定义字段

View File

@ -3,7 +3,7 @@ package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
/**
* 工单同步调用接口自定义字段DTO
@ -80,13 +80,13 @@ public class SapInShopOrderCustomFieldsDTO {
* 工单类型
*/
@SerializedName("ORDER_TYPE")
@NotNull(message = "工单自定义字段ORDER_TYPE不能为空")
@NotBlank(message = "工单自定义字段ORDER_TYPE不能为空")
private String orderType;
/**
* 工单类型描述
*/
@SerializedName("ORDER_TYPE_DESC")
@NotNull(message = "工单自定义字段ORDER_TYPE_DESC不能为空")
@NotBlank(message = "工单自定义字段ORDER_TYPE_DESC不能为空")
private String orderTypeDesc;
/**
* 物料
@ -107,13 +107,13 @@ public class SapInShopOrderCustomFieldsDTO {
* 宽幅
*/
@SerializedName("ZCT_KF")
@NotNull(message = "工单自定义字段ZCT_KF不能为空")
@NotBlank(message = "工单自定义字段ZCT_KF不能为空")
private String zctKf;
/**
* 长度
*/
@SerializedName("ZCT_CD")
@NotNull(message = "工单自定义字段ZCT_CD不能为空")
@NotBlank(message = "工单自定义字段ZCT_CD不能为空")
private String zctCd;
/**
* 外部型号

View File

@ -3,7 +3,7 @@ package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
@ -20,7 +20,7 @@ public class SapInShopOrderDTO {
* 工单号
*/
@SerializedName("SHOP_ORDER")
@NotNull(message = "工单SHOP_ORDER不能为空")
@NotBlank(message = "工单SHOP_ORDER不能为空")
private String shopOrder;
/**
* 工单类型
@ -31,13 +31,13 @@ public class SapInShopOrderDTO {
* 物料号
*/
@SerializedName("ITEM")
@NotNull(message = "工单ITEM不能为空")
@NotBlank(message = "工单ITEM不能为空")
private String item;
/**
* 计划工作中心
*/
@SerializedName("WORK_CENTER")
@NotNull(message = "工单WORK_CENTER不能为空")
@NotBlank(message = "工单WORK_CENTER不能为空")
private String workCenter;
/**
* 计划工艺路线
@ -48,31 +48,31 @@ public class SapInShopOrderDTO {
* 计划生产数量
*/
@SerializedName("QTY")
@NotNull(message = "工单QTY不能为空")
@NotBlank(message = "工单QTY不能为空")
private String qty;
/**
* 工单状态
*/
@SerializedName("SHOP_ORDER_STATUS")
@NotNull(message = "工单SHOP_ORDER_STATUS不能为空")
@NotBlank(message = "工单SHOP_ORDER_STATUS不能为空")
private String shopOrderStatus;
/**
* 计划开始时间
*/
@SerializedName("PLANNED_START_TIME")
@NotNull(message = "工单PLANNED_START_TIME不能为空")
@NotBlank(message = "工单PLANNED_START_TIME不能为空")
private String plannedStartTime;
/**
* 计划完成时间
*/
@SerializedName("PLANNED_COMP_TIME")
@NotNull(message = "工单PLANNED_COMP_TIME不能为空")
@NotBlank(message = "工单PLANNED_COMP_TIME不能为空")
private String plannedCompTime;
/**
* 优先级
*/
@SerializedName("PRIORITY")
@NotNull(message = "工单PRIORITY不能为空")
@NotBlank(message = "工单PRIORITY不能为空")
private String priority;
/**
* 工艺路线编号

View File

@ -3,7 +3,7 @@ package com.foreverwin.iep.integration.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
/**
* 工单同步调用接口工艺路线DTO
@ -15,30 +15,30 @@ public class SapInShopOrderRouterDTO {
* 工序顺序
*/
@SerializedName("SEQUENCE")
@NotNull(message = "工艺路线SEQUENCE不能为空")
@NotBlank(message = "工艺路线SEQUENCE不能为空")
private String sequence;
/**
* 工序
*/
@SerializedName("OPERATION")
@NotNull(message = "工艺路线OPERATION不能为空")
@NotBlank(message = "工艺路线OPERATION不能为空")
private String operation;
/**
* 工序描述
*/
@SerializedName("DESCRIPTION")
@NotNull(message = "工艺路线DESCRIPTION不能为空")
@NotBlank(message = "工艺路线DESCRIPTION不能为空")
private String description;
/**
* 是否报工工序
*/
@SerializedName("ERP_OPERATION")
@NotNull(message = "工艺路线ERP_OPERATION不能为空")
@NotBlank(message = "工艺路线ERP_OPERATION不能为空")
private String erpOperation;
/**
* ERP工作中心
*/
@SerializedName("ERP_WORK_CENTER")
@NotNull(message = "工艺路线ERP_WORK_CENTER不能为空")
@NotBlank(message = "工艺路线ERP_WORK_CENTER不能为空")
private String erpWorkCenter;
}

View File

@ -134,6 +134,11 @@
<artifactId>wms-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>qms-api</artifactId>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>

View File

@ -0,0 +1,93 @@
package com.foreverwin.iep.integration.handler.def.sap;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.SapExamineItemDTO;
import com.foreverwin.iep.integration.service.HandlerService;
import com.foreverwin.iep.integration.utils.JS;
import com.foreverwin.iep.qms.entity.ZQmsQcItemItf;
import com.foreverwin.iep.qms.feign.RemoteExamineItemService;
import com.foreverwin.mom.common.core.constant.SecurityConstants;
import com.foreverwin.mom.common.core.util.I18nUtil;
import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Set;
/**
* 校验项目同步接口
*/
@AllArgsConstructor
@Service("SAP_EXAMINE_ITEM")
public class SapExamineItem implements HandlerService {
private final RemoteExamineItemService remoteExamineItemService;
@Override
public InvokeResponse call(InvokeRequest invokeRequest) {
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
// 表映射到实体类
Gson gson = new Gson();
SapExamineItemDTO sapExamineItemDTO = gson.fromJson(jsonObject.get("messageContent").toString(), SapExamineItemDTO.class);
sapExamineItemDTO.setBatchId(invokeRequest.getTransSid());
sapExamineItemDTO.setSite(invokeRequest.getSite());
// 检验项目接口表
ZQmsQcItemItf zQmsQcItemItf = new ZQmsQcItemItf();
// 属性copy
BeanUtils.copyProperties(sapExamineItemDTO, zQmsQcItemItf);
if (StrUtil.isBlank(sapExamineItemDTO.getSampleSize())) {
zQmsQcItemItf.setSampleSize(null);
}
String message = remoteExamineItemService.remoteSaveOrUpdateSapExamineItem(zQmsQcItemItf, SecurityConstants.FROM_IN).getData();
InvokeResponse response = new InvokeResponse(invokeRequest);
LocalDateTime nowLocalDateTime = LocalDateTime.now();
response.setTransTime(nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
if ("S".equals(message)) {
response.setResult("0");
response.setMessageContent(Msg.SUCCESS);
} else {
response.setResult("1");
response.setMessageContent(message);
}
return response;
}
@Override
public String validation(InvokeRequest invokeRequest) {
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
// 表映射到实体类
Gson gson = new Gson();
SapExamineItemDTO sapExamineItemDTO = gson.fromJson(jsonObject.get("messageContent").toString(), SapExamineItemDTO.class);
if (ObjectUtil.isNull(sapExamineItemDTO)) {
return I18nUtil.getI18nText("int.invoke.iMES.in.error1");
}
// 表字段校验
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<SapExamineItemDTO>> violations = validator.validate(sapExamineItemDTO);
StringBuilder msg = new StringBuilder();
for (ConstraintViolation<SapExamineItemDTO> violation : violations) {
// 添加错误信息
msg.append(violation.getMessage());
}
return msg.toString();
}
}

View File

@ -48,6 +48,11 @@
<artifactId>wms-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>qms-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>