|
|
|
@ -30,8 +30,10 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springblade.common.constant.YieldOrderConst; |
|
|
|
import org.springblade.common.constant.YieldOrderConst; |
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
@ -67,6 +69,7 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrderEntity> implements IWorkOrderService { |
|
|
|
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrderEntity> implements IWorkOrderService { |
|
|
|
|
|
|
|
|
|
|
|
private final IYieldOrderService yieldOrderService; |
|
|
|
private final IYieldOrderService yieldOrderService; |
|
|
|
@ -110,11 +113,12 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void scheduling() { |
|
|
|
public void scheduling() { |
|
|
|
//查询待排产订单,状态是3
|
|
|
|
//查询待排产订单,状态是3
|
|
|
|
List<YieldOrderEntity> list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS)); |
|
|
|
List<YieldOrderEntity> list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS).isNotNull(YieldOrderEntity::getWorkCenterId).isNotNull(YieldOrderEntity::getReleaseDate)); |
|
|
|
|
|
|
|
log.info("待排产订单数量为:" + list.size()); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
//校验已排产订单
|
|
|
|
//校验已排产订单
|
|
|
|
checkSchedulingOrder(list); |
|
|
|
checkSchedulingOrder(list); |
|
|
|
list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS)); |
|
|
|
list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS).isNotNull(YieldOrderEntity::getWorkCenterId).isNotNull(YieldOrderEntity::getReleaseDate)); |
|
|
|
//初始化人员能力
|
|
|
|
//初始化人员能力
|
|
|
|
List<PersonAbilityEntity> personAbilityEntityList = personAbilityService.list(Wrappers.<PersonAbilityEntity>lambdaQuery().isNotNull(PersonAbilityEntity::getWorkCenterId).isNotNull(PersonAbilityEntity::getProcessId).isNotNull(PersonAbilityEntity::getCraftId)); |
|
|
|
List<PersonAbilityEntity> personAbilityEntityList = personAbilityService.list(Wrappers.<PersonAbilityEntity>lambdaQuery().isNotNull(PersonAbilityEntity::getWorkCenterId).isNotNull(PersonAbilityEntity::getProcessId).isNotNull(PersonAbilityEntity::getCraftId)); |
|
|
|
Map<String, PersonAbilityEntity> personAbilityMap = new HashMap<>(); |
|
|
|
Map<String, PersonAbilityEntity> personAbilityMap = new HashMap<>(); |
|
|
|
@ -140,7 +144,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
list1 -> { |
|
|
|
list1 -> { |
|
|
|
// 排序逻辑:优先级升序 → CR值降序 → 数量降序 → 时间升序
|
|
|
|
// 排序逻辑:优先级升序 → CR值降序 → 数量降序 → 时间升序
|
|
|
|
list1.sort(Comparator.comparingInt(YieldOrderEntity::getPriorityAps).reversed() |
|
|
|
list1.sort(Comparator.comparingInt(YieldOrderEntity::getPriorityAps).reversed() |
|
|
|
//.thenComparing((e1, e2) -> e2.getCrValue().compareTo(e1.getCrValue()))
|
|
|
|
.thenComparing((e1, e2) -> e2.getCrValue().compareTo(e1.getCrValue())) |
|
|
|
.thenComparingInt(YieldOrderEntity::getYpQty).reversed() |
|
|
|
.thenComparingInt(YieldOrderEntity::getYpQty).reversed() |
|
|
|
.thenComparing(YieldOrderEntity::getReleaseDate)); |
|
|
|
.thenComparing(YieldOrderEntity::getReleaseDate)); |
|
|
|
return list1; |
|
|
|
return list1; |
|
|
|
@ -404,6 +408,31 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<WorkOrderDto> schedulingCount(WorkOrderDto workOrder) { |
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(workOrder.getStartTime())){ |
|
|
|
|
|
|
|
workOrder.setStartTime(workOrder.getStartTime().concat(" 00:00:00")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(workOrder.getEndTime())){ |
|
|
|
|
|
|
|
workOrder.setEndTime(workOrder.getEndTime().concat(" 23:59:59")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WorkOrderDto> list = baseMapper.selectSchedulingCount(workOrder); |
|
|
|
|
|
|
|
list.forEach(item -> { |
|
|
|
|
|
|
|
item.setSchedulingRate(String.format("%.2f", (double)item.getSchedulingCount()/item.getTotalCount()*100)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<String> selectTeam() { |
|
|
|
|
|
|
|
return baseMapper.selectTeam(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<String> selectEquip() { |
|
|
|
|
|
|
|
return baseMapper.selectEquip(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void calculateCr(List<YieldOrderEntity> list) { |
|
|
|
void calculateCr(List<YieldOrderEntity> list) { |
|
|
|
//查询订单下的工序,计算cr值
|
|
|
|
//查询订单下的工序,计算cr值
|
|
|
|
for (YieldOrderEntity entity : list) { |
|
|
|
for (YieldOrderEntity entity : list) { |
|
|
|
@ -439,6 +468,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
public void allocateResources(List<YieldOrderEntity> list,Map<String, PersonAbilityEntity> personAbilityMap,Map<Long, String> mainProducerMap,Map<String,List<WorkPlanEntity>> planMap) { |
|
|
|
public void allocateResources(List<YieldOrderEntity> list,Map<String, PersonAbilityEntity> personAbilityMap,Map<Long, String> mainProducerMap,Map<String,List<WorkPlanEntity>> planMap) { |
|
|
|
List<WorkOrderEntity> workOrderList = new ArrayList<>(); |
|
|
|
List<WorkOrderEntity> workOrderList = new ArrayList<>(); |
|
|
|
for (YieldOrderEntity order : list) { |
|
|
|
for (YieldOrderEntity order : list) { |
|
|
|
|
|
|
|
try { |
|
|
|
//是否可以排产
|
|
|
|
//是否可以排产
|
|
|
|
Boolean isSchecuding = true; |
|
|
|
Boolean isSchecuding = true; |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
@ -481,7 +511,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
List<EquipResourceEntity> equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery().eq(EquipResourceEntity::getCraftId,craft.getCaId()).eq(EquipResourceEntity::getWorkCenterId,craft.getWorkCenterId()).ge(EquipResourceEntity::getStartTime, dateTime).eq(EquipResourceEntity::getIsUsed, 0).in(EquipResourceEntity::getEquipOrder, entry.getKey())); |
|
|
|
List<EquipResourceEntity> equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery().eq(EquipResourceEntity::getCraftId,craft.getCaId()).eq(EquipResourceEntity::getWorkCenterId,craft.getWorkCenterId()).ge(EquipResourceEntity::getStartTime, dateTime).eq(EquipResourceEntity::getIsUsed, 0).in(EquipResourceEntity::getEquipOrder, entry.getKey())); |
|
|
|
if(CollectionUtils.isEmpty(equipResourceList)){ |
|
|
|
if(CollectionUtils.isEmpty(equipResourceList)){ |
|
|
|
order.setStatus(6); |
|
|
|
order.setStatus(6); |
|
|
|
order.setErrorInfo("工序:"+craft+"未匹配到对应的设备资源"); |
|
|
|
order.setErrorInfo("工序:"+craft.getPpsId()+"未匹配到对应的设备资源"); |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
isSchecuding = false; |
|
|
|
isSchecuding = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
@ -505,7 +535,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
) |
|
|
|
) |
|
|
|
)); |
|
|
|
)); |
|
|
|
//计算生产所需产能,需将m2换算成dm2
|
|
|
|
//计算生产所需产能,需将m2换算成dm2
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
//需要判断设备额定生产能力是否满足订单总产能,如果不满足,则需要把总产能进行拆分
|
|
|
|
//需要判断设备额定生产能力是否满足订单总产能,如果不满足,则需要把总产能进行拆分
|
|
|
|
List<BigDecimal> capacityList = capacitySplit(equipResourceMap,sumCapacity); |
|
|
|
List<BigDecimal> capacityList = capacitySplit(equipResourceMap,sumCapacity); |
|
|
|
for(BigDecimal capacity : capacityList){ |
|
|
|
for(BigDecimal capacity : capacityList){ |
|
|
|
@ -552,6 +582,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
|
|
|
|
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> equipWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> equipWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
equipWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
equipWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
|
|
|
|
equipWrapper.eq(EquipResourceEntity::getDateTime,equipResource.getDateTime()); |
|
|
|
|
|
|
|
equipWrapper.eq(EquipResourceEntity::getPeriod,equipResource.getPeriod()); |
|
|
|
|
|
|
|
equipWrapper.eq(EquipResourceEntity::getStartTime,equipResource.getStartTime()); |
|
|
|
|
|
|
|
equipWrapper.eq(EquipResourceEntity::getEndTime,equipResource.getEndTime()); |
|
|
|
equipResourceService.update(equipResource,equipWrapper); |
|
|
|
equipResourceService.update(equipResource,equipWrapper); |
|
|
|
//该设备后续所有开始时间小于当前结束时间的时间段都变为不可用
|
|
|
|
//该设备后续所有开始时间小于当前结束时间的时间段都变为不可用
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper(); |
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper(); |
|
|
|
@ -594,21 +628,35 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
BigDecimal totalTime = new BigDecimal(0); |
|
|
|
BigDecimal totalTime = new BigDecimal(0); |
|
|
|
PersonAbilityEntity ability = personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()); |
|
|
|
PersonAbilityEntity ability = personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()); |
|
|
|
//由于客户提供的数据不全,先判断有没有对应的能力,如果没有先不计算时间
|
|
|
|
//由于客户提供的数据不全,先判断有没有对应的能力,如果没有先不计算时间
|
|
|
|
|
|
|
|
List<Long> ppsIds = Arrays.asList(Long.valueOf(10),Long.valueOf(21)); |
|
|
|
|
|
|
|
//镀后检验和镀后接收先按半小时计算
|
|
|
|
if(ability != null){ |
|
|
|
if(ability != null){ |
|
|
|
|
|
|
|
if(ppsIds.contains(craft.getPpsId())){ |
|
|
|
|
|
|
|
totalTime = BigDecimal.valueOf(30); |
|
|
|
|
|
|
|
workPlan.setStartTime(prevProcessEnd); |
|
|
|
|
|
|
|
workPlan.setEndTime(prevProcessEnd.plusMinutes(30)); |
|
|
|
|
|
|
|
if(craft.getPpsId() == 10){ |
|
|
|
|
|
|
|
workPlan.setMakeTeam(Long.valueOf(64)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(craft.getPpsId() == 21){ |
|
|
|
|
|
|
|
workPlan.setMakeTeam(Long.valueOf(65)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
totalTime = totalTime.add(BigDecimal.valueOf(order.getYpQty()).multiply(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getStandardTime()).add(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getPrepareTime())); |
|
|
|
totalTime = totalTime.add(BigDecimal.valueOf(order.getYpQty()).multiply(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getStandardTime()).add(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getPrepareTime())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(totalTime.compareTo(new BigDecimal(0)) > 0){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过加锁的方式保证每次查询到的人力资源都是最新的
|
|
|
|
//通过加锁的方式保证每次查询到的人力资源都是最新的
|
|
|
|
Long craftId = craft.getCaId(); |
|
|
|
/*Long craftId = craft.getCaId(); |
|
|
|
Lock craftLock = getCraftLock(craftId); |
|
|
|
Lock craftLock = getCraftLock(craftId); |
|
|
|
craftLock.lock(); // 加本地锁,同一工艺ID串行执行
|
|
|
|
craftLock.lock(); // 加本地锁,同一工艺ID串行执行
|
|
|
|
try{ |
|
|
|
try{ |
|
|
|
//查询大于当前时间+半小时的所有人员资源
|
|
|
|
//查询大于当前时间+半小时的所有人员资源
|
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().ge(PersonResourceEntity::getStartTime,prevProcessEnd.plusMinutes(30)).eq(PersonResourceEntity::getCraftId,craft.getCaId()).orderByAsc(PersonResourceEntity::getStartTime).last("for update")); |
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().ge(PersonResourceEntity::getStartTime,prevProcessEnd.plusMinutes(30)).eq(PersonResourceEntity::getCraftId,craft.getCaId()).eq(PersonResourceEntity::getIsUsed,0).orderByAsc(PersonResourceEntity::getStartTime).last("for update")); |
|
|
|
//如果personResourceList不为空,说明是镀后检验或者镀后验收这类跨作业中心的工艺
|
|
|
|
//如果personResourceList不为空,说明是镀后检验或者镀后验收这类跨作业中心的工艺
|
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
//剔除掉personResourceList中isUsed=1之前的数据,isUsed=1说明这些时间被占用了
|
|
|
|
//剔除掉personResourceList中isUsed=1之前的数据,isUsed=1说明这些时间被占用了
|
|
|
|
int isUsedIndex = -1; |
|
|
|
*//* int isUsedIndex = -1;
|
|
|
|
for(int m=0;m<personResourceList.size();m++){ |
|
|
|
for(int m=0;m<personResourceList.size();m++){ |
|
|
|
if("1".equals(personResourceList.get(m).getIsUsed())){ |
|
|
|
if("1".equals(personResourceList.get(m).getIsUsed())){ |
|
|
|
isUsedIndex = m; |
|
|
|
isUsedIndex = m; |
|
|
|
@ -616,16 +664,21 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
if(isUsedIndex != -1){ |
|
|
|
if(isUsedIndex != -1){ |
|
|
|
personResourceList = personResourceList.subList(isUsedIndex + 1, personResourceList.size()); |
|
|
|
personResourceList = personResourceList.subList(isUsedIndex + 1, personResourceList.size()); |
|
|
|
} |
|
|
|
}*//*
|
|
|
|
//如果size=0,说明最近3天的资源都排满了,就不需要排了
|
|
|
|
|
|
|
|
if(personResourceList.size() == 0){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
|
|
|
|
//int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue();
|
|
|
|
|
|
|
|
//1.如果size=0,说明最近3天的资源都排满了,就不需要排了
|
|
|
|
|
|
|
|
if(personResourceList.size() == 0){ |
|
|
|
|
|
|
|
//还原已占用资源
|
|
|
|
|
|
|
|
restoreResource(workPlanList); |
|
|
|
|
|
|
|
order.setErrorInfo("最近3天人力资源已占满,需下次排产"); |
|
|
|
|
|
|
|
yieldOrderService.updateById(order); |
|
|
|
|
|
|
|
isSchecuding = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
|
|
|
|
int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue(); |
|
|
|
|
|
|
|
//占用时间段
|
|
|
|
//占用时间段
|
|
|
|
LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
*//*LocalDateTime startTime = LocalDateTime.now();
|
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
StringBuilder personResourceIds = new StringBuilder(); |
|
|
|
StringBuilder personResourceIds = new StringBuilder(); |
|
|
|
for(int j=0;j<period;j++){ |
|
|
|
for(int j=0;j<period;j++){ |
|
|
|
@ -645,17 +698,20 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
personResourceIds.append(personResource.getId()); |
|
|
|
personResourceIds.append(personResource.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}*//*
|
|
|
|
workPlan.setPersonResourceIds(personResourceIds.toString()); |
|
|
|
PersonResourceEntity personResource = personResourceList.get(0); |
|
|
|
workPlan.setStartTime(startTime); |
|
|
|
personResource.setIsUsed("1"); |
|
|
|
workPlan.setEndTime(endTime); |
|
|
|
personResourceService.updateById(personResource); |
|
|
|
|
|
|
|
workPlan.setPersonResourceIds(personResource.getId().toString()); |
|
|
|
|
|
|
|
workPlan.setStartTime(personResource.getStartTime()); |
|
|
|
|
|
|
|
workPlan.setEndTime(personResource.getEndTime()); |
|
|
|
workPlan.setMakeTeam(personResourceList.get(0).getTeamId()); |
|
|
|
workPlan.setMakeTeam(personResourceList.get(0).getTeamId()); |
|
|
|
|
|
|
|
|
|
|
|
prevProcessEnd = endTime; |
|
|
|
prevProcessEnd = personResource.getEndTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
}finally { |
|
|
|
}finally { |
|
|
|
craftLock.unlock(); // 释放本地锁
|
|
|
|
craftLock.unlock(); // 释放本地锁
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
@ -695,8 +751,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
workOrder.setBatchNo(order.getBatchNo()); |
|
|
|
workOrder.setBatchNo(order.getBatchNo()); |
|
|
|
workOrder.setYoId(order.getId()); |
|
|
|
workOrder.setYoId(order.getId()); |
|
|
|
workOrder.setMakeQty(order.getYpQty()); |
|
|
|
workOrder.setMakeQty(order.getYpQty()); |
|
|
|
workOrder.setPlanStartDate(workPlanList.get(0).getStartTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
workOrder.setPlanStartDate(workPlanList.get(0).getStartTime() == null ? null :workPlanList.get(0).getStartTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
workOrder.setPlanEndDate(workPlanList.get(workPlanList.size()-1).getEndTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
workOrder.setPlanEndDate(workPlanList.get(workPlanList.size()-1).getEndTime() == null ? null : workPlanList.get(workPlanList.size()-1).getEndTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
workOrder.setInventoryQty(0); |
|
|
|
workOrder.setInventoryQty(0); |
|
|
|
workOrder.setRunStatus(2); |
|
|
|
workOrder.setRunStatus(2); |
|
|
|
workOrder.setPickingStatus(0); |
|
|
|
workOrder.setPickingStatus(0); |
|
|
|
@ -721,9 +777,14 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
this.updateById(workOrder); |
|
|
|
this.updateById(workOrder); |
|
|
|
//更新订单状态为已排产
|
|
|
|
//更新订单状态为已排产
|
|
|
|
order.setStatus(4); |
|
|
|
order.setStatus(4); |
|
|
|
|
|
|
|
order.setErrorInfo(null); |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
workOrderList.add(workOrder); |
|
|
|
workOrderList.add(workOrder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("报错订单是:"+order.getId()+",报错信息是:"+e.getMessage()); |
|
|
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtils.isNotEmpty(workOrderList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(workOrderList)){ |
|
|
|
@ -927,11 +988,15 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
equipResource.setIsUsed("0"); |
|
|
|
equipResource.setIsUsed("0"); |
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().add(workPlan.getHourQuota())); |
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().add(workPlan.getHourQuota())); |
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getDateTime,equipResource.getDateTime()); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getPeriod,equipResource.getPeriod()); |
|
|
|
|
|
|
|
equipResourceService.update(equipResource,updateWrapper); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//还原人力资源
|
|
|
|
//还原人力资源
|
|
|
|
if(workPlan.getPersonResourceIds() != null){ |
|
|
|
/*if(workPlan.getPersonResourceIds() != null){ |
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
@ -939,7 +1004,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
personResourceService.updateById(item); |
|
|
|
personResourceService.updateById(item); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1029,6 +1094,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
//获取相关工序
|
|
|
|
//获取相关工序
|
|
|
|
YieldOrderCraftEntity craft = yieldOrderCraftService.getOne(Wrappers.<YieldOrderCraftEntity>lambdaQuery().eq(YieldOrderCraftEntity::getYoId,order.getId()).eq(YieldOrderCraftEntity::getCaId,equipAbility.getCraftId())); |
|
|
|
YieldOrderCraftEntity craft = yieldOrderCraftService.getOne(Wrappers.<YieldOrderCraftEntity>lambdaQuery().eq(YieldOrderCraftEntity::getYoId,order.getId()).eq(YieldOrderCraftEntity::getCaId,equipAbility.getCraftId())); |
|
|
|
|
|
|
|
if(craft == null){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
//计算订单总产能
|
|
|
|
//计算订单总产能
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
//计算需要占用几个时间段
|
|
|
|
//计算需要占用几个时间段
|
|
|
|
@ -1100,4 +1168,35 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
return StringToFix; |
|
|
|
return StringToFix; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void restoreResource(List<WorkPlanEntity> list){ |
|
|
|
|
|
|
|
for(WorkPlanEntity workPlan : list){ |
|
|
|
|
|
|
|
//还原设备资源
|
|
|
|
|
|
|
|
if(workPlan.getEquipResourceId() != null){ |
|
|
|
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
|
|
|
|
equipResource.setIsUsed("0"); |
|
|
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().add(workPlan.getHourQuota())); |
|
|
|
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getDateTime,equipResource.getDateTime()); |
|
|
|
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getPeriod,equipResource.getPeriod()); |
|
|
|
|
|
|
|
equipResourceService.update(equipResource,updateWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//还原人力资源
|
|
|
|
|
|
|
|
if(workPlan.getPersonResourceIds() != null){ |
|
|
|
|
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
|
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
|
|
|
|
item.setIsUsed("0"); |
|
|
|
|
|
|
|
personResourceService.updateById(item); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(workPlan.getId() != null){ |
|
|
|
|
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|