zhuangdezheng 1 rok pred
rodič
commit
7e870e7f6c

+ 70 - 12
src/main/java/cn/ezhizao/project/business/controller/BizProductionPlanDetailSubDetailController.java

@@ -6,7 +6,11 @@ import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
 import cn.ezhizao.framework.web.controller.BaseController;
 import cn.ezhizao.framework.web.domain.AjaxResult;
 import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.domain.BizLot;
+import cn.ezhizao.project.business.domain.BizProductionPlanDetail;
 import cn.ezhizao.project.business.domain.BizProductionPlanDetailSubDetail;
+import cn.ezhizao.project.business.service.IBizLotService;
+import cn.ezhizao.project.business.service.IBizProductionPlanDetailService;
 import cn.ezhizao.project.business.service.IBizProductionPlanDetailSubDetailService;
 import cn.ezhizao.project.system.domain.SysDept;
 import cn.ezhizao.project.system.domain.SysDeptUser;
@@ -30,6 +34,10 @@ import java.util.List;
 @RestController
 @RequestMapping("/business/planDetailSubDetail")
 public class BizProductionPlanDetailSubDetailController extends BaseController {
+    @Resource
+    private IBizLotService bizLotService;
+    @Resource
+    private IBizProductionPlanDetailService bizProductionPlanDetailService;
     @Resource
     private IBizProductionPlanDetailSubDetailService bizProductionPlanDetailSubDetailService;
 
@@ -58,7 +66,7 @@ public class BizProductionPlanDetailSubDetailController extends BaseController {
     @Transactional
     @GetMapping("/getDept")
     public AjaxResult getDept() throws NoSuchFieldException, IllegalAccessException {
-//        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
+        // Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
         Long userId = 265L;
         List<SysDeptUser> deptUserList = deptUserService.query().eq("user_id", userId).list();
         List<Long> ids = new ArrayList<>();
@@ -111,29 +119,79 @@ public class BizProductionPlanDetailSubDetailController extends BaseController {
     public AjaxResult add(@RequestBody BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(bizProductionPlanDetailSubDetail);
 
-        /**
+        /*
          * 德迈仕生产批号生成规则
          * 数据表mrp10201关键字段
          *
-         * cpart产品编码字段
-         * prver工艺版本字段(目前mrp10201表中没有该字段,需要德迈仕新增)
-         * zzqty制造量(支),产品制造支数
-         * phsl生成总批数
-         * phsl1单个批次的产品支数
-         * phsl2尾批次的产品支数
+         * cpart: 产品编码字段
+         * prver: 工艺版本字段(目前mrp10201表中没有该字段,需要德迈仕新增)
+         * zzqty: 制造量(支),产品制造支数
+         * phsl:  生成总批数
+         * phsl1: 单个批次的产品支数
+         * phsl2: 尾批次的产品支数
          *
          * 通过cpart、prver从产品工艺表sfc10401获取产品加工工艺后,根据phsl、phsl1、phsl2生成对应数量的批号。
          * 验证公式:zzqty=phsl1 * (phsl - 1) + phsl2
          *
          * 举例:
-         * zzqty=15000
-         * phsl=273
-         * phsl1=55
-         * phsl2=40
+         * zzqty = 15000
+         * phsl  = 273
+         * phsl1 = 55
+         * phsl2 = 40
          * 生成272批 支数为55的批次,再生成1批 支数为40的批次
          * 总计273个批次,15000产品支数
+         *
+         * 批号12位规则:
+         * 第一位:       D表示德迈仕,J表示金华德
+         * 第二三位:     年份后两位
+         * 第四位:      月份(10月、11月、12月分别用A、B、C表示)
+         * 第五至八位:   生产计划单流水号
+         * 第九至十二位: 生产计划单下属批次流水号,
+         *
+         * D23727410070: 以这个批号为例
+         * D    -德迈仕
+         * 23   -2023年
+         * 7    -7月
+         * 2741 -生成计划单号(流水号)
+         * 007  -批次流水号,这是第7个批次
+         * 0    -用于分批,也就是一个批号,最多可以分9批
+         *
+         * 批次号生成规则
+         * docno    docseq
+         * D239096  1
+         * D239096: D    --德迈仕
+         *          23   --2023年
+         *          9    --月份
+         *          096  --序号的一部分
+         *          1    --序号的另外一部分
+         *          0961 --批次号中的“生产计划单流水号”部分
          */
 
+        /* 获取生成计划明细 */
+        final BizProductionPlanDetail planDetail = bizProductionPlanDetailService.getById(bizProductionPlanDetailSubDetail.getProductionPlanDetailId());
+        final int lotNumber = planDetail.getTotalLotNumber();
+        final int oneLotQuantity = planDetail.getOneLotQuantity();
+        final int lastLotQuantity = planDetail.getLastLotQuantity();
+        final String baseCode = planDetail.getProductionPlanNo().substring(0, 3);
+        final String baseCodeSeq = planDetail.getProductionPlanNo().substring(3, 6) + planDetail.getLineNumber().toString();
+
+        List<BizLot> bizLotList = new ArrayList<>();
+        for (int i = 0; i < lotNumber; ++i) {
+            BizLot bizLot = new BizLot();
+            /* 将i转换为3位字符串,位数不够,前面补0 */
+            String lotSeq = String.format("%03d", i + 1);
+            bizLot.setLotCode(baseCode + baseCodeSeq + lotSeq + "0");
+            bizLot.setProductionPlanDetailId(bizProductionPlanDetailSubDetail.getId());
+            bizLot.setProductionQuantity(oneLotQuantity);
+            if (i == lotNumber - 1) {
+                bizLot.setProductionQuantity(lastLotQuantity);
+            }
+            bizLotList.add(bizLot);
+        }
+        if (bizLotList.size() > 0) {
+            bizLotService.saveOrUpdateBatch(bizLotList);
+        }
+
         return toAjax(bizProductionPlanDetailSubDetailService.saveOrUpdate(bizProductionPlanDetailSubDetail));
     }
 

+ 1 - 1
src/main/java/cn/ezhizao/project/business/domain/BizLot.java

@@ -88,6 +88,6 @@ public class BizLot extends BaseEntity {
      */
     @Excel(name = "生产数量")
     @ApiModelProperty(value = "生产数量")
-    private BigDecimal productionQuantity;
+    private Integer productionQuantity;
 
 }

+ 7 - 7
src/main/java/cn/ezhizao/project/business/domain/BizProductionPlanDetail.java

@@ -41,6 +41,11 @@ public class BizProductionPlanDetail extends BaseEntity
     @ApiModelProperty(value = "投料/计划单号")
     private String productionPlanNo;
 
+    /** 序号 */
+    @Excel(name = "序号")
+    @ApiModelProperty(value = "序号")
+    private Integer lineNumber;
+
     /** 领料部门id */
     @ApiModelProperty(value = "领料部门id")
     private Long requisitionDepartmentId;
@@ -239,12 +244,12 @@ public class BizProductionPlanDetail extends BaseEntity
     /** 单批量 */
     @Excel(name = "单批量")
     @ApiModelProperty(value = "单批量")
-    private Long oneLotQuantity;
+    private Integer oneLotQuantity;
 
     /** 尾批量 */
     @Excel(name = "尾批量")
     @ApiModelProperty(value = "尾批量")
-    private Long lastLotQuantity;
+    private Integer lastLotQuantity;
 
     /** 主批号/投料单号/计划单号 */
     @Excel(name = "主批号/投料单号/计划单号")
@@ -256,11 +261,6 @@ public class BizProductionPlanDetail extends BaseEntity
     @ApiModelProperty(value = "订单编码")
     private String saleOrderCode;
 
-    /** 序号 */
-    @Excel(name = "序号")
-    @ApiModelProperty(value = "序号")
-    private Integer lineNumber;
-
     /** 是否外购生产 */
     @Excel(name = "是否外购生产")
     @ApiModelProperty(value = "是否外购生产")

+ 9 - 9
src/main/java/cn/ezhizao/project/business/mapper/BizLotMapper.java

@@ -1,31 +1,31 @@
 package cn.ezhizao.project.business.mapper;
 
-import java.util.List;
-import java.util.Map;
-
+import cn.ezhizao.project.business.domain.BizLot;
 import cn.ezhizao.project.business.domain.BizProductionPlanDetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 生产计划明细Mapper接口
  *
  * @author ruoyi
  * @date 2023-11-04
  */
-public interface BizProductionPlanDetailMapper extends BaseMapper<BizProductionPlanDetail>
-{
+public interface BizLotMapper extends BaseMapper<BizLot> {
     /**
      * 查询生产计划明细列表
      *
      * @param data 生产计划明细
      * @return 生产计划明细集合
      */
-    public List<BizProductionPlanDetail> getList(BizProductionPlanDetail data);
+    public List<BizLot> getList(BizLot data);
 
     /**
      * 物理删除
-     * @param bizProductionPlanDetail
+     *
+     * @param data
      * @return 删除结果
-    */
-    public int physicalDelete(BizProductionPlanDetail bizProductionPlanDetail);
+     */
+    public int physicalDelete(BizLot data);
 }

+ 7 - 7
src/main/java/cn/ezhizao/project/business/service/IBizLotService.java

@@ -1,18 +1,18 @@
 package cn.ezhizao.project.business.service;
 
-import java.util.List;
-import java.util.Map;
-
+import cn.ezhizao.project.business.domain.BizLot;
 import cn.ezhizao.project.business.domain.BizProductionPlanDetail;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * 生产计划明细Service接口
  *
  * @author ruoyi
  * @date 2023-11-04
  */
-public interface IBizProductionPlanDetailService extends IService<BizProductionPlanDetail>
+public interface IBizLotService extends IService<BizLot>
 {
     /**
      * 查询生产计划明细列表
@@ -20,13 +20,13 @@ public interface IBizProductionPlanDetailService extends IService<BizProductionP
      * @param data 生产计划明细
      * @return 生产计划明细集合
      */
-    List<BizProductionPlanDetail> getList(BizProductionPlanDetail data);
+    List<BizLot> getList(BizLot data);
 
     /**
      * 物理删除
-     * @param bizProductionPlanDetail
+     * @param data
      * @return 删除结果
      */
-    int physicalDelete(BizProductionPlanDetail bizProductionPlanDetail);
+    int physicalDelete(BizLot data);
 
 }

+ 17 - 15
src/main/java/cn/ezhizao/project/business/service/impl/BizLotServiceImpl.java

@@ -1,15 +1,14 @@
 package cn.ezhizao.project.business.service.impl;
 
-import java.util.List;
-import java.util.Map;
-import javax.annotation.Resource;
-
-import cn.ezhizao.project.business.domain.BizProductionPlanDetail;
-import cn.ezhizao.project.business.mapper.BizProductionPlanDetailMapper;
-import cn.ezhizao.project.business.service.IBizProductionPlanDetailService;
+import cn.ezhizao.project.business.domain.BizLot;
+import cn.ezhizao.project.business.mapper.BizLotMapper;
+import cn.ezhizao.project.business.service.IBizLotService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+
 /**
  * 生产计划明细Service业务层处理
  *
@@ -17,10 +16,9 @@ import org.springframework.stereotype.Service;
  * @date 2023-11-04
  */
 @Service
-public class BizProductionPlanDetailServiceImpl  extends ServiceImpl<BizProductionPlanDetailMapper, BizProductionPlanDetail> implements IBizProductionPlanDetailService
-{
+public class BizLotServiceImpl extends ServiceImpl<BizLotMapper, BizLot> implements IBizLotService {
     @Resource
-    private BizProductionPlanDetailMapper bizProductionPlanDetailMapper;
+    private BizLotMapper bizLotMapper;
 
     /**
      * 查询生产计划明细列表
@@ -29,17 +27,21 @@ public class BizProductionPlanDetailServiceImpl  extends ServiceImpl<BizProducti
      * @return 生产计划明细
      */
     @Override
-    public List<BizProductionPlanDetail> getList(BizProductionPlanDetail data)
-    {
-        return bizProductionPlanDetailMapper.getList(data);
+    public List<BizLot> getList(BizLot data) {
+        return bizLotMapper.getList(data);
     }
 
     /**
      * 物理删除
-     * @param bizProductionPlanDetail
+     *
+     * @param data
      * @return 删除结果
      */
     @Override
-    public int physicalDelete(BizProductionPlanDetail bizProductionPlanDetail){ return bizProductionPlanDetailMapper.physicalDelete(bizProductionPlanDetail); };
+    public int physicalDelete(BizLot data) {
+        return bizLotMapper.physicalDelete(data);
+    }
+
+    ;
 
 }