|
|
|
@ -34,19 +34,28 @@ import com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity; |
|
|
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity; |
|
|
|
import com.gaotao.modules.sys.mapper.SysSceneExceptionRuleMapper; |
|
|
|
import com.gaotao.modules.sys.service.SysMsgService; |
|
|
|
import com.gaotao.modules.sys.service.SysSceneDynamicControlModelService; |
|
|
|
import com.gaotao.modules.sys.service.SysUserRoleService; |
|
|
|
import com.gaotao.modules.trans.dao.TransNoControlMapper; |
|
|
|
import com.gaotao.modules.trans.entity.TransNoControl; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.HttpEntity; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@ -72,6 +81,8 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
private static final String TODO_MSG_SOURCE_PREFIX = "过站采集-创建分卷"; |
|
|
|
private static final String FLAG_Y = "Y"; |
|
|
|
private static final String FLAG_N = "N"; |
|
|
|
private static final String TID_SPLIT_CONTROL_NO = "10011"; |
|
|
|
private static final String TID_FINISH_CONTROL_NO = "10012"; |
|
|
|
private static final String TODO_DETAIL_STAGE_TRIGGER = "TRIGGER"; |
|
|
|
private static final String TODO_DETAIL_STAGE_REPORT = "REPORT"; |
|
|
|
|
|
|
|
@ -99,6 +110,19 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
private TransNoControlMapper transNoControlMapper; |
|
|
|
@Autowired |
|
|
|
private SysUserRoleService sysUserRoleService; |
|
|
|
@Autowired |
|
|
|
private SysSceneDynamicControlModelService sysSceneDynamicControlModelService; |
|
|
|
@Autowired |
|
|
|
private RestTemplate restTemplate; |
|
|
|
|
|
|
|
@Value("${mes.logs.base-url:https://www.rfid2print.net/CloudProdLogsD/api/logs}") |
|
|
|
private String mesLogsBaseUrl; |
|
|
|
|
|
|
|
@Value("${mes.logs.username:BOINGTECH}") |
|
|
|
private String mesLogsUsername; |
|
|
|
|
|
|
|
@Value("${mes.logs.password:xT8@mN5#vQwZ$2pL}") |
|
|
|
private String mesLogsPassword; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -3075,6 +3099,8 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
String exceptionFlag = inData.getExceptionFlag(); |
|
|
|
String exceptionReason = inData.getExceptionReason(); |
|
|
|
|
|
|
|
checkTidFinishControl(inData); |
|
|
|
|
|
|
|
//1.调用检查的方法 |
|
|
|
this.checkFinishScheduleWithNoFqc(inData); |
|
|
|
|
|
|
|
@ -4910,6 +4936,7 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
if (pendingLockTodo != null && FLAG_N.equalsIgnoreCase(pendingLockTodo.getAuditFlag())) { |
|
|
|
throw new XJException("当前异常代办尚未审核,创建分卷操作已锁定。"); |
|
|
|
} |
|
|
|
checkTidSplitControl(inData); |
|
|
|
|
|
|
|
//公共参数 |
|
|
|
String site = inData.getSite(); |
|
|
|
@ -4936,7 +4963,8 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
String remark = inData.getRemark(); |
|
|
|
Float defectQty = inData.getDefectQty(); |
|
|
|
String packingList = inData.getPackingList(); |
|
|
|
Map<String, Object> resultMap = this.workBenchCreateSlittingRollAction(site, orderNo, itemNo, seqNo, rollNo, rollQty, rollNums, operatorId, remark, defectQty, packingList); |
|
|
|
String tidRollType = StringUtils.hasText(inData.getTidRollType()) ? inData.getTidRollType().trim() : "正常卷"; |
|
|
|
Map<String, Object> resultMap = this.workBenchCreateSlittingRollAction(site, orderNo, itemNo, seqNo, rollNo, rollQty, rollNums, operatorId, remark, defectQty, packingList, tidRollType); |
|
|
|
//判断结果是否成功 |
|
|
|
String resultCode = String.valueOf(resultMap.get("resultCode")); |
|
|
|
if ("400".equalsIgnoreCase(resultCode)) { |
|
|
|
@ -5009,7 +5037,7 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
* @DateTime 2022/2/17 14:51 |
|
|
|
* @Param [site, orderNo, itemNo, seqNo, rollNo, rollQty, rollNums, operatorId, remark] |
|
|
|
**/ |
|
|
|
public Map<String, Object> workBenchCreateSlittingRollAction(String site, String orderNo, Integer itemNo, String seqNo, String rollNo, Float rollQty, Integer rollNums, String operatorId, String remark, Float defectQty, String packingList) { |
|
|
|
public Map<String, Object> workBenchCreateSlittingRollAction(String site, String orderNo, Integer itemNo, String seqNo, String rollNo, Float rollQty, Integer rollNums, String operatorId, String remark, Float defectQty, String packingList, String tidRollType) { |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(site); |
|
|
|
params.add(orderNo); |
|
|
|
@ -5022,12 +5050,140 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
params.add(remark); |
|
|
|
params.add(defectQty); // 不良数(每卷所有排的不良数之和) |
|
|
|
params.add(packingList); // Packing List(每卷参数) |
|
|
|
params.add(tidRollType); |
|
|
|
//调用存储过程 |
|
|
|
List<Map<String, Object>> resultList = procedureMapper.getProcedureData("workbench_createslittingroll_action", params); |
|
|
|
//处理返回的结果 |
|
|
|
return resultList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
private void checkTidSplitControl(SearchScheduleData inData) { |
|
|
|
String workCenterNo = inData.getWorkCenterNo() == null ? "" : inData.getWorkCenterNo().trim(); |
|
|
|
Map<String, String> context = new HashMap<>(); |
|
|
|
context.put("WORK_CENTER", workCenterNo); |
|
|
|
if (!sysSceneDynamicControlModelService.isControlEnabled(inData.getSite(), TID_SPLIT_CONTROL_NO, context)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> rollNos = scheduleMapper.listTidPendingNormalRolls(inData.getSite(), inData.getSeqNo()); |
|
|
|
if (rollNos == null || rollNos.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String resourceId = inData.getResourceId() == null ? "" : inData.getResourceId().trim(); |
|
|
|
if (!StringUtils.hasText(workCenterNo)) { |
|
|
|
throw new XJException("加工中心不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(resourceId)) { |
|
|
|
throw new XJException("机台不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>(); |
|
|
|
body.put("process", workCenterNo); |
|
|
|
body.put("rollLabels", rollNos); |
|
|
|
body.put("machineNo", resourceId); |
|
|
|
postMesLogs("/checkRolls", body, "TID分卷校验"); |
|
|
|
scheduleMapper.updateTidPassFlag(inData.getSite(), inData.getSeqNo(), rollNos); |
|
|
|
} |
|
|
|
|
|
|
|
private void checkTidFinishControl(SearchScheduleData inData) { |
|
|
|
String workCenterNo = inData.getWorkCenterNo() == null ? "" : inData.getWorkCenterNo().trim(); |
|
|
|
Map<String, String> context = new HashMap<>(); |
|
|
|
context.put("WORK_CENTER", workCenterNo); |
|
|
|
if (!sysSceneDynamicControlModelService.isControlEnabled(inData.getSite(), TID_FINISH_CONTROL_NO, context)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String resourceId = inData.getResourceId() == null ? "" : inData.getResourceId().trim(); |
|
|
|
if (!StringUtils.hasText(workCenterNo)) { |
|
|
|
throw new XJException("加工中心不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(resourceId)) { |
|
|
|
throw new XJException("机台不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(inData.getOrderNo())) { |
|
|
|
throw new XJException("订单号不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
SearchScheduleData query = new SearchScheduleData(); |
|
|
|
query.setSite(inData.getSite()); |
|
|
|
query.setOrderNo(inData.getOrderNo()); |
|
|
|
query.setItemNo(inData.getItemNo()); |
|
|
|
query.setSeqNo(inData.getSeqNo()); |
|
|
|
List<SfdcRollData> rolls = scheduleMapper.getSfdcRollByCon(query); |
|
|
|
BigDecimal quantity = BigDecimal.ZERO; |
|
|
|
if (rolls != null) { |
|
|
|
for (SfdcRollData roll : rolls) { |
|
|
|
if (roll == null || "Y".equalsIgnoreCase(roll.getVirtualRollFlag()) || "删除卷".equals(roll.getRollType())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (roll.getRollQty() != null) { |
|
|
|
quantity = quantity.add(BigDecimal.valueOf(roll.getRollQty().doubleValue())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
quantity = quantity.stripTrailingZeros(); |
|
|
|
Object quantityValue = quantity.scale() <= 0 ? quantity.longValue() : quantity; |
|
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>(); |
|
|
|
body.put("orderNo", inData.getOrderNo().trim()); |
|
|
|
body.put("quantity", quantityValue); |
|
|
|
body.put("process", workCenterNo); |
|
|
|
body.put("machineNo", resourceId); |
|
|
|
logger.info("TID结单校验请求: site={}, orderNo={}, seqNo={}, process={}, machineNo={}, quantity={}", |
|
|
|
inData.getSite(), inData.getOrderNo(), inData.getSeqNo(), workCenterNo, resourceId, quantityValue); |
|
|
|
postMesLogs("/checkQuantity", body, "TID结单校验"); |
|
|
|
} |
|
|
|
|
|
|
|
private void postMesLogs(String path, Map<String, Object> body, String failLabel) { |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
headers.setBasicAuth(mesLogsUsername, mesLogsPassword, StandardCharsets.UTF_8); |
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON); |
|
|
|
String requestUrl = buildMesLogsUrl(path); |
|
|
|
ResponseEntity<String> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(requestUrl, HttpMethod.POST, new HttpEntity<>(body, headers), String.class); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("{}调用失败", failLabel, e); |
|
|
|
throw new XJException(failLabel + "失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> mesResult = new HashMap<>(); |
|
|
|
if (StringUtils.hasText(response.getBody())) { |
|
|
|
mesResult = JSON.parseObject(response.getBody(), Map.class); |
|
|
|
} |
|
|
|
Integer mesCode = null; |
|
|
|
Object codeObj = mesResult.get("code"); |
|
|
|
if (codeObj instanceof Number) { |
|
|
|
mesCode = ((Number) codeObj).intValue(); |
|
|
|
} else if (codeObj != null) { |
|
|
|
try { |
|
|
|
mesCode = Integer.valueOf(String.valueOf(codeObj)); |
|
|
|
} catch (NumberFormatException ignored) { |
|
|
|
mesCode = null; |
|
|
|
} |
|
|
|
} |
|
|
|
boolean uploadAll = false; |
|
|
|
Object data = mesResult.get("data"); |
|
|
|
if (data instanceof Map) { |
|
|
|
Object flag = ((Map<?, ?>) data).get("isUploadAll"); |
|
|
|
uploadAll = Boolean.TRUE.equals(flag) || "true".equalsIgnoreCase(String.valueOf(flag)); |
|
|
|
} |
|
|
|
logger.info("{}响应: code={}, isUploadAll={}, msg={}", failLabel, mesCode, uploadAll, mesResult.get("msg")); |
|
|
|
if (mesCode == null || mesCode != 0) { |
|
|
|
String mesMsg = mesResult.get("msg") == null ? "" : String.valueOf(mesResult.get("msg")).trim(); |
|
|
|
throw new XJException(StringUtils.hasText(mesMsg) ? mesMsg : failLabel + "失败"); |
|
|
|
} |
|
|
|
if (!uploadAll) { |
|
|
|
throw new XJException(failLabel + "未通过"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String buildMesLogsUrl(String path) { |
|
|
|
String baseUrl = StringUtils.hasText(mesLogsBaseUrl) ? mesLogsBaseUrl.trim() : "http://logs.bt.in/api/logs"; |
|
|
|
if (baseUrl.endsWith("/")) { |
|
|
|
baseUrl = baseUrl.substring(0, baseUrl.length() - 1); |
|
|
|
} |
|
|
|
return baseUrl + path; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> getMergeRollPageData(SearchScheduleData inData) { |
|
|
|
//公共参数 |
|
|
|
|