|
|
|
|
@ -26,6 +26,8 @@ |
|
|
|
|
package org.springblade.scheduling.scheduling.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
@ -34,20 +36,35 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils; |
|
|
|
|
import org.apache.commons.lang3.time.DateUtils; |
|
|
|
|
import org.springblade.common.exception.BusinessException; |
|
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.jackson.JsonUtil; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.desk.basic.feign.IBasicClazzClient; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.BasicClazz; |
|
|
|
|
import org.springblade.desk.dashboard.constant.DsPartConstant; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsPartVersionEntity; |
|
|
|
|
import org.springblade.desk.energy.feign.IHttpRequestClient; |
|
|
|
|
import org.springblade.desk.logistics.pojo.dto.AllocationMessPageDTO; |
|
|
|
|
import org.springblade.desk.logistics.pojo.vo.AllocationMessVO; |
|
|
|
|
import org.springblade.desk.order.pojo.enums.YieldOrderEnum; |
|
|
|
|
import org.springblade.desk.produce.feign.IWorkPlanClient; |
|
|
|
|
import org.springblade.desk.produce.pojo.entity.WorkPlan; |
|
|
|
|
import org.springblade.desk.quality.feign.IPlanTestClient; |
|
|
|
|
import org.springblade.desk.quality.feign.IWorkPlanItemClient; |
|
|
|
|
import org.springblade.desk.quality.pojo.entity.PlanTest; |
|
|
|
|
import org.springblade.desk.quality.pojo.entity.WorkPlanItem; |
|
|
|
|
import org.springblade.erpdata.feign.IErpDataLogisticsClient; |
|
|
|
|
import org.springblade.erpdata.feign.IErpDataProduceClient; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.*; |
|
|
|
|
import org.springblade.scheduling.pojo.enums.WorkOrderEnum; |
|
|
|
|
import org.springblade.scheduling.pojo.vo.WorkOrderVO; |
|
|
|
|
@ -110,7 +127,22 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
private final ICraftAbilityService craftAbilityService; |
|
|
|
|
private final IPartVersionService partVersionService; |
|
|
|
|
private final IPartRelationService partRelationService; |
|
|
|
|
@Resource |
|
|
|
|
private final StGlassCakeOutClient glassCakeOutClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IWorkPlanItemClient workPlanItemClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IBasicClazzClient basicClazzClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IErpDataProduceClient erpDataProduceClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IPlanTestClient planTestClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IWorkPlanClient workPlanClient; |
|
|
|
|
@Resource |
|
|
|
|
private final IHttpRequestClient httpRequestClient; |
|
|
|
|
@Resource |
|
|
|
|
private IErpDataLogisticsClient erpDataLogisticsClient; |
|
|
|
|
|
|
|
|
|
@Value("${business.oldMes.url}") |
|
|
|
|
private String oldMesUrl; |
|
|
|
|
@ -2390,4 +2422,153 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
// 将Map的值转换为List返回
|
|
|
|
|
return new ArrayList<>(mergeMap.values()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean isTransferTest(Long woId) { |
|
|
|
|
List<WorkPlanItem> prWorkPlanItems = workPlanItemClient.listByWoId(woId); |
|
|
|
|
|
|
|
|
|
// 没有试验项目,不能转试
|
|
|
|
|
if (!(prWorkPlanItems != null && !prWorkPlanItems.isEmpty())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean flag = false; |
|
|
|
|
for (WorkPlanItem prWorkPlanItem : prWorkPlanItems) { |
|
|
|
|
// 如果试验项目中包含 承压检测 则代表可以发起转试 24/8/5 牛营杰确认
|
|
|
|
|
if ("承压检测".equals(prWorkPlanItem.getItemName())) { |
|
|
|
|
if (prWorkPlanItem.getCheckResult() == -1) { |
|
|
|
|
flag = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, String>> trialItemList() { |
|
|
|
|
// 构造 SQL 查询语句
|
|
|
|
|
List<BasicClazz> basicClazzList = basicClazzClient.list(new LambdaQueryWrapper<BasicClazz>() |
|
|
|
|
.eq(BasicClazz::getBizType, 11)); |
|
|
|
|
List<String> nameList = basicClazzList.stream().map(BasicClazz::getName).collect(Collectors.toList()); |
|
|
|
|
List<Map<String, String>> mapList = erpDataProduceClient.trialItemList(nameList).getData(); |
|
|
|
|
// 转换查询结果
|
|
|
|
|
List<Map<String, String>> result = new ArrayList<>(); |
|
|
|
|
if (mapList != null && !mapList.isEmpty()) { |
|
|
|
|
for (Map<String,String> map : mapList) { |
|
|
|
|
Map<String, String> item = new HashMap<>(); |
|
|
|
|
item.put("value", map.get("key") != null ? map.get("key") : ""); |
|
|
|
|
item.put("label", map.get("value") != null ? map.get("value") : ""); |
|
|
|
|
result.add(item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String,Object> queryAllocationMess(AllocationMessPageDTO dto) { |
|
|
|
|
List<AllocationMessVO> allocationMessList = erpDataLogisticsClient.queryAllocationMess(dto).getData(); |
|
|
|
|
int totalAllocationMessNum = erpDataLogisticsClient.queryAllocationMessNum(dto).getData(); |
|
|
|
|
Map<String,Object> result = new HashMap<>(3); |
|
|
|
|
result.put("current",dto.getPageNum()); |
|
|
|
|
result.put("record",allocationMessList); |
|
|
|
|
result.put("total",totalAllocationMessNum); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void launchTest(Map<String, Object> data, BladeUser user) throws Exception { |
|
|
|
|
// 提取参数
|
|
|
|
|
String batchNo = (String) data.get("batchNo"); |
|
|
|
|
Integer quantity = Integer.parseInt(data.get("quantity").toString()); |
|
|
|
|
String woCode = (String) data.get("woCode"); |
|
|
|
|
String remark = (String) data.get("remark"); |
|
|
|
|
String partCode = (String) data.get("partCode"); |
|
|
|
|
String productType = (String) data.get("productType"); |
|
|
|
|
String partName = (String) data.get("partName"); |
|
|
|
|
Object testListObj = data.get("testList"); |
|
|
|
|
JSONArray testList = (JSONArray) JSON.toJSON(testListObj); |
|
|
|
|
Long woId = Long.parseLong(data.get("woId").toString()); |
|
|
|
|
|
|
|
|
|
// 生成转试单号
|
|
|
|
|
String pptCode = generatePptCode(); |
|
|
|
|
|
|
|
|
|
// 获取相关工序
|
|
|
|
|
WorkPlan workPlan = findRelevantWorkPlan(woId); |
|
|
|
|
|
|
|
|
|
// 处理每个测试项
|
|
|
|
|
processTestItems(testList, batchNo, quantity, woCode, remark, partCode, partName, productType, pptCode, workPlan, user); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String generatePptCode() { |
|
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
|
Date currentDate = new Date(); |
|
|
|
|
c.setTime(currentDate); |
|
|
|
|
String year = String.valueOf(c.get(Calendar.YEAR)); |
|
|
|
|
int month = c.get(Calendar.MONTH) + 1; |
|
|
|
|
String formattedMonth = month < 10 ? "0" + month : String.valueOf(month); |
|
|
|
|
|
|
|
|
|
PlanTest latestData = planTestClient.getLatestData(currentDate); |
|
|
|
|
StringBuilder pptCode = new StringBuilder("LCR" + year + "-" + formattedMonth); |
|
|
|
|
|
|
|
|
|
if (latestData != null && latestData.getId() != null) { |
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(latestData.getCode())) { |
|
|
|
|
String numStr = String.valueOf(Integer.parseInt(latestData.getCode().substring(10)) + 1); |
|
|
|
|
pptCode.append("0".repeat(Math.max(0, 6 - numStr.length()))); |
|
|
|
|
pptCode.append(numStr); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pptCode.append("000001"); |
|
|
|
|
} |
|
|
|
|
return pptCode.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private WorkPlan findRelevantWorkPlan(Long woId) { |
|
|
|
|
List<WorkPlanItem> prWorkPlanItems = workPlanItemClient.listByWoId(woId); |
|
|
|
|
WorkPlan prWorkPlan = null; |
|
|
|
|
for (WorkPlanItem item : prWorkPlanItems) { |
|
|
|
|
if ("承压检测".equals(item.getItemName()) || "承压测试".equals(item.getItemName()) || "承压测试检测".equals(item.getItemName())) { |
|
|
|
|
if (item.getCheckResult() == -1) { |
|
|
|
|
prWorkPlan = workPlanClient.selectById(item.getWpId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return prWorkPlan; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processTestItems(JSONArray testList, String batchNo, Integer quantity, String woCode, String remark, |
|
|
|
|
String partCode, String partName, String productType, String pptCode, |
|
|
|
|
WorkPlan workPlan, BladeUser user) throws Exception { |
|
|
|
|
for (int i = 0; i < testList.size(); i++) { |
|
|
|
|
JSONObject object = testList.getObject(i, JSONObject.class); |
|
|
|
|
String value = object.getString("value"); |
|
|
|
|
String label = object.getString("label"); |
|
|
|
|
|
|
|
|
|
JSONObject response = httpRequestClient.launchTest( |
|
|
|
|
batchNo, quantity, woCode, remark, value, label, i + 1, user, partCode, partName, productType, pptCode |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (response != null) { |
|
|
|
|
saveTestRecord(workPlan, user, value, label, pptCode, response, i + 1); |
|
|
|
|
} else { |
|
|
|
|
throw new BusinessException("LIMS系统接口调用失败,请联系相关负责人处理。"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void saveTestRecord(WorkPlan workPlan, BladeUser user, String testKey, String testName, |
|
|
|
|
String pptCode, JSONObject response, int sequence) { |
|
|
|
|
PlanTest prPlanTest = new PlanTest(); |
|
|
|
|
prPlanTest.setWpId(workPlan.getId()); |
|
|
|
|
prPlanTest.setTestUserId(user.getUserId()); |
|
|
|
|
prPlanTest.setTestUserName(user.getUserName()); |
|
|
|
|
prPlanTest.setTestTime(LocalDateTime.now()); |
|
|
|
|
prPlanTest.setTestNo((long) sequence); |
|
|
|
|
prPlanTest.setWpCode(testKey); |
|
|
|
|
prPlanTest.setTestName(testName); |
|
|
|
|
prPlanTest.setTestStatus("已送"); |
|
|
|
|
prPlanTest.setCode(pptCode); |
|
|
|
|
prPlanTest.setErpId(response.getString("id")); |
|
|
|
|
prPlanTest.setDataId(response.getString("str1")); |
|
|
|
|
planTestClient.save(prPlanTest); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|