|
|
|
@ -29,6 +29,7 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@ -388,4 +389,60 @@ public class ERPPortServiceImpl implements IERPPortService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时清理ERP已删除的生产计划
|
|
|
|
|
* @param paramDto
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void ERPProdDeleteTask(ERPParamDto paramDto) {
|
|
|
|
|
ProdPlanInfo prodPlanInfo = new ProdPlanInfo();
|
|
|
|
|
HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
paramMap.put("beginBeginTime", "2020-01-01 00:00:00");
|
|
|
|
|
paramMap.put("endBeginTime", paramDto.getPlanEndTime());
|
|
|
|
|
prodPlanInfo.setParams(paramMap);
|
|
|
|
|
prodPlanInfo.setPlanStatus(MesConstants.MES_PLAN_STATUS_WAIT);
|
|
|
|
|
List<ProdPlanInfo> planInfoList = prodPlanInfoService.selectProdPlanInfoList(prodPlanInfo);
|
|
|
|
|
String requestParam = null;
|
|
|
|
|
String result = null;
|
|
|
|
|
ERPParamDto erpParamDto = new ERPParamDto();
|
|
|
|
|
erpParamDto.setAppCode(ERPConstants.planAppCode);
|
|
|
|
|
erpParamDto.setController(ERPConstants.planController);
|
|
|
|
|
erpParamDto.setActionName(ERPConstants.planActionName);
|
|
|
|
|
for (ProdPlanInfo planInfo : planInfoList) {
|
|
|
|
|
if (StringUtils.isEmpty(planInfo.getOrderCode())){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
erpParamDto.setTaskCode(planInfo.getOrderCode());
|
|
|
|
|
try {
|
|
|
|
|
// 创建ObjectMapper实例 对象转JSON字符串
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
|
|
|
|
|
requestParam = objectMapper.writeValueAsString(erpParamDto);
|
|
|
|
|
result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
|
|
|
|
|
// 处理接口返回消息
|
|
|
|
|
ObjectMapper resMapper = new ObjectMapper();
|
|
|
|
|
HashMap<String, Object> map = resMapper.readValue(result, new TypeReference<HashMap<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
HashMap<String, Object> returnData = (HashMap<String, Object>) map.get("ReturnData");
|
|
|
|
|
List<ProdPlanErpInfo> dataList = resMapper.convertValue(returnData.get("data"), new TypeReference<List<ProdPlanErpInfo>>() {
|
|
|
|
|
});
|
|
|
|
|
boolean SuccessFlag = true;
|
|
|
|
|
for (ProdPlanErpInfo prodPlanErpInfo : dataList) {
|
|
|
|
|
if (prodPlanErpInfo.getSeqNo().equals(planInfo.getPlanCode())){
|
|
|
|
|
SuccessFlag = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (SuccessFlag) {ProdPlanInfo insetInfo = new ProdPlanInfo();
|
|
|
|
|
insetInfo.setObjId(planInfo.getObjId());
|
|
|
|
|
insetInfo.setPlanStatus(MesConstants.MES_PLAN_STATUS_DELETE);
|
|
|
|
|
prodPlanInfoService.updateProdPlanInfo(insetInfo);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.warn("定时清理ERP已删除的生产计划异常:" + requestParam + "|" + result + "|" + e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|