瀏覽代碼

报工列表调整,添加报工删除

yzc 10 月之前
父節點
當前提交
7ad5e5ab51

+ 14 - 13
hx-mes/src/main/java/com/fjhx/mes/controller/production/ProductionReportingDetailController.java

@@ -1,13 +1,14 @@
 package com.fjhx.mes.controller.production;
 
-import org.springframework.web.bind.annotation.*;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.mes.entity.production.vo.ProductionReportingDetailVo;
-import com.fjhx.mes.entity.production.dto.ProductionReportingDetailSelectDto;
 import com.fjhx.mes.entity.production.dto.ProductionReportingDetailDto;
-import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.fjhx.mes.entity.production.vo.ProductionReportingDetailVo;
 import com.fjhx.mes.service.production.ProductionReportingDetailService;
+import com.ruoyi.common.core.domain.BaseSelectDto;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 
 /**
@@ -15,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
  * 生产报工明细 前端控制器
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-03-30
  */
 @RestController
@@ -25,13 +26,13 @@ public class ProductionReportingDetailController {
     @Autowired
     private ProductionReportingDetailService productionReportingDetailService;
 
-    /**
-     * 生产报工明细分页
-     */
-    @PostMapping("/page")
-    public Page<ProductionReportingDetailVo> page(@RequestBody ProductionReportingDetailSelectDto dto) {
-        return productionReportingDetailService.getPage(dto);
-    }
+//    /**
+//     * 生产报工明细分页
+//     */
+//    @PostMapping("/page")
+//    public Page<ProductionReportingDetailVo> page(@RequestBody ProductionReportingDetailSelectDto dto) {
+//        return productionReportingDetailService.getPage(dto);
+//    }
 
     /**
      * 生产报工明细明细

+ 23 - 1
hx-mes/src/main/java/com/fjhx/mes/entity/production/dto/ProductionReportingSelectDto.java

@@ -1,17 +1,39 @@
 package com.fjhx.mes.entity.production.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.core.domain.BaseSelectDto;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Date;
+
 /**
  * 生产报工列表查询入参实体
  *
- * @author 
+ * @author
  * @since 2023-03-30
  */
 @Getter
 @Setter
 public class ProductionReportingSelectDto extends BaseSelectDto {
 
+    /**
+     * 归属公司id
+     */
+    private Long companyId;
+
+    /**
+     * 工序id
+     */
+    private Long productionProcessesId;
+
+    /**
+     * 报工人Id
+     */
+    private Long userId;
+
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private Date dataDate;
+
+
 }

+ 47 - 2
hx-mes/src/main/java/com/fjhx/mes/entity/production/vo/ProductionReportingVo.java

@@ -1,7 +1,6 @@
 package com.fjhx.mes.entity.production.vo;
 
 import com.fjhx.mes.entity.production.po.ProductionReporting;
-import com.fjhx.mes.entity.production.po.ProductionReportingDetail;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -54,7 +53,53 @@ public class ProductionReportingVo extends ProductionReporting {
      */
     private Date dueDate;
 
-    /**报工明细列表*/
+    /**
+     * 报工明细列表
+     */
     List<ProductionReportingDetailVo> productionReportingDetailVoList;
 
+    /**
+     * 订单好
+     */
+    private String orderCode;
+    /**
+     * 任务单号
+     */
+    private String taskCode;
+    /**
+     * 工序名称
+     */
+    private String processesName;
+
+    /**
+     * 办公用户名称
+     */
+    private String userName;
+
+    /**
+     * 公司名称
+     */
+    private String companyName;
+
+    /**
+     * 产品编号
+     */
+    private String productCode;
+    /**
+     * 产品长
+     */
+    private BigDecimal productLength;
+    /**
+     * 产品宽
+     */
+    private BigDecimal productWidth;
+    /**
+     * 产品高
+     */
+    private BigDecimal productHeight;
+    /**
+     * 产品颜色
+     */
+    private String productColor;
+
 }

+ 105 - 2
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProductionReportingServiceImpl.java

@@ -17,10 +17,12 @@ import com.fjhx.mes.entity.technology.po.TechnologyProcessLine;
 import com.fjhx.mes.mapper.production.ProductionReportingMapper;
 import com.fjhx.mes.service.production.*;
 import com.fjhx.mes.service.technology.TechnologyProcessLineService;
+import com.fjhx.tenant.utils.DeptUstil;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.common.utils.wrapper.SqlField;
 import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -62,11 +64,56 @@ public class ProductionReportingServiceImpl extends ServiceImpl<ProductionReport
     @Override
     public Page<ProductionReportingVo> getPage(ProductionReportingSelectDto dto) {
         IWrapper<ProductionReporting> wrapper = getWrapper();
+
+        //权限过滤:生产报工
+        wrapper.in("pr", ProductionReporting::getCompanyId, SecurityUtils.getCompanyIds());
+        wrapper.eq("pr", ProductionReporting::getCompanyId, dto.getCompanyId());
+
+        //工序过滤
+        wrapper.eq("pr", ProductionReporting::getProductionProcessesId, dto.getProductionProcessesId());
+
+        //用户过滤
+        if (ObjectUtil.isNotEmpty(dto.getUserId())) {
+            wrapper.apply("FIND_IN_SET( {0}, pr.user_set )", dto.getUserId());
+        }
+
+        //日期过滤
+        if (ObjectUtil.isNotEmpty(dto.getDataDate())) {
+            wrapper.apply("DATE_FORMAT(pr.create_time, '%Y-%m') = DATE_FORMAT({0}, '%Y-%m')", dto.getDataDate());
+        }
+
+        //关键字检索
+        wrapper.keyword(dto.getKeyword(),
+                new SqlField("pr.user_name"),
+                new SqlField("po.code")
+        );
+
         wrapper.orderByDesc("pr", ProductionReporting::getId);
-        wrapper.like("pt.code", dto.getKeyword());
         Page<ProductionReportingVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<ProductionReportingVo> records = page.getRecords();
-        UserUtil.assignmentNickName(records, ProductionReporting::getCreateUser, ProductionReportingVo::setOperatorName);
+        if (ObjectUtil.isEmpty(records)) {
+            return page;
+        }
+
+        //获取生产公司信息
+        List<Long> companyIds = records.stream().map(ProductionReporting::getCompanyId).collect(Collectors.toList());
+        Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
+
+        for (ProductionReportingVo record : records) {
+            //赋值生产公司名称
+            record.setCompanyName(companyNameMap.get(record.getCompanyId()));
+        }
+
+        //赋值产品信息
+        productInfoService.attributeAssign(records, ProductionReportingVo::getProductId, (item, productInfo) -> {
+            item.setProductName(productInfo.getName());
+            item.setProductCode(productInfo.getCustomCode());
+            item.setProductLength(productInfo.getLength());
+            item.setProductWidth(productInfo.getWidth());
+            item.setProductHeight(productInfo.getHeight());
+            item.setProductColor(productInfo.getColor());
+        });
+
         return page;
     }
 
@@ -266,10 +313,66 @@ public class ProductionReportingServiceImpl extends ServiceImpl<ProductionReport
 //        productionReportingDetailService.updateBatchById(productionReportingDetailList);
     }
 
