|
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
@@ -17,7 +16,6 @@ import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
-import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.bom.po.BomDetail;
|
|
|
import com.fjhx.mes.entity.bom.po.BomInfo;
|
|
@@ -41,15 +39,11 @@ import com.fjhx.mes.service.production.ProductionTaskService;
|
|
|
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.sale.entity.contract.po.ContractProduct;
|
|
|
-import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
import com.fjhx.socket.core.PushTypeEnum;
|
|
|
import com.fjhx.socket.core.WebSocketPush;
|
|
|
import com.fjhx.wms.entity.stock.emums.StockWaitType;
|
|
|
import com.fjhx.wms.entity.stock.po.StockWait;
|
|
|
import com.fjhx.wms.entity.stock.po.StockWaitDetails;
|
|
|
-import com.fjhx.wms.service.stock.StockFrozenService;
|
|
|
import com.fjhx.wms.service.stock.StockService;
|
|
|
import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
@@ -84,9 +78,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
private ProductInfoService productInfoService;
|
|
|
@Autowired
|
|
|
private ProductionPlanService productionPlanService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ContractProductService contractProductService;
|
|
|
@Autowired
|
|
|
private BomInfoService bomInfoService;
|
|
|
@Autowired
|
|
@@ -94,8 +85,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
@Autowired
|
|
|
private StockService stockService;
|
|
|
@Autowired
|
|
|
- private StockFrozenService stockFrozenService;
|
|
|
- @Autowired
|
|
|
private ProductionTaskService productionTaskService;
|
|
|
@Autowired
|
|
|
private ProductionTaskDetailService productionTaskDetailService;
|
|
@@ -131,7 +120,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
//过滤待排程(待创建计划的工单)
|
|
|
if (Objects.equals(dto.getIsRemaining(), 1)) {
|
|
|
//研发必须提交后
|
|
|
- wrapper.eq("wo",WorkOrder::getResearchStatus,1);
|
|
|
+ wrapper.eq("wo", WorkOrder::getResearchStatus, 1);
|
|
|
|
|
|
wrapper.gt("wo.remainingQuantity", 0);
|
|
|
//过滤非定制/定制但已经重新配置了bom和工艺的工单
|
|
@@ -167,7 +156,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
|
|
|
@Override
|
|
|
public WorkOrderVo detail(Long id) {
|
|
|
- WorkOrderVo result = baseMapper.detail(IWrapper.<WorkOrder>getWrapper().eq("wo",WorkOrder::getId, id));
|
|
|
+ WorkOrderVo result = baseMapper.detail(IWrapper.<WorkOrder>getWrapper().eq("wo", WorkOrder::getId, id));
|
|
|
List<ProductionPlan> list = productionPlanService.list(q -> q.eq(ProductionPlan::getWorkOrderId, id));
|
|
|
result.setProductionPlans(list);
|
|
|
ProductInfo productInfo = productInfoService.getById(result.getProductId());
|
|
@@ -184,7 +173,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
|
|
|
//赋值买方信息
|
|
|
Customer customer = customerService.getById(result.getCustomerId());
|
|
|
- if(ObjectUtil.isNotEmpty(customer)) {
|
|
|
+ if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
//赋值客户国省市名称
|
|
|
Map<Long, String> areaMapByIds = CustomizeAreaUtil.getAreaMapByIds(Arrays.asList(
|
|
|
customer.getCountryId(),
|
|
@@ -209,47 +198,11 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
|
|
|
//生成工单编号,以及设置默认状态
|
|
|
// workOrderDto.setCode(CodeEnum.WORK_ORDER.getCode());
|
|
|
- workOrderDto.setCode(codingRuleService.createCode(CodingRuleEnum.JXST_WORK_ORDER.getKey(),null));
|
|
|
+ workOrderDto.setCode(codingRuleService.createCode(CodingRuleEnum.JXST_WORK_ORDER.getKey(), null));
|
|
|
workOrderDto.setStatus(0);
|
|
|
this.save(workOrderDto);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 批量新增
|
|
|
- *
|
|
|
- * @param workOrder
|
|
|
- */
|
|
|
- @Override
|
|
|
- @DSTransactional
|
|
|
- public void addBatch(List<WorkOrder> workOrder) {
|
|
|
- if (CollectionUtils.isEmpty(workOrder)) {
|
|
|
- throw new ServiceException("提交不能为空");
|
|
|
- }
|
|
|
- List<ContractProduct> upContractProduct = new ArrayList<>();
|
|
|
- for (WorkOrder w : workOrder) {
|
|
|
- //生成工单编号,以及设置默认状态
|
|
|
- w.setCode(CodeEnum.WORK_ORDER.getCode());
|
|
|
- w.setStatus(0);
|
|
|
- if (ObjectUtil.isNotEmpty(w.getSourceId()) && "1".equals(w.getSource())) {//外销合同生产数据
|
|
|
- ContractProduct contractProduct = contractProductService.getById(w.getSourceId());
|
|
|
- if (ObjectUtil.isEmpty(contractProduct)) {
|
|
|
- throw new ServiceException("该合同产品不存在,请检查");
|
|
|
- }
|
|
|
- BigDecimal expendQuantity = contractProduct.getExpendQuantity().subtract(w.getQuantity());
|
|
|
- if (expendQuantity.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- //外销合同-交接单转生产 如果转生产数量大于大于合同数量 将待处理数量改为0
|
|
|
- expendQuantity = BigDecimal.ZERO;
|
|
|
- }
|
|
|
- contractProduct.setExpendQuantity(expendQuantity);
|
|
|
- upContractProduct.add(contractProduct);
|
|
|
- }
|
|
|
- }
|
|
|
- this.saveBatch(workOrder);
|
|
|
- if (CollectionUtils.isNotEmpty(upContractProduct)) {//扣减销售合同数量
|
|
|
- contractProductService.updateBatchById(upContractProduct);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void edit(WorkOrderDto workOrderDto) {
|
|
|
this.updateById(workOrderDto);
|
|
@@ -269,11 +222,11 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
workOrderVo.setCompletionRate(BigDecimal.ZERO);
|
|
|
|
|
|
//人工生产数量为0 完工率 100
|
|
|
- if(ObjectUtil.isNotEmpty(workOrderVo.getProductionQuantity()) && workOrderVo.getProductionQuantity().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ if (ObjectUtil.isNotEmpty(workOrderVo.getProductionQuantity()) && workOrderVo.getProductionQuantity().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
workOrderVo.setCompletionRate(BigDecimal.valueOf(100));
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtil.isNotEmpty(workOrderVo.getProductionQuantity()) && workOrderVo.getProductionQuantity().compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ if (ObjectUtil.isNotEmpty(workOrderVo.getProductionQuantity()) && workOrderVo.getProductionQuantity().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
//赋值已计划数量
|
|
|
workOrderVo.setArrangedQuantity(workOrderVo.getProductionQuantity().subtract(workOrderVo.getRemainingQuantity()));
|
|
|
//赋值完成率
|
|
@@ -354,9 +307,9 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
public void distribute(WorkOrderDto dto) {
|
|
|
- Assert.notEmpty(dto.getId(),"工单Id不能为空");
|
|
|
- Assert.notEmpty(dto.getProductionQuantity(),"待生产数量不能为空");
|
|
|
- Assert.notEmpty(dto.getStockWaitQuantity(),"待出库数量不能为空");
|
|
|
+ Assert.notEmpty(dto.getId(), "工单Id不能为空");
|
|
|
+ Assert.notEmpty(dto.getProductionQuantity(), "待生产数量不能为空");
|
|
|
+ Assert.notEmpty(dto.getStockWaitQuantity(), "待出库数量不能为空");
|
|
|
|
|
|
WorkOrder workOrder = this.getById(dto.getId());
|
|
|
Assert.notEmpty(workOrder, "查询不到该工单的信息");
|
|
@@ -484,13 +437,13 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
* 研发上传附件
|
|
|
*/
|
|
|
@Override
|
|
|
- public void research(WorkOrderDto dto){
|
|
|
+ public void research(WorkOrderDto dto) {
|
|
|
WorkOrder workOrder = this.getById(dto.getId());
|
|
|
- Assert.notEmpty(workOrder,"查询不到工单信息!");
|
|
|
+ Assert.notEmpty(workOrder, "查询不到工单信息!");
|
|
|
//修改研发状态
|
|
|
this.update(q -> q
|
|
|
.eq(WorkOrder::getId, dto.getId())
|
|
|
- .set(ObjectUtil.isNotEmpty(dto.getResearchStatus()),WorkOrder::getResearchStatus, dto.getResearchStatus())
|
|
|
+ .set(ObjectUtil.isNotEmpty(dto.getResearchStatus()), WorkOrder::getResearchStatus, dto.getResearchStatus())
|
|
|
.set(BasePo::getUpdateTime, new Date())
|
|
|
.set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
);
|
|
@@ -498,14 +451,14 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
ObsFileUtil.editFile(dto.getFileList(), dto.getId());
|
|
|
|
|
|
//发消息
|
|
|
- if(workOrder.getResearchStatus()==0&&dto.getResearchStatus()==1){
|
|
|
- if("1".equals(workOrder.getIsCustomized())){
|
|
|
+ if (workOrder.getResearchStatus() == 0 && dto.getResearchStatus() == 1) {
|
|
|
+ if ("1".equals(workOrder.getIsCustomized())) {
|
|
|
//定制工单 推送消息给工单配置的负责人
|
|
|
DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
List<Long> userIds = userService.getUserIdsByRoleKey("design");
|
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
WebSocketPush.byUsers(PushTypeEnum.MESSAGE, userIds, "您有新的定制工单待配置!", PushBusinessTypeEnum.NEW_WORK_ORDER.getType());
|
|
|
- }else if("0".equals(workOrder.getIsCustomized())) {
|
|
|
+ } else if ("0".equals(workOrder.getIsCustomized())) {
|
|
|
//非定制工单 推送消息给生产计划下发的负责人
|
|
|
sendPlanInfo();
|
|
|
}
|