feat(工单派工接口):新增
This commit is contained in:
parent
2daeea2a93
commit
0f0956295a
5
pom.xml
5
pom.xml
@ -38,6 +38,11 @@
|
||||
<artifactId>tds-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.foreverwin</groupId>
|
||||
<artifactId>int-api</artifactId>
|
||||
<version>4.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.foreverwin.iep.tds.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TdsDispatchOperationDTO {
|
||||
|
||||
private String stepId;
|
||||
|
||||
private String operation;
|
||||
}
|
||||
@ -130,5 +130,9 @@
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.foreverwin</groupId>
|
||||
<artifactId>int-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@ -1,19 +1,27 @@
|
||||
package com.foreverwin.iep.tds.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.iep.common.constant.BaseConstants;
|
||||
import com.foreverwin.iep.integration.feign.RemoteInvokeService;
|
||||
import com.foreverwin.iep.prd.entity.CustomFields;
|
||||
import com.foreverwin.iep.prd.entity.Operation;
|
||||
import com.foreverwin.iep.prd.entity.ShopOrder;
|
||||
import com.foreverwin.iep.prd.mapper.CustomFieldsMapper;
|
||||
import com.foreverwin.iep.prd.mapper.OperationMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ShopOrderMapper;
|
||||
import com.foreverwin.iep.smd.entity.Resrce;
|
||||
import com.foreverwin.iep.smd.entity.WorkCenter;
|
||||
import com.foreverwin.iep.smd.mapper.ResrceMapper;
|
||||
import com.foreverwin.iep.tds.common.FrontPage;
|
||||
import com.foreverwin.iep.tds.dto.TdsDispatchOperationDTO;
|
||||
import com.foreverwin.iep.tds.entity.TdsDispatch;
|
||||
import com.foreverwin.iep.tds.entity.TdsDispatchLog;
|
||||
import com.foreverwin.iep.tds.enums.DispatchLogTypeEnum;
|
||||
@ -31,7 +39,11 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@ -43,6 +55,10 @@ public class TdsDispatchEquipmentServiceImpl extends ServiceImpl<TdsDispatchEqui
|
||||
private final TdsDispatchService tdsDispatchService;
|
||||
private final TdsDispatchLogService tdsDispatchLogService;
|
||||
|
||||
private final CustomFieldsMapper customFieldsMapper;
|
||||
|
||||
private final RemoteInvokeService remoteInvokeService;
|
||||
|
||||
@Override
|
||||
public IPage<List<Map>> findResource(FrontPage page, String searchText) {
|
||||
// 获取site
|
||||
@ -274,6 +290,17 @@ public class TdsDispatchEquipmentServiceImpl extends ServiceImpl<TdsDispatchEqui
|
||||
List<TdsDispatch> dispatchList = new ArrayList<>();
|
||||
List<TdsDispatchLog> dispatchLogList = new ArrayList<>();
|
||||
|
||||
// ERP报文开始#
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZPP_MES_ORDER_DISPATCH");
|
||||
JSONObject conTextJsonObject = new JSONObject();
|
||||
conTextJsonObject.put("EXCHANGE_SYSTEM", "MES");
|
||||
conTextJsonObject.put("EXCHANGE_ID", StrUtil.uuid());
|
||||
conTextJsonObject.put("EXCHANGE_DOC", "");
|
||||
jsonObject.put("REQUEST_CONTEXT", conTextJsonObject);
|
||||
JSONObject bodyJsonObject = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
// 点击添加按钮,把 新派工数据插入到派工表和派工日志表中,然后 更新shop_order表中的计划工作中心为当前设备对应工作中心
|
||||
// 组装
|
||||
// 循环遍历
|
||||
@ -365,12 +392,53 @@ public class TdsDispatchEquipmentServiceImpl extends ServiceImpl<TdsDispatchEqui
|
||||
|
||||
dispatchList.add(dispatch);
|
||||
dispatchLogList.add(tdsDispatchLog);
|
||||
|
||||
// 调用派工校验
|
||||
// 校验工作中心类型是否是PRODUCTION_LINE
|
||||
CustomFields customFields = customFieldsMapper.selectOne(Wrappers.<CustomFields>lambdaQuery()
|
||||
.eq(CustomFields::getHandle, WorkCenter.genHandle(site, dispatch.getWorkCenter()))
|
||||
.eq(CustomFields::getSite, site)
|
||||
.eq(CustomFields::getTableName, "WORK_CENTER")
|
||||
.eq(CustomFields::getFieldName, "SAP_WC_TYPE")
|
||||
);
|
||||
if (customFields != null && "PRODUCTION_LINE".equals(customFields.getFieldValue())) {
|
||||
// 获取设备对应设备大类的工序
|
||||
List<String> operationByResrceList = baseMapper.selectOperationListByResrce(site, resrce);
|
||||
if (CollectionUtils.isNotEmpty(operationByResrceList)) {
|
||||
// 获取工单对应工艺路线下的工序
|
||||
List<TdsDispatchOperationDTO> operationByShopOrderList = baseMapper.selectOperationListByShopOrder(site, dispatchNo);
|
||||
if (CollectionUtils.isNotEmpty(operationByShopOrderList)) {
|
||||
// 交集
|
||||
List<TdsDispatchOperationDTO> operationList = operationByShopOrderList.stream()
|
||||
.filter(map -> operationByResrceList.contains(map.getOperation()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(operationList)) {
|
||||
// 封装erp报文REQUEST_BODY
|
||||
for (TdsDispatchOperationDTO tdsDispatchOperationDTO : operationList) {
|
||||
JSONObject inputJsonObject = new JSONObject();
|
||||
inputJsonObject.put("AUFNR", dispatchNo);
|
||||
inputJsonObject.put("VORNR", tdsDispatchOperationDTO.getStepId());
|
||||
inputJsonObject.put("ARBPL", dispatch.getWorkCenter());
|
||||
jsonArray.add(inputJsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 批量保存到派工表
|
||||
tdsDispatchService.saveBatch(dispatchList);
|
||||
// 批量保存到日志表
|
||||
tdsDispatchLogService.saveBatch(dispatchLogList);
|
||||
|
||||
// ERP报文结束#
|
||||
if (jsonArray.size() > 0) {
|
||||
bodyJsonObject.put("IT_INPUT", jsonArray);
|
||||
jsonObject.put("REQUEST_BODY", bodyJsonObject);
|
||||
// 调用ERP派工
|
||||
remoteInvokeService.orderDispatch(jsonObject);
|
||||
}
|
||||
|
||||
/* 11月11日晚7:30和业务确认后,先不写以下逻辑:
|
||||
执行成功后:更新shop_order表中的计划工作中心为当前设备对应工作中心
|
||||
取值逻辑:通过派工的设备取到设备对应的工作中心;
|
||||
|
||||
@ -2,7 +2,7 @@ package com.foreverwin.iep.tds.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.foreverwin.iep.tds.common.FrontPage;
|
||||
import com.foreverwin.iep.tds.domain.Dispatch;
|
||||
import com.foreverwin.iep.tds.dto.TdsDispatchOperationDTO;
|
||||
import com.foreverwin.iep.tds.entity.TdsDispatch;
|
||||
import com.foreverwin.mom.common.data.datascope.MomBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -30,4 +30,8 @@ public interface TdsDispatchEquipmentMapper extends MomBaseMapper<TdsDispatch> {
|
||||
List<String> selectShopOrderOperationList(@Param("site") String site,@Param("shopOrder") String shopOrder);
|
||||
|
||||
TdsDispatch selectWorkCenter(@Param("site") String site, @Param("resrce") String resrce);
|
||||
|
||||
List<String> selectOperationListByResrce(@Param("site") String site, @Param("resrce") String resrce);
|
||||
|
||||
List<TdsDispatchOperationDTO> selectOperationListByShopOrder(@Param("site") String site, @Param("dispatchNo") String dispatchNo);
|
||||
}
|
||||
|
||||
@ -248,5 +248,42 @@
|
||||
and r.RESRCE = #{resrce}
|
||||
</select>
|
||||
|
||||
<!--获取设备对应设备大类的工序-->
|
||||
<select id="selectOperationListByResrce" resultType="java.lang.String">
|
||||
select
|
||||
o.OPERATION
|
||||
from
|
||||
wip.resrce r
|
||||
inner join wip.eqp_type et on
|
||||
et.SITE = r.SITE
|
||||
and et.HANDLE = r.EQP_TYPE_BO
|
||||
inner join wip.eqp_category ec on
|
||||
ec.SITE = et.SITE
|
||||
and ec.HANDLE = et.EQP_CATEGORY_BO
|
||||
inner join wip.op_eqp_category oec on
|
||||
oec.SITE = ec.SITE
|
||||
and oec.EQP_CATEGORY_BO = ec.HANDLE
|
||||
inner join wip.operation o on
|
||||
o.SITE = oec.SITE
|
||||
and o.HANDLE = oec.OPERATION_BO
|
||||
where
|
||||
r.SITE = #{site}
|
||||
and r.RESRCE = #{resrce}
|
||||
</select>
|
||||
|
||||
<!--获取工单对应工艺路线下的工序-->
|
||||
<select id="selectOperationListByShopOrder" resultType="com.foreverwin.iep.tds.dto.TdsDispatchOperationDTO">
|
||||
select
|
||||
rs.STEP_ID,
|
||||
o.OPERATION
|
||||
from
|
||||
wip.shop_order so
|
||||
inner join wip.router_step rs on
|
||||
rs.ROUTER_BO = so.PLANNED_ROUTER_BO
|
||||
inner join wip.operation o on
|
||||
o.HANDLE = rs.OPERATION_BO
|
||||
where
|
||||
so.SITE = #{site}
|
||||
and so.SHOP_ORDER = #{dispatchNo}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user