|
@@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.enums.PushBusinessTypeEnum;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
-import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
@@ -36,7 +35,6 @@ import com.fjhx.mes.service.technology.TechnologyService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderBomService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderProductionProcessesService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderService;
|
|
|
-import com.fjhx.mes.utils.code.CodeEnum;
|
|
|
import com.fjhx.socket.core.PushTypeEnum;
|
|
|
import com.fjhx.socket.core.WebSocketPush;
|
|
|
import com.fjhx.wms.entity.stock.emums.StockWaitType;
|
|
@@ -116,9 +114,9 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
wrapper.orderByDesc("pt", ProductionTask::getId);
|
|
|
if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
wrapper.keyword(dto.getKeyword(),
|
|
|
- new SqlField("pt",ProductionTaskVo::getCode),
|
|
|
- new SqlField("pt",ProductionTaskVo::getQuantity),
|
|
|
- new SqlField("pt",ProductionTaskVo::getDueDate),
|
|
|
+ new SqlField("pt", ProductionTaskVo::getCode),
|
|
|
+ new SqlField("pt", ProductionTaskVo::getQuantity),
|
|
|
+ new SqlField("pt", ProductionTaskVo::getDueDate),
|
|
|
new SqlField("pi.`name`"),
|
|
|
new SqlField("pp.`code`")
|
|
|
);
|
|
@@ -130,7 +128,7 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
UserUtil.assignmentNickName(records, ProductionTask::getPersonLiableId, ProductionTaskVo::setPersonLiableName);
|
|
|
|
|
|
//赋值客户名称
|
|
|
- customerService.attributeAssign(records,ProductionTaskVo::getCustomerId,(item, customer) -> {
|
|
|
+ customerService.attributeAssign(records, ProductionTaskVo::getCustomerId, (item, customer) -> {
|
|
|
item.setCustomerName(customer.getName());
|
|
|
});
|
|
|
return page;
|
|
@@ -160,12 +158,12 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
//检查待排程数量防止并发
|
|
|
List<ProductionTask> productionTaskList = this.list(q -> q.eq(ProductionTask::getProductionPlanId, productionTaskDto.getProductionPlanId()));
|
|
|
BigDecimal taskCount = productionTaskList.stream().map(ProductionTask::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if(taskCount.add(productionTaskDto.getQuantity()).compareTo(productionPlan.getQuantity())>0){
|
|
|
+ if (taskCount.add(productionTaskDto.getQuantity()).compareTo(productionPlan.getQuantity()) > 0) {
|
|
|
throw new ServiceException("任务数量大于计划数量,请检查!");
|
|
|
}
|
|
|
|
|
|
// productionTaskDto.setCode(CodeEnum.PRODUCTION_TASK.getCode());
|
|
|
- productionTaskDto.setCode(codingRuleService.createCode(CodingRuleEnum.JXST_PRODUCTION_TASK.getKey(),null));
|
|
|
+ productionTaskDto.setCode(codingRuleService.createCode(CodingRuleEnum.JXST_PRODUCTION_TASK.getKey(), null));
|
|
|
this.save(productionTaskDto);
|
|
|
//更新生产计划状态为进行中
|
|
|
productionPlan.setStatus(1);
|
|
@@ -223,6 +221,9 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
//根据BOM明细冻结库存
|
|
|
List<Long> productIds = bomDetailList.stream().map(BomDetail::getProductId).collect(Collectors.toList());
|
|
|
Map<Long, List<Stock>> productMap = stockService.mapKGroup(Stock::getProductId, q -> q.in(Stock::getProductId, productIds));
|
|
|
+ Map<Long, ProductInfo> productInfoMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q
|
|
|
+ .in(ObjectUtil.isNotEmpty(productIds), ProductInfo::getId, productIds)
|
|
|
+ );
|
|
|
List<StockFrozen> stockFrozenList = new ArrayList<>();
|
|
|
for (BomDetail bomDetail : bomDetailList) {
|
|
|
Long productId = bomDetail.getProductId();
|
|
@@ -231,7 +232,8 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
//添加冻结库存
|
|
|
List<Stock> stocks = productMap.get(productId);
|
|
|
if (ObjectUtil.isEmpty(stocks)) {
|
|
|
- throw new ServiceException("物料库存不存在");
|
|
|
+ ProductInfo productInfo = productInfoMap.get(productId);
|
|
|
+ throw new ServiceException(String.format("物料%s(%s)库存不足!", productInfo.getName(), productInfo.getSpec()));
|
|
|
}
|
|
|
//计算库存是否充足(可用库存 - 冻结库存 - 所需的数量)是否大等于0
|
|
|
BigDecimal quantity = stocks.stream().map(Stock::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
@@ -244,7 +246,8 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
}
|
|
|
BigDecimal subtract = quantity.subtract(stockFrozen.getFrozenQuantity()).subtract(multiply);
|
|
|
if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- throw new ServiceException("物料库存不足");
|
|
|
+ ProductInfo productInfo = productInfoMap.get(productId);
|
|
|
+ throw new ServiceException(String.format("物料%s(%s)库存不足!", productInfo.getName(), productInfo.getSpec()));
|
|
|
}
|
|
|
//存在库存
|
|
|
BigDecimal add = stockFrozen.getFrozenQuantity().add(multiply);
|
|
@@ -373,7 +376,7 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
//推送消息给第一个工序的用户有单可以抢了
|
|
|
WorkOrderProductionProcesses workOrderProductionProcesses = productionProcessesList.get(0);
|
|
|
List<Long> userIds = taskProcessesUserJson.getList(workOrderProductionProcesses.getId().toString(), Long.class);
|
|
|
- WebSocketPush.byUsers(PushTypeEnum.MESSAGE,userIds,"您有新的任务可接收!", PushBusinessTypeEnum.NEW_TASK.getType());
|
|
|
+ WebSocketPush.byUsers(PushTypeEnum.MESSAGE, userIds, "您有新的任务可接收!", PushBusinessTypeEnum.NEW_TASK.getType());
|
|
|
}
|
|
|
|
|
|
@Override
|