|
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONConfig;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -76,6 +77,8 @@ public class ApsServiceImpl implements ApsService {
|
|
|
private ApsProductionOrderService apsProductionOrderService;
|
|
|
@Autowired
|
|
|
private ApsAnnealingDifferenceService apsAnnealingDifferenceService;
|
|
|
+ @Autowired
|
|
|
+ private ApsNochangeRollerService apsNochangeRollerService;
|
|
|
|
|
|
/**
|
|
|
* Aps排程
|
|
@@ -129,283 +132,8 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
apsBlankOrders.addAll(fbNotLock);
|
|
|
}
|
|
|
+// apsOrderScheduleNew(apsBlankOrders,currentUser);
|
|
|
apsOrderSchedule(apsBlankOrders);
|
|
|
-
|
|
|
-
|
|
|
- // 1卷排程
|
|
|
- /*if(singleApsList != null && singleApsList.size()>0){
|
|
|
- // 模型转换
|
|
|
- ProductionScheduleVo productionScheduleVo = apsProductionScheduleInit(singleApsList);
|
|
|
- // 排程计划设备集合
|
|
|
- List<String> blankids = singleApsList.stream().map(ApsBlankOrderVo::getId).collect(Collectors.toList());
|
|
|
- List<Equipment> equipmentList1 = new ArrayList<>();
|
|
|
- List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
- .in(ApsProcessOperationDo::getBlankid, blankids));
|
|
|
- for (ApsProcessOperationDo operationDo : operationDos1) {
|
|
|
- List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankids,null,productionScheduleVo,apsConfigs.get(0));
|
|
|
- }
|
|
|
- productionScheduleVo.setEquipmentList(equipmentList1);
|
|
|
-
|
|
|
- System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- // APS平台排程接口调用
|
|
|
- ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
|
|
|
- if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
- throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
- }
|
|
|
- // 获取坯料计划
|
|
|
- apsBlankOrderService.apsAfter(productionScheduleRetVo,singleApsList);
|
|
|
- }*/
|
|
|
-
|
|
|
- /*if(productionScheduleVos != null && productionScheduleVos.size()>0){
|
|
|
- // 提前退火排程
|
|
|
- *//*ProductionScheduleVo productionScheduleThVo = new ProductionScheduleVo();
|
|
|
- productionScheduleThVo.setProductionScheduleId("提前退火排程-"+SecurityUtil.getUUID());
|
|
|
- productionScheduleThVo.setApsPlanStartDate(productionScheduleVos.get(0).getApsPlanStartDate());
|
|
|
- productionScheduleThVo.setPlanSeconds(productionScheduleVos.get(0).getPlanSeconds());
|
|
|
- productionScheduleThVo.setRoamTime(productionScheduleVos.get(0).getRoamTime());
|
|
|
- productionScheduleThVo.setEnvironmentMode(productionScheduleVos.get(0).getEnvironmentMode());
|
|
|
- productionScheduleThVo.setWashingtime(productionScheduleVos.get(0).getWashingtime());
|
|
|
- productionScheduleThVo.setStandingtime(productionScheduleVos.get(0).getStandingtime());
|
|
|
- productionScheduleThVo.setLooseness(productionScheduleVos.get(0).getLooseness());
|
|
|
- productionScheduleThVo.setPcspeed(productionScheduleVos.get(0).getPcspeed());
|
|
|
- List<ProductionProcesses> pros = new ArrayList<>();
|
|
|
- List<String> thBlankIds = new ArrayList<>();
|
|
|
- Map<String,List<String>> blankProcessIds = new HashMap<>();
|
|
|
- List<WashingMetal> closealloynames = new ArrayList<>();
|
|
|
- for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
|
|
|
- pros.addAll(productionScheduleVo.getProcesses());
|
|
|
- for (ProductionProcesses pross : productionScheduleVo.getProcesses()) {
|
|
|
- for (ProduceOrder produceOrder : pross.getProduceOrder()) {
|
|
|
- thBlankIds.add(produceOrder.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- blankProcessIds.putAll(productionScheduleVo.getBlankProcessIds());
|
|
|
- closealloynames.addAll(productionScheduleVo.getClosealloynames());
|
|
|
- }
|
|
|
- productionScheduleThVo.setProcesses(pros);
|
|
|
- productionScheduleThVo.setBlankProcessIds(blankProcessIds);
|
|
|
- productionScheduleThVo.setClosealloynames(closealloynames);
|
|
|
- // 退火设备列表
|
|
|
- thBlankIds = thBlankIds.stream().distinct().collect(Collectors.toList());
|
|
|
- // 排程计划设备集合
|
|
|
- List<Equipment> equipmentList = new ArrayList<>();
|
|
|
- List<ApsProcessOperationDo> operationDos = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
- .in(ApsProcessOperationDo::getBlankid, thBlankIds));
|
|
|
- for (ApsProcessOperationDo operationDo : operationDos) {
|
|
|
- List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList,eqMaps,thBlankIds,null,productionScheduleThVo,apsConfigs.get(0));
|
|
|
- }
|
|
|
- productionScheduleThVo.setEquipmentList(equipmentList);
|
|
|
-
|
|
|
- // 退火排程
|
|
|
- System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleThVo, jsonConfig));
|
|
|
- logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleThVo, jsonConfig));
|
|
|
- // APS平台排程接口调用
|
|
|
- ProductionScheduleRetVo productionScheduleRetThVo = rwApsServer.productionThSchedule(productionScheduleThVo);
|
|
|
- if (!"200".equals(productionScheduleRetThVo.getCode())) {
|
|
|
- throw new CustomException(productionScheduleRetThVo.getMsg());
|
|
|
- }*//*
|
|
|
-
|
|
|
- // 全部排程,每4个一组
|
|
|
- Map<String,ProductionProcesses> allProcesses = new HashMap<>();
|
|
|
- List<ProductionProcesses> rootProcesses = new ArrayList<>();
|
|
|
- for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
|
|
|
- for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
|
|
|
- allProcesses.put(process.getId(),process);
|
|
|
- if(process.getPreviousProcessesIds() == null || process.getPreviousProcessesIds().size() == 0){
|
|
|
- rootProcesses.add(process);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
|
|
|
- for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
|
|
|
- allProcesses.put(process.getId(),process);
|
|
|
- if(process.getPreviousProcessesIds() == null || process.getPreviousProcessesIds().size() == 0){
|
|
|
- rootProcesses.add(process);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 坯料计划排序
|
|
|
- Collections.sort(rootProcesses,(v1,v2)->{
|
|
|
- // 合金
|
|
|
- String alloy1 = v1.getVolumeMetal();
|
|
|
- String alloy2 = v2.getVolumeMetal();
|
|
|
- // 合金状态
|
|
|
- String alloystatus1 = v1.getVolumeMetalstate();
|
|
|
- String alloystatus2 = v2.getVolumeMetalstate();
|
|
|
- // 产品类型
|
|
|
- String producttype1 = v1.getProducttype();
|
|
|
- String producttype2 = v2.getProducttype();
|
|
|
- // 宽度
|
|
|
- BigDecimal prowidth1 = v1.getVolumeWidth();
|
|
|
- BigDecimal prowidth2 = v2.getVolumeWidth();
|
|
|
- // 厚度
|
|
|
- BigDecimal thickness1 = v1.getVolumeThickness();
|
|
|
- BigDecimal thickness2 = v2.getVolumeThickness();
|
|
|
- // 重量
|
|
|
- BigDecimal singlerollweight1 = v1.getSinglerollweight();
|
|
|
- BigDecimal singlerollweight2 = v2.getSinglerollweight();
|
|
|
-
|
|
|
- int a = 0;
|
|
|
- // 宽度
|
|
|
- if(prowidth1.compareTo(prowidth2) == 0){
|
|
|
- // 合金
|
|
|
- if(alloy1.compareTo(alloy2) == 0){
|
|
|
- // 产品类型
|
|
|
- if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
|
|
|
- // 厚度
|
|
|
- if(thickness1.compareTo(thickness2) == 0){
|
|
|
- // 合金状态
|
|
|
- if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
|
|
|
- // 重量
|
|
|
- if(singlerollweight1.compareTo(singlerollweight2) == 0){
|
|
|
- a = 0;
|
|
|
- }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
|
|
|
- a = -1;
|
|
|
- }else{
|
|
|
- a = 1;
|
|
|
- }
|
|
|
- }else{
|
|
|
- a = alloystatus1.compareTo(alloystatus2);
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(thickness1.compareTo(thickness2) > 0){
|
|
|
- a = -1;
|
|
|
- }else{
|
|
|
- a = 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- a = producttype1.compareTo(producttype2);
|
|
|
- }
|
|
|
- }else{
|
|
|
- a = alloy1.compareTo(alloy2);
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(prowidth1.compareTo(prowidth2) > 0){
|
|
|
- a = -1;
|
|
|
- }else{
|
|
|
- a = 1;
|
|
|
- }
|
|
|
- }
|
|
|
- return a;
|
|
|
- });
|
|
|
- List<List<ProductionProcesses>> chunks = new ArrayList<>();
|
|
|
- int listSize = rootProcesses.size();
|
|
|
- for (int i = 0; i < listSize; i += 4) {
|
|
|
- chunks.add(rootProcesses.subList(i, Math.min(i + 4, listSize)));
|
|
|
- }
|
|
|
-
|
|
|
- // 全部排程,每4个一组
|
|
|
- for (List<ProductionProcesses> rootpros : chunks) {
|
|
|
- ProductionScheduleVo productionScheduleVo = productionScheduleVoInit();
|
|
|
- // 工序作业ID
|
|
|
- Set<String> opId = new LinkedHashSet<>();
|
|
|
- Set<String> orderIds = new LinkedHashSet<>();
|
|
|
- List<ProductionProcesses> pssall = new ArrayList<>();
|
|
|
- for (ProductionProcesses processes : rootpros) {
|
|
|
- pssall.add(processes);
|
|
|
- for (String s : processes.getBsProcessesId()) {
|
|
|
- opId.add(s);
|
|
|
- }
|
|
|
- for (ProduceOrder produceOrder : processes.getProduceOrder()) {
|
|
|
- orderIds.add(produceOrder.getId());
|
|
|
- }
|
|
|
- getAllNextPross(processes,allProcesses,pssall,opId);
|
|
|
- }
|
|
|
- // 退火工序锁定
|
|
|
- *//*if(productionScheduleRetThVo.getProcesses() != null && productionScheduleRetThVo.getProcesses().size()>0){
|
|
|
- for (ProductionProcesses process : pssall) {
|
|
|
- for (ProductionProcesses productionScheduleRetThVoProcess : productionScheduleRetThVo.getProcesses()) {
|
|
|
- if(productionScheduleRetThVoProcess.getId().equals(process.getId())){
|
|
|
- process.setEquipmentId(productionScheduleRetThVoProcess.getEquipmentId());
|
|
|
- List<String> opeqs = new ArrayList<>();
|
|
|
- opeqs.add(productionScheduleRetThVoProcess.getEquipmentId());
|
|
|
- process.setOptionalEquipments(opeqs);
|
|
|
- process.setDelay(0);
|
|
|
- process.setStartTime(productionScheduleRetThVoProcess.getStartTime());
|
|
|
- process.setEndTime(productionScheduleRetThVoProcess.getEndTime());
|
|
|
- process.setIfLock(true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*//*
|
|
|
- // 排程计划设备集合
|
|
|
- List<Equipment> equipmentList1 = new ArrayList<>();
|
|
|
- List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
- .in(ApsProcessOperationDo::getId, opId));
|
|
|
- for (ApsProcessOperationDo operationDo : operationDos1) {
|
|
|
- List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,null,opId,productionScheduleVo,apsConfigs.get(0));
|
|
|
- }
|
|
|
- productionScheduleVo.setEquipmentList(equipmentList1);
|
|
|
- productionScheduleVo.setProcesses(pssall);
|
|
|
-
|
|
|
- System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- // APS平台排程接口调用
|
|
|
- ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
|
|
|
- if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
- throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
- }
|
|
|
- // 获取坯料计划
|
|
|
- List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
|
|
|
- for (String orderId : orderIds) {
|
|
|
- ApsBlankOrderVo apsBlankOrderVo = dataMapOrder.get(orderId);
|
|
|
- if(apsBlankOrderVo != null){
|
|
|
- apsBlankOrderss.add(apsBlankOrderVo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
|
|
|
- }
|
|
|
-
|
|
|
- *//*for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
|
|
|
- // 退火工序锁定
|
|
|
- if(productionScheduleRetThVo.getProcesses() != null && productionScheduleRetThVo.getProcesses().size()>0){
|
|
|
- for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
|
|
|
- for (ProductionProcesses productionScheduleRetThVoProcess : productionScheduleRetThVo.getProcesses()) {
|
|
|
- if(productionScheduleRetThVoProcess.getId().equals(process.getId())){
|
|
|
- process.setEquipmentId(productionScheduleRetThVoProcess.getEquipmentId());
|
|
|
- List<String> opeqs = new ArrayList<>();
|
|
|
- opeqs.add(productionScheduleRetThVoProcess.getEquipmentId());
|
|
|
- process.setOptionalEquipments(opeqs);
|
|
|
- process.setDelay(0);
|
|
|
- process.setStartTime(productionScheduleRetThVoProcess.getStartTime());
|
|
|
- process.setEndTime(productionScheduleRetThVoProcess.getEndTime());
|
|
|
- process.setIfLock(true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 设备列表赋值
|
|
|
- List<String> blankIds = new ArrayList<>();
|
|
|
- for (ProductionProcesses pross : productionScheduleVo.getProcesses()) {
|
|
|
- for (ProduceOrder produceOrder : pross.getProduceOrder()) {
|
|
|
- blankIds.add(produceOrder.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- blankIds = blankIds.stream().distinct().collect(Collectors.toList());
|
|
|
- // 排程计划设备集合
|
|
|
- List<Equipment> equipmentList1 = new ArrayList<>();
|
|
|
- List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
- .in(ApsProcessOperationDo::getBlankid, blankIds));
|
|
|
- for (ApsProcessOperationDo operationDo : operationDos1) {
|
|
|
- List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankIds,null,productionScheduleVo,apsConfigs.get(0));
|
|
|
- }
|
|
|
- productionScheduleVo.setEquipmentList(equipmentList1);
|
|
|
-
|
|
|
- System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- // APS平台排程接口调用
|
|
|
- ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
|
|
|
- if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
- throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
- }
|
|
|
- apsBlankOrderService.apsAfter(productionScheduleRetVo,dataMap.get(productionScheduleVo.getProductionScheduleId()));
|
|
|
- }*//*
|
|
|
- }*/
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.info("排程异常" + e);
|
|
@@ -532,6 +260,8 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
// 1卷一起排
|
|
|
List<ApsBlankOrderVo> singleApsList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProductionScheduleVo> apsProductionSchedules = new ArrayList<>();
|
|
|
// 多卷先排
|
|
|
apsBlankOrders.forEach((bo)->{
|
|
|
List<ApsBlankOrderVo> v = new ArrayList<>();
|
|
@@ -553,6 +283,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankids,null,productionScheduleVo,apsConfigs.get(0));
|
|
|
}
|
|
|
productionScheduleVo.setEquipmentList(equipmentList1);
|
|
|
+ apsProductionSchedules.add(productionScheduleVo);
|
|
|
|
|
|
System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
@@ -578,6 +309,229 @@ public class ApsServiceImpl implements ApsService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void apsOrderScheduleNew(List<ApsBlankOrderVo> apsBlankOrders,SysUserVo currentUser){
|
|
|
+ // 先按合金,合金状态分组,再每组分别排程
|
|
|
+ for (ApsBlankOrderVo apsBlankOrder : apsBlankOrders) {
|
|
|
+ apsBlankOrder.setVolumeMetalAndState(apsBlankOrder.getAlloy() + (apsBlankOrder.getAlloystatus() == null ? "" : apsBlankOrder.getAlloystatus()));
|
|
|
+ }
|
|
|
+ Map<String, List<ApsBlankOrderVo>> voms = apsBlankOrders.stream().collect(Collectors.groupingBy(ApsBlankOrderVo::getVolumeMetalAndState));
|
|
|
+ if(voms != null && voms.size()>0){
|
|
|
+ voms.forEach((k,v)->{
|
|
|
+ try{
|
|
|
+ apsOrderScheduleApsNew(v);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.info("排程异常" + e);
|
|
|
+ String msg = "排程服务异常";
|
|
|
+ if(e instanceof CustomException){
|
|
|
+ msg = e.getMessage();
|
|
|
+ }
|
|
|
+ currentUser.setRoption(msg);
|
|
|
+ String tenantId = CXCommonUtils.getCurrentUserFactoryId(currentUser);
|
|
|
+ redisService.redisCatchInit("apsUser-"+tenantId,currentUser,3600*24);
|
|
|
+// throw e;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void apsOrderScheduleApsNew(List<ApsBlankOrderVo> apsBlankOrders){
|
|
|
+ // 坯料计划排序
|
|
|
+ Collections.sort(apsBlankOrders,(v1,v2)->{
|
|
|
+ // 合金
|
|
|
+ String alloy1 = v1.getAlloy();
|
|
|
+ String alloy2 = v2.getAlloy();
|
|
|
+ // 合金状态
|
|
|
+ String alloystatus1 = v1.getAlloystatus();
|
|
|
+ String alloystatus2 = v2.getAlloystatus();
|
|
|
+ // 产品类型
|
|
|
+ String producttype1 = v1.getProducttype();
|
|
|
+ String producttype2 = v2.getProducttype();
|
|
|
+ // 宽度
|
|
|
+ BigDecimal prowidth1 = v1.getProwidth();
|
|
|
+ BigDecimal prowidth2 = v2.getProwidth();
|
|
|
+ // 厚度
|
|
|
+ BigDecimal thickness1 = v1.getThickness();
|
|
|
+ BigDecimal thickness2 = v2.getThickness();
|
|
|
+ // 重量
|
|
|
+ BigDecimal singlerollweight1 = v1.getSinglerollweight();
|
|
|
+ BigDecimal singlerollweight2 = v2.getSinglerollweight();
|
|
|
+
|
|
|
+ int a = 0;
|
|
|
+ // 插单优先
|
|
|
+ if(v1.getCdbs().compareTo(v2.getCdbs()) == 0){
|
|
|
+ // 合金
|
|
|
+ if(alloy1.compareTo(alloy2) == 0){
|
|
|
+ // 产品类型
|
|
|
+ if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
|
|
|
+ // 宽度
|
|
|
+ if(prowidth1.compareTo(prowidth2) == 0){
|
|
|
+ // 厚度
|
|
|
+ if(thickness1.compareTo(thickness2) == 0){
|
|
|
+ // 合金状态
|
|
|
+ if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
|
|
|
+ // 重量
|
|
|
+ if(singlerollweight1.compareTo(singlerollweight2) == 0){
|
|
|
+ // 按照订单排序
|
|
|
+ if(v1.getProductionorderid().compareTo(v2.getProductionorderid()) == 0){
|
|
|
+ // 卷数从大到小
|
|
|
+ a = v2.getRollnum().compareTo(v1.getRollnum());
|
|
|
+ }else{
|
|
|
+ a = v1.getProductionorderid().compareTo(v2.getProductionorderid());
|
|
|
+ }
|
|
|
+ }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
|
|
|
+ a = -1;
|
|
|
+ }else{
|
|
|
+ a = 1;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ a = alloystatus1.compareTo(alloystatus2);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(thickness1.compareTo(thickness2) > 0){
|
|
|
+ a = -1;
|
|
|
+ }else{
|
|
|
+ a = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(prowidth1.compareTo(prowidth2) > 0){
|
|
|
+ a = -1;
|
|
|
+ }else{
|
|
|
+ a = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ a = producttype1.compareTo(producttype2);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ a = alloy1.compareTo(alloy2);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ a = v1.getCdbs().compareTo(v2.getCdbs());
|
|
|
+ }
|
|
|
+ return a;
|
|
|
+ });
|
|
|
+ // 排程前解锁所有待排程订单
|
|
|
+ List<String> blankOrderIds = new ArrayList<>();
|
|
|
+ apsBlankOrders.forEach((bo)->{
|
|
|
+ blankOrderIds.add(bo.getId());
|
|
|
+ });
|
|
|
+ // 更新待排程的锁定的作业
|
|
|
+ if(blankOrderIds != null && blankOrderIds.size()>0){
|
|
|
+ String blankidStrs = CollUtil.join(blankOrderIds, "','");
|
|
|
+ blankidStrs = "'" + blankidStrs + "'";
|
|
|
+ apsBlankOrderDao.setLockMarkNullByToAps(blankidStrs);
|
|
|
+
|
|
|
+ // 更新排程明细数据锁定状态为否
|
|
|
+ /*processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"n")
|
|
|
+ .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));*/
|
|
|
+ apsBlankOrderDao.setProDetailLockMark(blankidStrs);
|
|
|
+ }
|
|
|
+ // 排程
|
|
|
+ List<ProductionScheduleVo> productionScheduleVos = new ArrayList<>();
|
|
|
+ Map<String,List<ApsBlankOrderVo>> dataMap = new HashMap<>();
|
|
|
+ Map<String,ApsBlankOrderVo> dataMapOrder = new HashMap<>();
|
|
|
+ JSONConfig jsonConfig = JSONConfig.create();
|
|
|
+ jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<ApsScheduleConfigDo> apsConfigs = apsScheduleConfigService.list();
|
|
|
+ // 所有设备
|
|
|
+ List<AspCheckItemsDo> eqs = aspCheckItemsService.list(new LambdaQueryWrapper<>());
|
|
|
+ Map<String, AspCheckItemsDo> eqMaps = new HashMap<>();
|
|
|
+ for (AspCheckItemsDo eq : eqs) {
|
|
|
+ eqMaps.put(eq.getId(), eq);
|
|
|
+ }
|
|
|
+ // 1卷一起排
|
|
|
+ List<ApsBlankOrderVo> singleApsList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProductionScheduleVo> apsProductionSchedules = new ArrayList<>();
|
|
|
+ // 多卷先排
|
|
|
+ apsBlankOrders.forEach((bo)->{
|
|
|
+ List<ApsBlankOrderVo> v = new ArrayList<>();
|
|
|
+ v.add(bo);
|
|
|
+ dataMapOrder.put(bo.getId(),bo);
|
|
|
+
|
|
|
+ // 模型转换
|
|
|
+ ProductionScheduleVo productionScheduleVo = apsProductionScheduleInit(v);
|
|
|
+ productionScheduleVos.add(productionScheduleVo);
|
|
|
+ dataMap.put(productionScheduleVo.getProductionScheduleId(),v);
|
|
|
+// int mergeThNum = mergeThNum(bo, productionScheduleVo);
|
|
|
+ // 排程计划设备集合
|
|
|
+ List<Equipment> equipmentList1 = new ArrayList<>();
|
|
|
+ List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
|
|
|
+ .in(ApsProcessOperationDo::getBlankid, bo.getId()));
|
|
|
+ List<String> blankids = new ArrayList<>();
|
|
|
+ blankids.add(bo.getId());
|
|
|
+ for (ApsProcessOperationDo operationDo : operationDos1) {
|
|
|
+ List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankids,null,productionScheduleVo,apsConfigs.get(0));
|
|
|
+ }
|
|
|
+ productionScheduleVo.setEquipmentList(equipmentList1);
|
|
|
+ apsProductionSchedules.add(productionScheduleVo);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 多个坯料计划合并排程
|
|
|
+ if(apsProductionSchedules != null && apsProductionSchedules.size()>0){
|
|
|
+ ProductionScheduleVo apsProductionSchedule = apsProductionSchedules.get(0);
|
|
|
+ List<ProductionProcesses> processes = new ArrayList<>();
|
|
|
+ List<Equipment> equipmentList = new ArrayList<>();
|
|
|
+ for (ProductionScheduleVo productionSchedule : apsProductionSchedules) {
|
|
|
+ processes.addAll(productionSchedule.getProcesses());
|
|
|
+ for (Equipment equipment : productionSchedule.getEquipmentList()) {
|
|
|
+ if(equipmentList.size()>0){
|
|
|
+// List<Equipment> haseqs = equipmentList.stream().filter(v -> v.getId().equals(equipment.getId())).collect(Collectors.toList());
|
|
|
+ int ia = -1;
|
|
|
+ for (int i = 0; i < equipmentList.size(); i++) {
|
|
|
+ if(equipmentList.get(i).getId().equals(equipment.getId())){
|
|
|
+ ia = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ia == -1){
|
|
|
+ equipmentList.add(equipment);
|
|
|
+ }else{
|
|
|
+ Equipment equipment1 = equipmentList.get(ia);
|
|
|
+ if(equipment1.getEquipmentRunTimes() != null && equipment1.getEquipmentRunTimes().size()>0){
|
|
|
+ if(equipment.getEquipmentRunTimes() != null && equipment.getEquipmentRunTimes().size()>0){
|
|
|
+ if(equipment.getEquipmentRunTimes().size() > equipment1.getEquipmentRunTimes().size()){
|
|
|
+ equipmentList.set(ia,equipment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ equipmentList.set(ia,equipment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ equipmentList.add(equipment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ apsProductionSchedule.setProcesses(processes);
|
|
|
+ apsProductionSchedule.setEquipmentList(equipmentList);
|
|
|
+
|
|
|
+ System.out.println("排程数据:" + JSONUtil.toJsonStr(apsProductionSchedule, jsonConfig));
|
|
|
+ logger.info("排程数据:" + JSONUtil.toJsonStr(apsProductionSchedule, jsonConfig));
|
|
|
+ // APS平台排程接口调用
|
|
|
+ ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(apsProductionSchedule);
|
|
|
+ if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
+ logger.info("排程异常,坯料计划ID:" + blankOrderIds);
|
|
|
+ // 排程异常后恢复历史排程结果为锁定状态
|
|
|
+ processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
|
|
|
+ .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));
|
|
|
+ // 没有可排程工序的订单跳过
|
|
|
+ if("没有可排程的工序".equals(productionScheduleRetVo.getMsg())){
|
|
|
+ logger.info("排程异常:没有可排程的工序,坯料计划编号:" + blankOrderIds);
|
|
|
+ }else{
|
|
|
+ throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 获取坯料计划
|
|
|
+ /*List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
|
|
|
+ apsBlankOrderss.add(bo);*/
|
|
|
+ apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrders);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算合并退火的个数
|
|
|
* @return
|
|
@@ -663,6 +617,10 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 退火合并厚差配置数据
|
|
|
List<ApsAnnealingDifferenceDo> apsAnnealingDifferenceDos = apsAnnealingDifferenceService.list();
|
|
|
productionScheduleVo.setApsAnnealingDifferences(apsAnnealingDifferenceDos);
|
|
|
+ // 铸轧兼容配置
|
|
|
+ List<ApsNochangeRollerDo> nochangeRollerDos = apsNochangeRollerService.list();
|
|
|
+ productionScheduleVo.setApsNochangeRollerDos(nochangeRollerDos);
|
|
|
+
|
|
|
return productionScheduleVo;
|
|
|
}
|
|
|
|
|
@@ -758,9 +716,26 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 设备列表
|
|
|
List<String> optionalEquipments = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(operationDo.getCanchoosedeviceid())) {
|
|
|
- String[] sbIds = operationDo.getCanchoosedeviceid().split(",");
|
|
|
+ String canchoosedeviceid = operationDo.getCanchoosedeviceid();
|
|
|
+ // 锁定作业添加可选设备里没有但已锁定排程明细的设备
|
|
|
+ if("y".equals(operationDo.getLockmark())){
|
|
|
+ List<ApsProcessOperationProcessEquDo> pros = processOperationProcessEquService.list(new LambdaQueryWrapper<ApsProcessOperationProcessEquDo>()
|
|
|
+ .eq(ApsProcessOperationProcessEquDo::getProcessid, operationDo.getId()));
|
|
|
+ if(pros != null && pros.size()>0){
|
|
|
+ for (ApsProcessOperationProcessEquDo pro : pros) {
|
|
|
+ if(!canchoosedeviceid.contains(pro.getProcessdeviceid())){
|
|
|
+ if(StrUtil.isBlank(canchoosedeviceid)){
|
|
|
+ canchoosedeviceid = pro.getProcessdeviceid();
|
|
|
+ }else{
|
|
|
+ canchoosedeviceid = canchoosedeviceid + "," + pro.getProcessdeviceid();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] sbIds = canchoosedeviceid.split(",");
|
|
|
for (String equIds : sbIds) {
|
|
|
- if(equIds.equals("0001be252874536843730b100052")){
|
|
|
+ if(equIds.equals("09be204864014e88ac19d5ac9950fa32")){
|
|
|
System.out.println(equIds);
|
|
|
}
|
|
|
AspCheckItemsDo checkItemsD = eqMaps.get(equIds);
|
|
@@ -920,7 +895,11 @@ public class ApsServiceImpl implements ApsService {
|
|
|
// 合金+输入物料+宽度+厚度
|
|
|
er.setSeriesProduceMark(processesDo.getMetal() + "^_^" + processesDo.getProducttype() + "^_^" + processesDo.getProwidth() + "^_^" + processesDo.getThickness() + "^_^" + outMaterDos.get(0).getThickness());
|
|
|
er.setVolumeMetal(processesDo.getMetal());
|
|
|
- er.setVolumeMetalstate(processesDo.getMetalstate());
|
|
|
+ if("成退".equals(processesDo.getProcess()) || "中退".equals(processesDo.getProcess()) || "小卷成退".equals(processesDo.getProcess())){
|
|
|
+ er.setVolumeMetalstate(outMaterDos.get(0).getMetalstate());
|
|
|
+ }else{
|
|
|
+ er.setVolumeMetalstate(processesDo.getMetalstate());
|
|
|
+ }
|
|
|
er.setPrepressworkmin(processesDo.getPrepressworkmin() == null ? null : processesDo.getPrepressworkmin().intValue());
|
|
|
er.setCutfinishmin(processesDo.getCutfinishmin() == null ? null : processesDo.getCutfinishmin().intValue());
|
|
|
// 单卷宽度、重量数据赋值
|
|
@@ -930,6 +909,7 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}else{
|
|
|
er.setTotalSinglerollweight(processesDo.getSinglerollweight());
|
|
|
}
|
|
|
+
|
|
|
er.setProducttype(processesDo.getProducttype());
|
|
|
er.setTotalThickness(processesDo.getThickness());
|
|
|
er.setOnceprocessmin(processesDo.getOnceprocessmin().intValue());
|
|
@@ -1014,6 +994,9 @@ public class ApsServiceImpl implements ApsService {
|
|
|
if(vi>=v.size()){
|
|
|
break;
|
|
|
}
|
|
|
+ if(i == productionProcesses.size()){
|
|
|
+ int aaa = 1;
|
|
|
+ }
|
|
|
if(productionProcesses.get(i).getNextProcessesIds() == null){
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
ids.add(v.get(vi).getId());
|