+    @DSTransactional
     @Override
     public void delete(Long id) {
+        ProductionReporting dataById = this.getById(id);
+        Assert.notEmpty(dataById, "查询不到报工信息!");
+        Long taskId = dataById.getProductionTaskId();
+        Long processesId = dataById.getProductionProcessesId();
+        BigDecimal quantity = dataById.getQuantity();
+
         this.removeById(id);
         productionReportingDetailService.remove(q -> q.eq(ProductionReportingDetail::getProductionReportingId, id));
+
+        //获取工艺信息
+        ProductionOrderDetail pod = produceOrderDetailService.getById(taskId);
+        Assert.notEmpty(pod, "查询不到生产任务信息!");
+        ProductInfo productInfo = productInfoService.getById(pod.getProductId());
+        Assert.notEmpty(productInfo, "查询不到生产产品信息!");
+        Long technologyId = productInfo.getTechnologyId();
+
+        //回滚当前工序生产进度
+        productionTaskProgressService.update(q -> q
+                .eq(ProductionTaskProgress::getTaskId, taskId)
+                .eq(ProductionTaskProgress::getProcessesId, processesId)
+                .setSql("finish_quantity = finish_quantity - " + quantity)
+                .setSql("balance_quantity = balance_quantity + " + quantity)
+                .set(BasePo::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
+
+        //回滚下一工序结存数量
+        List<Long> nextProcessIds = technologyProcessLineService.listObject(TechnologyProcessLine::getTargetProcessesId, q -> q
+                .eq(TechnologyProcessLine::getTechnologyId, technologyId)
+                .eq(TechnologyProcessLine::getSourceProcessesId, processesId)
+                .ne(TechnologyProcessLine::getTargetProcessesId, 99)
+        );
+        if (ObjectUtil.isNotEmpty(nextProcessIds)) {
+            productionTaskProgressService.update(q -> q
+                    .eq(ProductionTaskProgress::getTaskId, taskId)
+                    .in(ProductionTaskProgress::getProcessesId, nextProcessIds)
+                    .setSql("balance_quantity = balance_quantity - " + quantity)
+                    .set(BasePo::getUpdateTime, new Date())
+                    .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+            );
+        }
+
+        //回滚生产任务完成数量以及状态
+        produceOrderDetailService.update(q -> q
+                .eq(ProductionOrderDetail::getId, taskId)
+                .setSql("produce_status = IF(produce_status=2,1,produce_status)")
+                .setSql("finish_quantity = finish_quantity - " + quantity)
+                .set(BasePo::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
+        //回滚生产订单状态
+        produceOrderService.update(q -> q
+                .eq(ProductionOrder::getId, pod.getProduceOrderId())
+                .setSql("produce_status = IF(produce_status=2,1,produce_status)")
+                .set(BasePo::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
     }
 
 }

+ 13 - 11
hx-mes/src/main/resources/mapper/production/ProductionReportingMapper.xml

@@ -2,17 +2,19 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.mes.mapper.production.ProductionReportingMapper">
     <select id="getPage" resultType="com.fjhx.mes.entity.production.vo.ProductionReportingVo">
-        SELECT
-            pr.id,
-            pr.production_task_id,
-            pt.CODE,
-            pr.create_user,
-            pr.create_time,
-            pr.update_user,
-            pr.update_time
-        FROM
-            production_reporting pr
-                JOIN production_task pt ON pr.production_task_id = pt.id
+        SELECT pr.*,
+               po.`code`  AS orderCode,
+               pod.`code` AS taskCode,
+               pp.`name`  AS processesName,
+               pod.product_id
+        FROM (SELECT pr.*,
+                     GROUP_CONCAT(su.nick_name SEPARATOR ',') AS user_name
+              FROM production_reporting pr
+                       LEFT JOIN sys_user su ON FIND_IN_SET(su.user_id, pr.user_set)
+              GROUP BY pr.id) pr
+                 LEFT JOIN production_order_detail pod ON pr.production_task_id = pod.id
+                 LEFT JOIN production_order po ON pod.produce_order_id = po.id
+                 LEFT JOIN production_processes pp ON pr.production_processes_id = pp.id
             ${ew.customSqlSegment}
     </select>
     <select id="detail" resultType="com.fjhx.mes.entity.production.vo.ProductionReportingVo">