|
@@ -0,0 +1,93 @@
|
|
|
+package com.fjhx.mes.service.work.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
+import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.mes.entity.production.po.ProductionPlan;
|
|
|
+import com.fjhx.mes.entity.work.dto.WorkOrderDto;
|
|
|
+import com.fjhx.mes.entity.work.dto.WorkOrderSelectDto;
|
|
|
+import com.fjhx.mes.entity.work.po.WorkOrder;
|
|
|
+import com.fjhx.mes.entity.work.vo.WorkOrderVo;
|
|
|
+import com.fjhx.mes.mapper.work.WorkOrderMapper;
|
|
|
+import com.fjhx.mes.service.production.ProductionPlanService;
|
|
|
+import com.fjhx.mes.service.work.WorkOrderService;
|
|
|
+import com.fjhx.mes.utils.code.CodeEnum;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 工单 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2023-03-29
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder> implements WorkOrderService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProductInfoService productInfoService;
|
|
|
+ @Autowired
|
|
|
+ ProductionPlanService productionPlanService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<WorkOrderVo> getPage(WorkOrderSelectDto dto) {
|
|
|
+ IWrapper<WorkOrder> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("wo", WorkOrder::getId);
|
|
|
+ wrapper.like("wo",WorkOrder::getCode,dto.getKeyword());
|
|
|
+ wrapper.like("wo",WorkOrder::getQuantity,dto.getKeyword());
|
|
|
+ Page<WorkOrderVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<WorkOrderVo> records = page.getRecords();
|
|
|
+ //赋值产品名
|
|
|
+ List<Long> productIds = records.stream().map(WorkOrder::getProductId).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(productIds)) {
|
|
|
+ List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
|
|
|
+ Map<Long, ProductInfo> ProductInfoMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getId,
|
|
|
+ Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
|
|
|
+ for (WorkOrderVo workOrder : records) {
|
|
|
+ ProductInfo productInfo = ProductInfoMap.get(workOrder.getProductId());
|
|
|
+ workOrder.setProductName(productInfo.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WorkOrderVo detail(Long id) {
|
|
|
+ WorkOrder WorkOrder = this.getById(id);
|
|
|
+ WorkOrderVo result = BeanUtil.toBean(WorkOrder, WorkOrderVo.class);
|
|
|
+ List<ProductionPlan> list = productionPlanService.list(q -> q.eq(ProductionPlan::getWorkOrderId, id));
|
|
|
+ result.setProductionPlans(list);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(WorkOrderDto workOrderDto) {
|
|
|
+ //生成工单编号,以及设置默认状态
|
|
|
+ workOrderDto.setCode(CodeEnum.SUPPLIER.getCode());
|
|
|
+ workOrderDto.setStatus(0);
|
|
|
+ this.save(workOrderDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(WorkOrderDto workOrderDto) {
|
|
|
+ this.updateById(workOrderDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|