|
@@ -6,7 +6,12 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterTableAlterColumn
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
|
|
|
|
+import com.github.zuihou.authority.dao.auth.UserMapper;
|
|
|
|
+import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
|
|
|
|
+import com.github.zuihou.authority.entity.auth.User;
|
|
import com.github.zuihou.authority.entity.common.DictionaryItem;
|
|
import com.github.zuihou.authority.entity.common.DictionaryItem;
|
|
|
|
+import com.github.zuihou.authority.service.common.ParameterService;
|
|
import com.github.zuihou.base.R;
|
|
import com.github.zuihou.base.R;
|
|
import com.github.zuihou.base.service.SuperServiceImpl;
|
|
import com.github.zuihou.base.service.SuperServiceImpl;
|
|
import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
@@ -29,14 +34,14 @@ import com.github.zuihou.business.productionReadyCenter.service.AutoNodeService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.BBomService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.BBomService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.MMeterialReceiveLogService;
|
|
import com.github.zuihou.business.productionReadyCenter.service.MMeterialReceiveLogService;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneMapper;
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Repair;
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Repair;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
import com.github.zuihou.business.productionResourceCenter.service.RepairService;
|
|
import com.github.zuihou.business.productionResourceCenter.service.RepairService;
|
|
import com.github.zuihou.business.util.DynamicRabbitMq;
|
|
import com.github.zuihou.business.util.DynamicRabbitMq;
|
|
-import com.github.zuihou.common.constant.BizConstant;
|
|
|
|
-import com.github.zuihou.common.constant.CacheKey;
|
|
|
|
-import com.github.zuihou.common.constant.CodeRuleModule;
|
|
|
|
-import com.github.zuihou.common.constant.RepeatCacheKey;
|
|
|
|
|
|
+import com.github.zuihou.common.constant.*;
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
@@ -96,8 +101,6 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
@Autowired
|
|
@Autowired
|
|
private PlanProductMapper planProductMapper;
|
|
private PlanProductMapper planProductMapper;
|
|
@Autowired
|
|
@Autowired
|
|
- private TTaskMapper taskMapper;
|
|
|
|
- @Autowired
|
|
|
|
private AutoNodeService autoNodeService;
|
|
private AutoNodeService autoNodeService;
|
|
@Autowired
|
|
@Autowired
|
|
private OrderZoneService orderZoneService;
|
|
private OrderZoneService orderZoneService;
|
|
@@ -128,6 +131,17 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private BBomMapper bBomMapper;
|
|
private BBomMapper bBomMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParameterService parameterService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StationUserLoginInfoMapper stationUserLoginInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ZZoneMapper zZoneMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public IPage<Order> pageList(IPage page,String sustDesc, LbqWrapper<Order> wrapper) {
|
|
public IPage<Order> pageList(IPage page,String sustDesc, LbqWrapper<Order> wrapper) {
|
|
@@ -447,7 +461,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
}
|
|
}
|
|
|
|
|
|
//把之前的预生成的数据删除
|
|
//把之前的预生成的数据删除
|
|
- taskMapper.delete(Wraps.<TTask>lbQ().eq(TTask::getDraftFlag,"1").in(TTask::getOrderId,idList));
|
|
|
|
|
|
+ taskService.remove(Wraps.<TTask>lbQ().eq(TTask::getDraftFlag,"1").in(TTask::getOrderId,idList));
|
|
planProductMapper.delete(Wraps.<PlanProduct>lbQ().eq(PlanProduct::getDraftFlag,"1").in(PlanProduct::getOrderId,idList));
|
|
planProductMapper.delete(Wraps.<PlanProduct>lbQ().eq(PlanProduct::getDraftFlag,"1").in(PlanProduct::getOrderId,idList));
|
|
planMapper.delete(Wraps.<Plan>lbQ().eq(Plan::getDraftFlag,"1").in(Plan::getOrderId,idList));
|
|
planMapper.delete(Wraps.<Plan>lbQ().eq(Plan::getDraftFlag,"1").in(Plan::getOrderId,idList));
|
|
|
|
|
|
@@ -649,7 +663,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
taskService.update(task,Wraps.<TTask>lbQ().in(TTask::getPlanId,planIds));
|
|
taskService.update(task,Wraps.<TTask>lbQ().in(TTask::getPlanId,planIds));
|
|
|
|
|
|
//把首任务放到mq中
|
|
//把首任务放到mq中
|
|
- List<TTask>taskList = taskMapper.selectList(Wraps.<TTask>lbQ().in(TTask::getPlanId,planIds));
|
|
|
|
|
|
+ List<TTask>taskList = taskService.list(Wraps.<TTask>lbQ().in(TTask::getPlanId,planIds));
|
|
//把一些重要信息存放缓存
|
|
//把一些重要信息存放缓存
|
|
pushToRedis(taskList);
|
|
pushToRedis(taskList);
|
|
pushToMq(taskList);
|
|
pushToMq(taskList);
|
|
@@ -722,157 +736,163 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
QueryWrapper<Plan> planWrapper = new QueryWrapper<Plan>();
|
|
QueryWrapper<Plan> planWrapper = new QueryWrapper<Plan>();
|
|
planWrapper.eq("plan_status", "2");
|
|
planWrapper.eq("plan_status", "2");
|
|
List<Plan> plans = planMapper.selectList(planWrapper);
|
|
List<Plan> plans = planMapper.selectList(planWrapper);
|
|
- Map<Long,Plan> plansMap = plans.stream().collect(Collectors.toMap(Plan::getId, t->t));
|
|
|
|
|
|
|
|
List<Long> planIds = plans.stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
List<Long> planIds = plans.stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
List<Long> orderIds = plans.stream().map(p -> p.getOrderId()).collect(Collectors.toList());
|
|
List<Long> orderIds = plans.stream().map(p -> p.getOrderId()).collect(Collectors.toList());
|
|
|
|
|
|
- // 未生产工件表
|
|
|
|
- QueryWrapper<TWorkpiece> tWorkpieceWrapper = new QueryWrapper<TWorkpiece>();
|
|
|
|
- tWorkpieceWrapper.in("planId", planIds);
|
|
|
|
- tWorkpieceWrapper.in("produce_status", "1");
|
|
|
|
- List<TWorkpiece> tWorkpieces = workpieceMapper.selectList(tWorkpieceWrapper);
|
|
|
|
-
|
|
|
|
- List<OrderProduct> orderProductList = orderProductService.list(Wraps.<OrderProduct>lbQ().in(OrderProduct::getOrderId,orderIds));
|
|
|
|
- Map<Long,OrderProduct> orderProductListMap = orderProductList.stream().collect(Collectors.toMap(OrderProduct::getBomId, t->t));
|
|
|
|
|
|
+ List<PlanProduct> planProductList = planProductService.list(Wraps.<PlanProduct>lbQ().in(PlanProduct::getPlanId, planIds));
|
|
|
|
+ List<Long> planBomIds = planProductList.stream().map(p -> p.getBomId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
+ List<OrderProduct> orderProductList = orderProductService.list(Wraps.<OrderProduct>lbQ().in(OrderProduct::getOrderId,orderIds).in(OrderProduct::getBomId,planBomIds));
|
|
//查出所有产品ID
|
|
//查出所有产品ID
|
|
List<PlanProduct> productList = planProductMapper.selectList(Wraps.<PlanProduct>lbQ().in(PlanProduct::getPlanId, planIds));
|
|
List<PlanProduct> productList = planProductMapper.selectList(Wraps.<PlanProduct>lbQ().in(PlanProduct::getPlanId, planIds));
|
|
- Map<Long,Long> planProductMap = productList.stream().collect(Collectors.toMap(PlanProduct::getPlanId, t->t.getBomId()));
|
|
|
|
|
|
|
|
- List<Long> bomIdList = productList.stream().map(p -> p.getBomId()).collect(Collectors.toList());
|
|
|
|
//查出本次需要得工艺信息
|
|
//查出本次需要得工艺信息
|
|
- Map<Long, List<BomProcedure>> bomProcedureMap = bomProcedureService.getBomProcedureMap(bomIdList);
|
|
|
|
|
|
+ Map<Long, List<BomProcedure>> bomProcedureMap = bomProcedureService.getBomProcedureMap(planBomIds);
|
|
|
|
+
|
|
|
|
+ // 可选设备集合(工序名称+可选设备列表)
|
|
|
|
+ Map<String, List<CandidateProcess>> candidateProMap = new HashMap<>(); // 可选处理集合(可选设备以及对应的加工时间)
|
|
|
|
+ // 工序集合(工序名+工序)
|
|
|
|
+ Map<String, TTask> operationMap = new HashMap<>();
|
|
|
|
+ // 设备集合(设备名+设备)
|
|
|
|
+ Map<String, Machine> machineMap = new HashMap<>();
|
|
|
|
+ // 零件集合(零件名称+零件)
|
|
|
|
+ Map<String, TWorkpiece> partMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ Map<Long,OrderProduct> orderProductMap = orderProductList.stream().collect(Collectors.toMap(OrderProduct::getId, t->t));
|
|
|
|
+
|
|
|
|
+ // 排产需要的数组组装进行优化,提高组装数据的时效
|
|
|
|
+ double totalOpNum = 0.0;
|
|
|
|
+ for(int partIndex = 1;partIndex <= planProductList.size(); partIndex++){
|
|
|
|
+ PlanProduct planProduct = planProductList.get(partIndex - 1);
|
|
|
|
+ OrderProduct orderProduct = orderProductMap.get(planProduct.getOrderProductId());
|
|
|
|
+ Long bomId = planProduct.getBomId();
|
|
|
|
+ List<BomProcedure> bomProcedureList = bomProcedureMap.get(bomId);
|
|
|
|
+ String stationGaSwitchFlag = parameterService.getValue(ParameterKey.STATION_GA_SWITCH_FLAG, null);
|
|
|
|
+ List<Long> stationResourcesIds = new ArrayList<>();
|
|
|
|
+ if("1".equals(stationGaSwitchFlag)){
|
|
|
|
+ // 将人工上下料放在排产中计算,上下料工艺配置中可配置所有上下料,实际排产中根据上下料站人员登录的实际情况和订单产品进行绑定,将不是该订单产线登录的人员上下料站剔除
|
|
|
|
+ // 取得当前上下料站人员登录情况
|
|
|
|
+ Order order = baseMapper.selectById(orderProduct.getOrderId());
|
|
|
|
+ Long zoneId = order.getZoneId();
|
|
|
|
+ ZZone zZone = zZoneMapper.selectById(zoneId);
|
|
|
|
+ Long orgId = zZone.getOrgId();
|
|
|
|
+
|
|
|
|
+ // 查询该机构下的所有用户对应的上下料站
|
|
|
|
+ LbqWrapper<User> userWrapper = new LbqWrapper<User>().eq(User::getOrg, orgId);
|
|
|
|
+ List<User> orgUsers = userMapper.selectList(userWrapper);
|
|
|
|
+ List<Long> userIds = orgUsers.stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
|
|
+ LbqWrapper<StationUserLoginInfo> stationUserLoginInfoWrapper = new LbqWrapper<StationUserLoginInfo>().in(StationUserLoginInfo::getUserId, userIds);
|
|
|
|
+ List<StationUserLoginInfo> stationUserLoginInfos = stationUserLoginInfoMapper.selectList(stationUserLoginInfoWrapper);
|
|
|
|
+ // 工人上下料站人员信息
|
|
|
|
+ stationResourcesIds = stationUserLoginInfos.stream().map(p -> p.getStationId()).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if(stationResourcesIds.size() == 0){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
-// // 可选设备集合(工序名称+可选设备列表)
|
|
|
|
-// Map<String, List<CandidateProcess>> candidateProMap = new HashMap<>(); // 可选处理集合(可选设备以及对应的加工时间)
|
|
|
|
-// // 工序集合(工序名+工序)
|
|
|
|
-// Map<String, Operation> operationMap = new HashMap<>();
|
|
|
|
-// // 设备集合(设备名+设备)
|
|
|
|
-// Map<String, Machine> machineMap = new HashMap<>();
|
|
|
|
-// // 零件集合(零件名称+零件)
|
|
|
|
-// Map<String, Part> partMap = new HashMap<>();
|
|
|
|
-// Map<Long,OrderProduct> orderProductMap = orderProductList.stream().collect(Collectors.toMap(OrderProduct::getId, t->t));
|
|
|
|
-//
|
|
|
|
-// List<TTask> taskList = new ArrayList<TTask>();
|
|
|
|
-// //设置completeBatchNo
|
|
|
|
-// Map<String,String> completeBatchNoMap = new HashMap<String,String>();
|
|
|
|
-// double totalOpNum = 0.0;
|
|
|
|
-//
|
|
|
|
-// for(TWorkpiece tWorkpiece : tWorkpieces){
|
|
|
|
-// Long bomId = planProductMap.get(tWorkpiece.getPlanId());
|
|
|
|
-// List<BomProcedure> bomProcedureList = bomProcedureMap.get(bomId);
|
|
|
|
-// Map<Long,BomProcedure> bomProcedureListMap = bomProcedureList.stream().collect(Collectors.toMap(BomProcedure::getId, t->t));
|
|
|
|
-// Part part = new Part();
|
|
|
|
-// List<CandidateProcess> candidateProcesses = new ArrayList<CandidateProcess>();
|
|
|
|
-// // 根据工件id查找未加工的任务
|
|
|
|
-// QueryWrapper<TTask> tTaskWrapper = new QueryWrapper<TTask>();
|
|
|
|
-// planWrapper.in("completeBatchNo", tWorkpiece.getCompleteBatchNo());
|
|
|
|
-// planWrapper.eq("status", "1");
|
|
|
|
-// List<TTask> tTasks = taskMapper.selectList(tTaskWrapper);
|
|
|
|
-// List<Operation> opList = new ArrayList<Operation>();
|
|
|
|
-//
|
|
|
|
-// for(TTask tTask : tTasks){
|
|
|
|
-// BomProcedure bomProcedure = bomProcedureListMap.get(tTask.getProcedureId());
|
|
|
|
-// if (bomProcedure.getProductionresourceList().size() > 0){
|
|
|
|
-// Machine machine = new Machine();
|
|
|
|
-// CandidateProcess candidateProcess = new CandidateProcess();
|
|
|
|
-// for(BomProcedureProductionresource bomProcedureProductionresource : bomProcedure.getProductionresourceList()){
|
|
|
|
-// if(!machineMap.containsKey(bomProcedureProductionresource.getResourceId())){
|
|
|
|
-// machine.setId(bomProcedureProductionresource.getResourceId().longValue());
|
|
|
|
-// // 添加设备维保时间片
|
|
|
|
-// LbqWrapper<Repair> repairWrapper = new LbqWrapper<Repair>().eq(Repair::getProductionresourceId, bomProcedureProductionresource.getResourceId()).gt(Repair::getRepairStartTime, cn.hutool.core.date.DateUtil.toLocalDateTime(cn.hutool.core.date.DateUtil.date()));
|
|
|
|
-// List<Repair> repairs = repairService.list(repairWrapper);
|
|
|
|
-// for(Repair repair : repairs){
|
|
|
|
-// machine.getNoUseTime().add(Timestamp.valueOf(repair.getRepairStartTime()).getTime() + "-" + Timestamp.valueOf(repair.getRepairEndTime()).getTime());
|
|
|
|
-// }
|
|
|
|
-// machineMap.put("M" + bomProcedureProductionresource.getResourceId(), machine);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if(!candidateProMap.containsKey(tWorkpiece.getCompleteBatchNo() + "_" + bomProcedure.getNo())){
|
|
|
|
-// candidateProcess.setMachineId(bomProcedureProductionresource.getResourceId());
|
|
|
|
-// LbqWrapper<BomProcedureProgram> bomProcedureProgramWrapper = new LbqWrapper<BomProcedureProgram>().eq(BomProcedureProgram::getResourceId, bomProcedureProductionresource.getResourceId()).eq(BomProcedureProgram::getProcedureId,bomProcedureProductionresource.getProcedureId());
|
|
|
|
-// BomProcedureProgram bomProcedureProgram = bomProcedureProgramMapper.selectOne(bomProcedureProgramWrapper);
|
|
|
|
-// // 人工上下料没有程序的情况直接用工序时间
|
|
|
|
-// if(null != bomProcedureProgram && null != bomProcedureProgram.getWorkTime()){
|
|
|
|
-// candidateProcess.setProcedureId(bomProcedureProgram.getProcedureId());
|
|
|
|
-// candidateProcess.setDuration(bomProcedureProgram.getWorkTime().intValue());
|
|
|
|
-// candidateProcess.setRunTime(bomProcedureProgram.getWorkTime());
|
|
|
|
-// }else{
|
|
|
|
-// candidateProcess.setProcedureId(bomProcedure.getId());
|
|
|
|
-// //candidateProcess.setDuration(bomProcedure.getPrepareWorkhours().intValue() + bomProcedure.getRatedWorkhours().intValue());
|
|
|
|
-// candidateProcess.setDuration(bomProcedure.getRatedWorkhours().intValue());
|
|
|
|
-// candidateProcess.setRunTime( bomProcedure.getRatedWorkhours());
|
|
|
|
-// }
|
|
|
|
-// if(!candidateProcesses.contains(candidateProcess)){
|
|
|
|
-// candidateProcesses.add(candidateProcess);
|
|
|
|
-// }
|
|
|
|
-// candidateProMap.put(tWorkpiece.getCompleteBatchNo() + "_" + bomProcedure.getNo(),candidateProcesses);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// // 组装排产所以的工序信息
|
|
|
|
-// Operation operation = new Operation();
|
|
|
|
-// operation.setId(String.valueOf(tTask.getId()));
|
|
|
|
-// operation.setPartId(tTask.getCompleteBatchNo());
|
|
|
|
-// operation.setName(tTask.getProcedureNo());
|
|
|
|
-// operation.setSeq(tTask.getProcedureSort()+1);
|
|
|
|
-// operation.setDueDate(orderProductListMap.get(tWorkpiece.getBomId()).getDeliveryTime().getTime());
|
|
|
|
-// operation.setPlanQty(1);
|
|
|
|
-// String operationKey = tTask.getCompleteBatchNo() + "_" + tTask.getProcedureNo();
|
|
|
|
-// operationMap.put(operationKey,operation);
|
|
|
|
-// opList.add(operation);
|
|
|
|
-// totalOpNum ++;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// part.setId(tWorkpiece.getCompleteBatchNo());
|
|
|
|
-// part.setOperationNum(bomProcedureList.size());
|
|
|
|
-// part.setOpList(opList);
|
|
|
|
-// // 根据最终版本调整交互日期及优先级
|
|
|
|
-// part.setDueDate(orderProductListMap.get(tWorkpiece.getBomId()).getDeliveryTime().getTime());
|
|
|
|
-// part.setPartPrority(plansMap.get(tWorkpiece.getPlanId()).getPrority());
|
|
|
|
-// partMap.put(tWorkpiece.getCompleteBatchNo(),part);
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// // 调用java简易排产
|
|
|
|
-// Instance instance = new Instance();
|
|
|
|
-// instance.setTotalOpNum(totalOpNum);
|
|
|
|
-// // 赋值设备map
|
|
|
|
-// instance.setMachineMap(machineMap);
|
|
|
|
-// // 创造零件map
|
|
|
|
-// instance.setPartMap(partMap);
|
|
|
|
-// // 创造工序map
|
|
|
|
-// instance.setOperationMap(operationMap);
|
|
|
|
-// // 创造工序可选设备集合map
|
|
|
|
-// instance.setCandidateProMap(candidateProMap);
|
|
|
|
-//
|
|
|
|
-// GAScheduler gaScheduler = new GAScheduler(instance, GAScheduler.PRIORITY_CODE);
|
|
|
|
-// try{
|
|
|
|
-// gaScheduler.schedule();
|
|
|
|
-// }catch(Exception e){
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// // 更新task表人工序任务的预计开始时间及结束时间
|
|
|
|
-// Iterator<Map.Entry<String, Operation>> it = instance.getOperationMap().entrySet().iterator();
|
|
|
|
-// while(it.hasNext()){
|
|
|
|
-// Operation operation = it.next().getValue();
|
|
|
|
-// for(TTask task : taskList){
|
|
|
|
-// if(task.getTmpId().equals(operation.getId())){
|
|
|
|
-// List<BomProcedureProductionresource> procedureProductionresourceList = procedureProductionresourceMapper.selectList(Wraps.<BomProcedureProductionresource>lbQ().eq(BomProcedureProductionresource::getProcedureId,task.getProcedureId()).
|
|
|
|
-// eq(BomProcedureProductionresource::getResourceId,operation.getMachineId()).orderByDesc(BomProcedureProductionresource::getCreateTime));
|
|
|
|
-// task.setExpectStartTime(new Date(operation.getStart()));
|
|
|
|
-// task.setExpectEndTime(new Date(operation.getFinish()));
|
|
|
|
-// task.setResourceId(operation.getMachineId());
|
|
|
|
-// if(CollectionUtil.isNotEmpty(procedureProductionresourceList)){
|
|
|
|
-// task.setResourceBusinessId(procedureProductionresourceList.get(0).getResourceBusinessId());
|
|
|
|
-// }
|
|
|
|
-// taskMapper.updateAllById(task);
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
|
|
+ // 根据计划查询工件和任务
|
|
|
|
+ LbqWrapper<TWorkpiece> workpieceWrapper = new LbqWrapper<TWorkpiece>().in(TWorkpiece::getPlanId, planProduct.getPlanId());
|
|
|
|
+ List<TWorkpiece> planWorkpieces = workpieceMapper.selectList(workpieceWrapper);
|
|
|
|
+
|
|
|
|
+ Map<String,List<CandidateProcess>> operationCandidateProcesses = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ for(int partNum = 0; partNum < planWorkpieces.size(); partNum++){
|
|
|
|
+ TWorkpiece workpiece = planWorkpieces.get(partNum);
|
|
|
|
+ List<TTask> opList = new ArrayList<TTask>();
|
|
|
|
+
|
|
|
|
+ // 根据工件id查询工件工序
|
|
|
|
+ LbqWrapper<TTask> tTaskWrapper = new LbqWrapper<TTask>().in(TTask::getCompleteBatchNo, workpiece.getCompleteBatchNo()).eq(TTask::getStatus,"1").orderByAsc(TTask::getProcedureSort);
|
|
|
|
+ List<TTask> tTasks = taskService.list(tTaskWrapper);
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < tTasks.size(); i++){
|
|
|
|
+ TTask tTask = tTasks.get(i);
|
|
|
|
+ String operationkey = tTask.getCompleteBatchNo() + "_" + tTask.getProcedureNo();
|
|
|
|
+ operationMap.put(operationkey,tTask);
|
|
|
|
+ opList.add(tTask);
|
|
|
|
+ totalOpNum ++;
|
|
|
|
+
|
|
|
|
+ // 组装排产工序对应设备
|
|
|
|
+ // 工序可用设备
|
|
|
|
+ List<CandidateProcess> candidateProcesses = new ArrayList<CandidateProcess>();
|
|
|
|
+ BomProcedure bomProcedure = bomProcedureList.get(tTask.getProcedureSort());
|
|
|
|
+
|
|
|
|
+ // 同一计划订单中的工件工序对应设备信息只要找一次后用工序匹配
|
|
|
|
+ if(operationCandidateProcesses.containsKey(tTask.getProcedureNo())){
|
|
|
|
+ candidateProMap.put(workpiece.getCompleteBatchNo() + "_" + bomProcedure.getNo(), operationCandidateProcesses.get(tTask.getProcedureNo()));
|
|
|
|
+ }else{
|
|
|
|
+ if (bomProcedure.getProductionresourceList().size() > 0){
|
|
|
|
+ for(BomProcedureProductionresource bomProcedureProductionresource : bomProcedure.getProductionresourceList()){
|
|
|
|
+ Machine machine = new Machine();
|
|
|
|
+ CandidateProcess candidateProcess = new CandidateProcess();
|
|
|
|
+
|
|
|
|
+ if(bomProcedure.getType().contains("上料") || bomProcedure.getType().contains("下料") || bomProcedure.getType().contains("翻面")){
|
|
|
|
+ if("0".equals(stationGaSwitchFlag)){
|
|
|
|
+ taskService.assemblingCandidate(candidateProMap, machineMap, workpiece, candidateProcesses, bomProcedure, machine, candidateProcess, bomProcedureProductionresource);
|
|
|
|
+ }else if("1".equals(stationGaSwitchFlag)){
|
|
|
|
+ if(stationResourcesIds.contains(bomProcedureProductionresource.getResourceId())){
|
|
|
|
+ taskService.assemblingCandidate(candidateProMap, machineMap, workpiece, candidateProcesses, bomProcedure, machine, candidateProcess, bomProcedureProductionresource);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ // 查询设备状态
|
|
|
|
+ Productionresource productionresource = productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId, bomProcedureProductionresource.getResourceId()));
|
|
|
|
+ if("1".equals(productionresource.getStatus()) || "1".equals(productionresource.getOnlineStatus())){
|
|
|
|
+ taskService.assemblingCandidate(candidateProMap, machineMap, workpiece, candidateProcesses, bomProcedure, machine, candidateProcess, bomProcedureProductionresource);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ candidateProMap.put(workpiece.getCompleteBatchNo() + "_" + bomProcedure.getNo(), candidateProcesses.stream().sorted(Comparator.comparing(CandidateProcess::getPrority,Comparator.reverseOrder())).collect(Collectors.toList()));
|
|
|
|
+ operationCandidateProcesses.put(bomProcedure.getNo(), candidateProcesses.stream().sorted(Comparator.comparing(CandidateProcess::getPrority,Comparator.reverseOrder())).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ workpiece.setOperationNum(tTasks.size());
|
|
|
|
+ workpiece.setOpList(opList);
|
|
|
|
+ // 根据最终版本调整交互日期及优先级
|
|
|
|
+ workpiece.setDueDate(orderProduct.getDeliveryTime().getTime());
|
|
|
|
+ workpiece.setPartPrority(orderProduct.getPrority());
|
|
|
|
+ partMap.put(workpiece.getCompleteBatchNo(),workpiece);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 调用java简易排产
|
|
|
|
+ Instance instance = new Instance();
|
|
|
|
+ instance.setTotalOpNum(totalOpNum);
|
|
|
|
+ // 赋值设备map
|
|
|
|
+ instance.setMachineMap(machineMap);
|
|
|
|
+ // 创造零件map
|
|
|
|
+ instance.setPartMap(partMap);
|
|
|
|
+ // 创造工序map
|
|
|
|
+ instance.setOperationMap(operationMap);
|
|
|
|
+ // 创造工序可选设备集合map
|
|
|
|
+ instance.setCandidateProMap(candidateProMap);
|
|
|
|
+
|
|
|
|
+ GAScheduler gaScheduler = new GAScheduler(instance, GAScheduler.PRIORITY_CODE);
|
|
|
|
+ try{
|
|
|
|
+ gaScheduler.schedule();
|
|
|
|
+ }catch(Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ // 更新task表人工序任务的预计开始时间及结束时间
|
|
|
|
+ Iterator<Map.Entry<String, TTask>> it = instance.getOperationMap().entrySet().iterator();
|
|
|
|
+ ArrayList<TTask> taskList = new ArrayList<>();
|
|
|
|
+ while(it.hasNext()){
|
|
|
|
+ TTask task = it.next().getValue();
|
|
|
|
+ List<BomProcedureProductionresource> procedureProductionresourceList = procedureProductionresourceMapper.selectList(Wraps.<BomProcedureProductionresource>lbQ().eq(BomProcedureProductionresource::getProcedureId,task.getProcedureId())
|
|
|
|
+ .eq(BomProcedureProductionresource::getResourceId,task.getMachineId()).orderByDesc(BomProcedureProductionresource::getCreateTime));
|
|
|
|
+ task.setExpectStartTime(new Date(task.getStart()));
|
|
|
|
+ task.setExpectEndTime(new Date(task.getFinish()));
|
|
|
|
+ task.setResourceId(task.getMachineId());
|
|
|
|
+ task.setExecutorId(task.getMachineId());
|
|
|
|
+ if(CollectionUtil.isNotEmpty(procedureProductionresourceList)){
|
|
|
|
+ task.setResourceBusinessId(procedureProductionresourceList.get(0).getResourceBusinessId());
|
|
|
|
+ }
|
|
|
|
+ taskList.add(task);
|
|
|
|
+ }
|
|
|
|
+ taskService.updateBatchById(taskList);
|
|
|
|
|
|
// 默认只有一键生产过后的订单可以暂停和启用,未一键生产过的订单无需暂停和启用,启用是找出所有的所有未加工的工件重新排序
|
|
// 默认只有一键生产过后的订单可以暂停和启用,未一键生产过的订单无需暂停和启用,启用是找出所有的所有未加工的工件重新排序
|
|
model.setProduceStatus("2");
|
|
model.setProduceStatus("2");
|
|
@@ -920,7 +940,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
// 删除工件信息
|
|
// 删除工件信息
|
|
workpieceMapper.delete(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getPlanId,model.getId()));
|
|
workpieceMapper.delete(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getPlanId,model.getId()));
|
|
// 删除任务信息
|
|
// 删除任务信息
|
|
- taskMapper.delete(Wraps.<TTask>lbQ().eq(TTask::getPlanId,model.getId()));
|
|
|
|
|
|
+ taskService.remove(Wraps.<TTask>lbQ().eq(TTask::getPlanId,model.getId()));
|
|
return true;
|
|
return true;
|
|
|
|
|
|
}
|
|
}
|