|
|
|
|
@ -172,9 +172,11 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
if(plan.getProductId()==null && plan.getTaskDetailId()!=null){
|
|
|
|
|
TaskDetailDO taskDetailDO = taskService.getTaskDetail(plan.getTaskDetailId());
|
|
|
|
|
plan.setProductId(taskDetailDO.getProductId());
|
|
|
|
|
plan.setProductNameSnapshot(taskDetailDO.getProductNameSnapshot());
|
|
|
|
|
}
|
|
|
|
|
if (plan.getIsEnable() == null) plan.setIsEnable(true);
|
|
|
|
|
if(plan.getPriorityNum()==null) plan.setPriorityNum(1L);
|
|
|
|
|
fillProductNameSnapshot(plan);
|
|
|
|
|
fillProcessRouteSnapshot(plan);
|
|
|
|
|
// if (createReqVO.getIsCalculateLoss() == null) {
|
|
|
|
|
// createReqVO.setIsCalculateLoss(true);
|
|
|
|
|
@ -369,6 +371,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
public void updatePlan(PlanSaveReqVO updateReqVO) {
|
|
|
|
|
// 校验存在
|
|
|
|
|
validatePlanExists(updateReqVO.getId());
|
|
|
|
|
PlanDO oldPlan = planMapper.selectById(updateReqVO.getId());
|
|
|
|
|
// 更新
|
|
|
|
|
PlanDO updateObj = BeanUtils.toBean(updateReqVO, PlanDO.class);
|
|
|
|
|
if (updateObj.getIsEnable() == null) updateObj.setIsEnable(true);
|
|
|
|
|
@ -376,14 +379,36 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
TaskDetailDO taskDetailDO = taskService.getTaskDetail(updateObj.getTaskDetailId());
|
|
|
|
|
updateObj.setProductId(taskDetailDO.getProductId());
|
|
|
|
|
}
|
|
|
|
|
fillProcessRouteSnapshot(updateObj);
|
|
|
|
|
fillProductNameSnapshot(updateObj);
|
|
|
|
|
if (updateReqVO.getProcessRouteId() == null) {
|
|
|
|
|
updateObj.setProcessRouteId(oldPlan.getProcessRouteId());
|
|
|
|
|
updateObj.setProcessRouteName(oldPlan.getProcessRouteName());
|
|
|
|
|
} else {
|
|
|
|
|
fillProcessRouteSnapshot(updateObj);
|
|
|
|
|
}
|
|
|
|
|
planMapper.updateById(updateObj);
|
|
|
|
|
if (updateReqVO.getProcessRouteItems() != null || updateReqVO.getProcessRouteId() != null) {
|
|
|
|
|
if (updateReqVO.getProcessRouteItems() != null) {
|
|
|
|
|
planProcessRouteItemMapper.deleteByPlanId(updateReqVO.getId());
|
|
|
|
|
savePlanProcessRouteItems(updateReqVO.getId(), updateObj.getProcessRouteId(), updateReqVO.getProcessRouteItems());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateReportNumbers(Long id, Long wangongNumber, Long passNumber, Long noPassNumber, BigDecimal passRate) {
|
|
|
|
|
validatePlanExists(id);
|
|
|
|
|
planMapper.updateReportNumbers(id, wangongNumber, passNumber, noPassNumber, passRate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillProductNameSnapshot(PlanDO plan) {
|
|
|
|
|
if (plan == null || plan.getProductId() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ErpProductDO product = productService.getProduct(plan.getProductId());
|
|
|
|
|
if (product != null) {
|
|
|
|
|
plan.setProductNameSnapshot(product.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillProcessRouteSnapshot(PlanDO plan) {
|
|
|
|
|
if (plan.getProcessRouteId() == null) {
|
|
|
|
|
plan.setProcessRouteName(null);
|
|
|
|
|
@ -435,12 +460,15 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
public PlanRespVO getPlanRespVO(PlanDO planDO) {
|
|
|
|
|
PlanRespVO planRespVO = BeanUtils.toBean(planDO, PlanRespVO.class);
|
|
|
|
|
|
|
|
|
|
planRespVO.setProductName(planDO.getProductNameSnapshot());
|
|
|
|
|
if (planDO.getProductId() != null) {
|
|
|
|
|
ErpProductDO product = productService.getProduct(planDO.getProductId());
|
|
|
|
|
planRespVO.setProductName(product == null ? null : product.getName());
|
|
|
|
|
if (StringUtils.isBlank(planRespVO.getProductName())) {
|
|
|
|
|
planRespVO.setProductName(product == null ? null : product.getName());
|
|
|
|
|
}
|
|
|
|
|
planRespVO.setProductCode(product == null ? null : product.getBarCode());
|
|
|
|
|
} else {
|
|
|
|
|
planRespVO.setProductName(null);
|
|
|
|
|
planRespVO.setProductName(planDO.getProductNameSnapshot());
|
|
|
|
|
planRespVO.setProductCode(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -573,7 +601,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
item.setProductName(StringUtils.isNotBlank(product.getBarCode())
|
|
|
|
|
? "【" + product.getBarCode() + "】" + product.getName()
|
|
|
|
|
: product.getName());
|
|
|
|
|
} else if (item.getProductId() != null) {
|
|
|
|
|
} else if (item.getProductId() != null && StringUtils.isBlank(item.getProductName())) {
|
|
|
|
|
item.setProductName("产品[" + item.getProductId() + "]");
|
|
|
|
|
}
|
|
|
|
|
item.setPassRate(calculatePassRate(item.getPassNumber(), item.getWangongNumber()));
|
|
|
|
|
@ -637,7 +665,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
PlanTaskPageRespVO respVO = new PlanTaskPageRespVO();
|
|
|
|
|
respVO.setId(plan.getId());
|
|
|
|
|
ErpProductDO product = productMap.get(plan.getProductId());
|
|
|
|
|
respVO.setProductName(product != null ? product.getName() : null);
|
|
|
|
|
respVO.setProductName(StringUtils.defaultIfBlank(plan.getProductNameSnapshot(), product != null ? product.getName() : null));
|
|
|
|
|
DeviceLedgerDO device = deviceMap.get(plan.getDeviceId());
|
|
|
|
|
respVO.setDeviceName(device != null ? device.getDeviceName() : null);
|
|
|
|
|
respVO.setPlanNumber(plan.getPlanNumber());
|
|
|
|
|
@ -671,6 +699,9 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
list = buildProgress(list);
|
|
|
|
|
Map<Long, ErpProductDO> map = productService.getProductMap(
|
|
|
|
|
convertSet(list, PlanDO::getProductId));
|
|
|
|
|
Map<Long, String> productNameSnapshotMap = list.stream()
|
|
|
|
|
.filter(item -> item.getId() != null && StringUtils.isNotBlank(item.getProductNameSnapshot()))
|
|
|
|
|
.collect(Collectors.toMap(PlanDO::getId, PlanDO::getProductNameSnapshot, (a, b) -> a));
|
|
|
|
|
Map<Long, AdminUserDO> userMap = userService.getUserMap(
|
|
|
|
|
convertSet(list, PlanDO::getProductionManagerId));
|
|
|
|
|
Map<Long, TaskDO> taskMap = taskService.getMap(
|
|
|
|
|
@ -678,8 +709,12 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
Map<Long, OrganizationDO> organizationMap = organizationService.getMap(
|
|
|
|
|
convertSet(list, PlanDO::getFeedingPipeline));
|
|
|
|
|
List<PlanRespVO> respList = BeanUtils.toBean(list, PlanRespVO.class, item -> {
|
|
|
|
|
MapUtils.findAndThen(map, item.getProductId(),
|
|
|
|
|
product -> item.setProductName(product.getName()));
|
|
|
|
|
item.setProductName(StringUtils.defaultIfBlank(productNameSnapshotMap.get(item.getId()), item.getProductName()));
|
|
|
|
|
MapUtils.findAndThen(map, item.getProductId(), product -> {
|
|
|
|
|
if (StringUtils.isBlank(item.getProductName())) {
|
|
|
|
|
item.setProductName(product.getName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MapUtils.findAndThen(userMap, item.getProductionManagerId(),
|
|
|
|
|
unit -> item.setProductionManager(unit.getNickname()));
|
|
|
|
|
@ -911,7 +946,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
item.setLatestStartTime(plan.getLatestStartTime()); // 前提:PlanDO已加该字段
|
|
|
|
|
item.setPlanNumber(plan.getPlanNumber());
|
|
|
|
|
ErpProductDO product = productMap.get(plan.getProductId());
|
|
|
|
|
item.setProductName(product == null ? null : product.getName());
|
|
|
|
|
item.setProductName(StringUtils.defaultIfBlank(plan.getProductNameSnapshot(), product == null ? null : product.getName()));
|
|
|
|
|
item.setDeviceName(device == null ? null : device.getDeviceName());
|
|
|
|
|
item.setProductCode(product == null ? null : product.getBarCode());
|
|
|
|
|
item.setDeviceCode(device == null ? null : device.getDeviceCode());
|
|
|
|
|
|