|
@@ -73,9 +73,13 @@ public class ApsServiceImpl implements ApsService {
|
|
|
@Autowired
|
|
|
private ApsMergeFurnaceService apsMergeFurnaceService;
|
|
|
|
|
|
+ /**
|
|
|
+ * Aps排程
|
|
|
+ * @param apsBlankOrders
|
|
|
+ * @param apsType cd:插单
|
|
|
+ */
|
|
|
@Override
|
|
|
-// @Async("customThreadPool")
|
|
|
- public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders) {
|
|
|
+ public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders,String apsType) {
|
|
|
// 当前等路人所属工厂
|
|
|
SysUserVo currentUser = CXCommonUtils.getCurrentUser();
|
|
|
String tenantId = currentUser.getOrganizationDoList().get(0).getFullpid().split(",")[1];
|
|
@@ -101,273 +105,23 @@ public class ApsServiceImpl implements ApsService {
|
|
|
idStrs = CollUtil.join(hasIds, "','");
|
|
|
idStrs = "'" + idStrs + "'";
|
|
|
}
|
|
|
-
|
|
|
// 查询存在未锁定的作业坯料计划
|
|
|
-// List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getFbNotLock(idStrs,tenantId);
|
|
|
- List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
|
|
|
- if (fbNotLock != null && fbNotLock.size() > 0) {
|
|
|
- apsBlankOrders.addAll(fbNotLock);
|
|
|
- }
|
|
|
- // 坯料计划排序
|
|
|
- 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(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){
|
|
|
-// a = 0;
|
|
|
- // 卷数从大到小
|
|
|
- a = v2.getRollnum().compareTo(v1.getRollnum());
|
|
|
- }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);
|
|
|
+ // 插单重排会优先排插单再排程其它的订单
|
|
|
+ if("cd".equals(apsType) && apsBlankOrders != null && apsBlankOrders.size()>0){
|
|
|
+ apsOrderSchedule(apsBlankOrders);
|
|
|
+ List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
|
|
|
+ if (fbNotLock != null && fbNotLock.size() > 0) {
|
|
|
+ apsOrderSchedule(fbNotLock);
|
|
|
}
|
|
|
- return a;
|
|
|
- });
|
|
|
- // 排程前解锁所有待排程订单
|
|
|
- List<String> blankOrderIds = new ArrayList<>();
|
|
|
- apsBlankOrders.forEach((bo)->{
|
|
|
- blankOrderIds.add(bo.getId());
|
|
|
- });
|
|
|
- processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"n")
|
|
|
- .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));
|
|
|
- // 更新待排程的锁定的作业
|
|
|
- if(blankOrderIds != null && blankOrderIds.size()>0){
|
|
|
- String blankidStrs = CollUtil.join(blankOrderIds, "','");
|
|
|
- blankidStrs = "'" + blankidStrs + "'";
|
|
|
- apsBlankOrderDao.setLockMarkNullByToAps(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);
|
|
|
+ }else{
|
|
|
+ List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
|
|
|
+ if (fbNotLock != null && fbNotLock.size() > 0) {
|
|
|
+ apsBlankOrders.addAll(fbNotLock);
|
|
|
+ }
|
|
|
+ apsOrderSchedule(apsBlankOrders);
|
|
|
}
|
|
|
- // 1卷一起排
|
|
|
- List<ApsBlankOrderVo> singleApsList = new ArrayList<>();
|
|
|
- // 多卷先排
|
|
|
- apsBlankOrders.forEach((bo)->{
|
|
|
- /*if(bo.getRollnum() == 1){
|
|
|
- singleApsList.add(bo);
|
|
|
- }else{*/
|
|
|
- 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);
|
|
|
-
|
|
|
- System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
- // APS平台排程接口调用
|
|
|
- ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
|
|
|
- if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
- logger.info("排程异常,坯料计划ID:" + bo.getId());
|
|
|
- /*processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
|
|
|
- .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));*/
|
|
|
- throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
- }
|
|
|
- // 获取坯料计划
|
|
|
- List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
|
|
|
- apsBlankOrderss.add(bo);
|
|
|
- apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
|
|
|
-// }
|
|
|
-
|
|
|
- /*if(bo.getRollnum()>mergeThNum){
|
|
|
- Map<String,ProductionProcesses> allProcesses = new HashMap<>();
|
|
|
- List<ProductionProcesses> rootProcesses = new ArrayList<>();
|
|
|
- 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 += mergeThNum) {
|
|
|
- chunks.add(rootProcesses.subList(i, Math.min(i + mergeThNum, 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);
|
|
|
- }
|
|
|
- // 排程计划设备集合
|
|
|
- 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<>();
|
|
|
- apsBlankOrderss.add(bo);
|
|
|
- apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
|
|
|
- }
|
|
|
- }else{*/
|
|
|
-
|
|
|
-// }
|
|
|
- });
|
|
|
// 1卷排程
|
|
|
/*if(singleApsList != null && singleApsList.size()>0){
|
|
|
// 模型转换
|
|
@@ -660,6 +414,262 @@ public class ApsServiceImpl implements ApsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void apsOrderSchedule(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(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){
|
|
|
+// a = 0;
|
|
|
+ // 卷数从大到小
|
|
|
+ a = v2.getRollnum().compareTo(v1.getRollnum());
|
|
|
+ }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);
|
|
|
+ }
|
|
|
+ return a;
|
|
|
+ });
|
|
|
+ // 排程前解锁所有待排程订单
|
|
|
+ List<String> blankOrderIds = new ArrayList<>();
|
|
|
+ apsBlankOrders.forEach((bo)->{
|
|
|
+ blankOrderIds.add(bo.getId());
|
|
|
+ });
|
|
|
+ processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"n")
|
|
|
+ .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));
|
|
|
+ // 更新待排程的锁定的作业
|
|
|
+ if(blankOrderIds != null && blankOrderIds.size()>0){
|
|
|
+ String blankidStrs = CollUtil.join(blankOrderIds, "','");
|
|
|
+ blankidStrs = "'" + blankidStrs + "'";
|
|
|
+ apsBlankOrderDao.setLockMarkNullByToAps(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<>();
|
|
|
+ // 多卷先排
|
|
|
+ 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);
|
|
|
+
|
|
|
+ System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
+ logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
|
|
|
+ // APS平台排程接口调用
|
|
|
+ ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
|
|
|
+ if (!"200".equals(productionScheduleRetVo.getCode())) {
|
|
|
+ logger.info("排程异常,坯料计划ID:" + bo.getId());
|
|
|
+ /*processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
|
|
|
+ .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));*/
|
|
|
+ throw new CustomException(productionScheduleRetVo.getMsg());
|
|
|
+ }
|
|
|
+ // 获取坯料计划
|
|
|
+ List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
|
|
|
+ apsBlankOrderss.add(bo);
|
|
|
+ apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
|
|
|
+ /*if(bo.getRollnum()>mergeThNum){
|
|
|
+ Map<String,ProductionProcesses> allProcesses = new HashMap<>();
|
|
|
+ List<ProductionProcesses> rootProcesses = new ArrayList<>();
|
|
|
+ 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 += mergeThNum) {
|
|
|
+ chunks.add(rootProcesses.subList(i, Math.min(i + mergeThNum, 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);
|
|
|
+ }
|
|
|
+ // 排程计划设备集合
|
|
|
+ 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<>();
|
|
|
+ apsBlankOrderss.add(bo);
|
|
|
+ apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
|
|
|
+ }
|
|
|
+ }else{*/
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算合并退火的个数
|
|
|
* @return
|