liweidong-hj 4 weeks ago
commit cde530beb1
  1. 12
      blade-service/blade-desk/src/main/java/org/springblade/desk/logistics/mapper/OrderBindMapper.xml
  2. 9
      blade-service/blade-desk/src/main/java/org/springblade/desk/logistics/mapper/TaskMapper.xml
  3. 57
      blade-service/blade-scheduling/src/main/java/org/springblade/scheduling/scheduling/service/impl/WorkOrderServiceImpl.java

@ -8,15 +8,15 @@
SELECT O.*, SELECT O.*,
Y.CARD_NO AS cardNo Y.CARD_NO AS cardNo
FROM LM_ORDER_BIND O FROM LM_ORDER_BIND O
left join MES_YIELD_ORDER Y LEFT JOIN MES_YIELD_ORDER Y ON O.ORDER_ID = Y.ID
on O.ORDER_ID=Y.ID WHERE O.IS_DELETED = 0
WHERE O.IS_DELETED = 0 <!-- 关键修复:添加 l. 表别名 --> <!-- 修复1:Oracle 用 || 替代多参数 CONCAT -->
<!-- 以下筛选条件保持不变 -->
<if test="orderBindDto.boxBarcode != null and orderBindDto.boxBarcode != ''"> <if test="orderBindDto.boxBarcode != null and orderBindDto.boxBarcode != ''">
AND O.BOX_BARCODE LIKE CONCAT('%', #{orderBindDto.boxBarcode}, '%') AND O.BOX_BARCODE LIKE '%' || #{orderBindDto.boxBarcode} || '%'
</if> </if>
<!-- 修复2:参数引用错误,补充 orderBindDto. 前缀 -->
<if test="orderBindDto.bindingStatus != null and orderBindDto.bindingStatus != ''"> <if test="orderBindDto.bindingStatus != null and orderBindDto.bindingStatus != ''">
AND O.BINDING_STATUS = #{bindingStatus.bindingStatus} AND O.BINDING_STATUS = #{orderBindDto.bindingStatus}
</if> </if>
<if test="orderBindDto.startTime != null and orderBindDto.startTime != ''"> <if test="orderBindDto.startTime != null and orderBindDto.startTime != ''">
AND O.CREATE_TIME &gt;= #{orderBindDto.startTime} AND O.CREATE_TIME &gt;= #{orderBindDto.startTime}

@ -17,12 +17,11 @@
SELECT l.*, SELECT l.*,
b.WC_NAME AS wcName b.WC_NAME AS wcName
FROM LM_TASK l FROM LM_TASK l
left join BS_WORK_CENTER b LEFT JOIN BS_WORK_CENTER b ON l.WC_ID = b.ID
on l.WC_ID = b.ID WHERE l.IS_DELETED = 0 <!-- 注释笔误修正:此处l.原本就正确,无需额外添加 -->
WHERE l.IS_DELETED = 0 <!-- 关键修复:添加 l. 表别名 --> <!-- 核心修复:Oracle 用 || 替代多参数 CONCAT -->
<!-- 以下筛选条件保持不变 -->
<if test="taskDto.boxBarcode != null and taskDto.boxBarcode != ''"> <if test="taskDto.boxBarcode != null and taskDto.boxBarcode != ''">
AND l.BOX_BARCODE LIKE CONCAT('%', #{taskDto.boxBarcode}, '%') AND l.BOX_BARCODE LIKE '%' || #{taskDto.boxBarcode} || '%'
</if> </if>
<if test="taskDto.wcId != null and taskDto.wcId != ''"> <if test="taskDto.wcId != null and taskDto.wcId != ''">
AND l.WC_ID = #{taskDto.wcId} AND l.WC_ID = #{taskDto.wcId}

@ -674,7 +674,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
equipWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod()); equipWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod());
equipWrapper.ne(BaseEntity::getId,equipResource.getId()); equipWrapper.ne(BaseEntity::getId,equipResource.getId());
List<EquipResourceEntity> otherResourceList = equipResourceService.list(equipWrapper); List<EquipResourceEntity> otherResourceList = equipResourceService.list(equipWrapper);
BigDecimal rate = equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(), 2, RoundingMode.HALF_UP); BigDecimal rate = equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(), 4, RoundingMode.HALF_UP);
for(EquipResourceEntity otherResource : otherResourceList){ for(EquipResourceEntity otherResource : otherResourceList){
otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR)); otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR));
otherResource.setIsUsed("1"); otherResource.setIsUsed("1");
@ -881,10 +881,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
workOrderList.add(workOrder); workOrderList.add(workOrder);
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_3.getCode()){ if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_3.getCode()){
StGlassCakeOutDTO glassDto = new StGlassCakeOutDTO(); StGlassCakeOutDTO glassDto = new StGlassCakeOutDTO();
glassDto.setPrintMark("1".equals(part.getIsPrint()) ? false : true); glassDto.setCardNo(workOrder.getCardNo());
glassDto.setPowderWeight(part.getPowderWeight().toString()); glassDto.setWoCode(workOrder.getWoCode());
glassDto.setMaterialNo(part.getMaterial());
glassDto.setThickness(part.getFormingThickness().toString());
glassCakeOutList.add(glassDto); glassCakeOutList.add(glassDto);
} }
@ -1100,15 +1098,15 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
public void checkSchedulingOrder(List<YieldOrderEntity> list) { public void checkSchedulingOrder(List<YieldOrderEntity> list) {
//判断待排产优先级,1级所有1级往后订单重新排产,2级订单重新排4/5级订单 //判断待排产优先级,1级所有1级往后订单重新排产,2级订单重新排4/5级订单
List<Integer> priorityList = list.stream().map(YieldOrderEntity::getPriorityAps).collect(Collectors.toList()); List<Integer> priorityList = list.stream().map(YieldOrderEntity::getPriorityAps).collect(Collectors.toList());
if (priorityList.contains(1)) { if (priorityList.contains(YieldOrderEnum.PRIORITY_APS_CRITICAL.getCode())) {
//查询所有非一级的待生产订单 //查询所有非一级的待生产订单
List<YieldOrderEntity> schedulingOrderList = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().ne(YieldOrderEntity::getPriorityAps, 1).eq(YieldOrderEntity::getStatus, 4)); List<YieldOrderEntity> schedulingOrderList = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().ne(YieldOrderEntity::getPriorityAps, 1).in(BaseEntity::getStatus, YieldOrderEnum.STATUS_APS.getCode(),YieldOrderEnum.STATUS_PROCESS_WAITING.getCode()));
//校验已排产订单资源占用情况 //校验已排产订单资源占用情况
checkResource(schedulingOrderList); checkResource(schedulingOrderList);
} }
if (priorityList.contains(2)) { if (priorityList.contains(YieldOrderEnum.PRIORITY_APS_HIGH.getCode())) {
//查询4/5级的待生产订单 //查询4/5级的待生产订单
List<YieldOrderEntity> schedulingOrderList = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().in(YieldOrderEntity::getPriorityAps, Arrays.asList("4", "5")).eq(YieldOrderEntity::getStatus, 4)); List<YieldOrderEntity> schedulingOrderList = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().in(YieldOrderEntity::getPriorityAps, Arrays.asList("4", "5")).in(BaseEntity::getStatus, YieldOrderEnum.STATUS_APS.getCode(),YieldOrderEnum.STATUS_PROCESS_WAITING.getCode()));
checkResource(schedulingOrderList); checkResource(schedulingOrderList);
} }
} }
@ -1116,9 +1114,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
public void checkResource(List<YieldOrderEntity> list) { public void checkResource(List<YieldOrderEntity> list) {
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
//根据订单查询设备资源 //根据订单查询设备资源
for (YieldOrderEntity yieldOrder : list) { for (YieldOrderEntity order : list) {
BigDecimal sumCapacity = order.getYieldType() == YieldOrderEnum.YIELD_TYPE_1.getCode() ? order.getYpArea().multiply(BigDecimal.valueOf(order.getYpQty())) : BigDecimal.valueOf(order.getYpQty());
//查询相关车间订单 //查询相关车间订单
WorkOrderEntity workOrder = this.getOne(Wrappers.<WorkOrderEntity>lambdaQuery().eq(WorkOrderEntity::getYoId, yieldOrder.getId())); WorkOrderEntity workOrder = this.getOne(Wrappers.<WorkOrderEntity>lambdaQuery().eq(WorkOrderEntity::getYoId, order.getId()));
if (workOrder != null) { if (workOrder != null) {
List<WorkPlanEntity> schedulingPlanList = workPlanService.list(Wrappers.<WorkPlanEntity>lambdaQuery().eq(WorkPlanEntity::getWoId, workOrder.getId())); List<WorkPlanEntity> schedulingPlanList = workPlanService.list(Wrappers.<WorkPlanEntity>lambdaQuery().eq(WorkPlanEntity::getWoId, workOrder.getId()));
if (CollectionUtils.isNotEmpty(schedulingPlanList)) { if (CollectionUtils.isNotEmpty(schedulingPlanList)) {
@ -1127,12 +1127,30 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
if (workPlan.getEquipResourceId() != null) { if (workPlan.getEquipResourceId() != null) {
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId());
equipResource.setIsUsed("0"); equipResource.setIsUsed("0");
equipResource.setRestCapacity(equipResource.getRestCapacity().add(BigDecimal.valueOf(workPlan.getHourQuota()))); equipResource.setRestCapacity(equipResource.getRestCapacity().add(sumCapacity));
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper<>(); equipResourceService.updateById(equipResource);
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
LambdaQueryWrapper<EquipResourceEntity> equipWrapper = new LambdaQueryWrapper<>();
equipWrapper.eq(EquipResourceEntity::getEquipCode, equipResource.getEquipCode());
equipWrapper.eq(EquipResourceEntity::getDateTime, equipResource.getDateTime());
equipWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod());
equipWrapper.ne(BaseEntity::getId,equipResource.getId());
List<EquipResourceEntity> otherResourceList = equipResourceService.list(equipWrapper);
BigDecimal rate = equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(), 4, RoundingMode.HALF_UP);
for(EquipResourceEntity otherResource : otherResourceList){
otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR));
otherResource.setIsUsed("0");
otherResource.setGlassCode(null);
equipResourceService.updateById(otherResource);
}
//该设备后续所有开始时间小于当前结束时间的时间段都变为不可用
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper();
updateWrapper.lt(EquipResourceEntity::getStartTime, equipResource.getEndTime());
updateWrapper.gt(EquipResourceEntity::getStartTime, equipResource.getStartTime());
updateWrapper.eq(EquipResourceEntity::getEquipCode, equipResource.getEquipCode()); updateWrapper.eq(EquipResourceEntity::getEquipCode, equipResource.getEquipCode());
updateWrapper.eq(EquipResourceEntity::getDateTime, equipResource.getDateTime()); EquipResourceEntity equipResource1 = new EquipResourceEntity();
updateWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod()); equipResource1.setIsUsed("0");
equipResourceService.update(equipResource, updateWrapper); equipResourceService.update(equipResource1, updateWrapper);
} }
//还原人力资源 //还原人力资源
@ -1153,8 +1171,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
this.deleteLogic(Arrays.asList(workOrder.getId())); this.deleteLogic(Arrays.asList(workOrder.getId()));
} }
yieldOrder.setStatus(YieldOrderEnum.STATUS_APS.getCode()); order.setStatus(YieldOrderEnum.STATUS_APS.getCode());
yieldOrderService.updateById(yieldOrder); yieldOrderService.updateById(order);
} }
} }
@ -1593,11 +1611,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
equipWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod()); equipWrapper.eq(EquipResourceEntity::getPeriod, equipResource.getPeriod());
equipWrapper.ne(BaseEntity::getId,equipResource.getId()); equipWrapper.ne(BaseEntity::getId,equipResource.getId());
List<EquipResourceEntity> otherResourceList = equipResourceService.list(equipWrapper); List<EquipResourceEntity> otherResourceList = equipResourceService.list(equipWrapper);
BigDecimal rate = equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(), 2, RoundingMode.HALF_UP); BigDecimal rate = equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(), 4, RoundingMode.HALF_UP);
for(EquipResourceEntity otherResource : otherResourceList){ for(EquipResourceEntity otherResource : otherResourceList){
otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR)); otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR));
equipResourceService.updateById(otherResource); equipResourceService.updateById(otherResource);
} }
isSameFurnace = true; isSameFurnace = true;
prevProcessEnd = workPlan.getPlanEndTime(); prevProcessEnd = workPlan.getPlanEndTime();
} }

Loading…
Cancel
Save