Преглед изворни кода

Merge remote-tracking branch 'origin/master'

guoyujia пре 1 година
родитељ
комит
e519e366ec

+ 101 - 24
src/main/java/cn/ezhizao/project/business/controller/BizProductionPlanDetailSubDetailController.java

@@ -1,13 +1,16 @@
 package cn.ezhizao.project.business.controller;
 
-import cn.ezhizao.common.utils.SecurityUtils;
 import cn.ezhizao.common.utils.poi.ExcelUtil;
 import cn.ezhizao.framework.aspectj.lang.annotation.Log;
 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,8 +33,11 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/business/planDetailSubDetail")
-public class BizProductionPlanDetailSubDetailController extends BaseController
-{
+public class BizProductionPlanDetailSubDetailController extends BaseController {
+    @Resource
+    private IBizLotService bizLotService;
+    @Resource
+    private IBizProductionPlanDetailService bizProductionPlanDetailService;
     @Resource
     private IBizProductionPlanDetailSubDetailService bizProductionPlanDetailSubDetailService;
 
@@ -45,8 +51,7 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:list')")
     @GetMapping("/list")
-    public TableDataInfo list(BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo list(BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(bizProductionPlanDetailSubDetail);
         startPage();
         List<BizProductionPlanDetailSubDetail> list = bizProductionPlanDetailSubDetailService.getList(bizProductionPlanDetailSubDetail);
@@ -60,18 +65,17 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:list')")
     @Transactional
     @GetMapping("/getDept")
-    public AjaxResult getDept() throws NoSuchFieldException, IllegalAccessException
-    {
-//        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
+    public AjaxResult getDept() throws NoSuchFieldException, IllegalAccessException {
+        // Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
         Long userId = 265L;
         List<SysDeptUser> deptUserList = deptUserService.query().eq("user_id", userId).list();
         List<Long> ids = new ArrayList<>();
-        for (SysDeptUser item:deptUserList
-             ) {
+        for (SysDeptUser item : deptUserList
+        ) {
             ids.add(item.getDeptId());
         }
         List<SysDept> deptOptions = new ArrayList<>();
-        if(ids.size() > 0){
+        if (ids.size() > 0) {
             deptOptions = deptService.getDeptOptions(ids);
         }
 
@@ -84,8 +88,7 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:export')")
     @Log(title = "生产子计划明细", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException
-    {
+    public void export(HttpServletResponse response, BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(bizProductionPlanDetailSubDetail);
         List<BizProductionPlanDetailSubDetail> list = bizProductionPlanDetailSubDetailService.getList(bizProductionPlanDetailSubDetail);
         ExcelUtil<BizProductionPlanDetailSubDetail> util = new ExcelUtil<BizProductionPlanDetailSubDetail>(BizProductionPlanDetailSubDetail.class);
@@ -97,8 +100,7 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail = new BizProductionPlanDetailSubDetail();
         bizProductionPlanDetailSubDetail.setId(id);
         List<BizProductionPlanDetailSubDetail> list = bizProductionPlanDetailSubDetailService.getList(bizProductionPlanDetailSubDetail);
@@ -113,10 +115,87 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:add')")
     @Log(title = "生产子计划明细", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException
-    {
+    @PostMapping("/save")
+    public AjaxResult add(@RequestBody BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(bizProductionPlanDetailSubDetail);
+
+        /*
+         * 德迈仕生产批号生成规则
+         * 数据表mrp10201关键字段
+         *
+         * 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
+         * 生成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, 4);
+        final String baseCodeSeq = planDetail.getProductionPlanNo().substring(4, 7) + 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.setTechnologicalProcessId(bizProductionPlanDetailSubDetail.getTechnologicalProcessId());
+            bizLot.setTechnologyVersion(bizProductionPlanDetailSubDetail.getTechnologyVersion());
+            bizLot.setProductId(bizProductionPlanDetailSubDetail.getProductId());
+            bizLot.setProductDescription(bizProductionPlanDetailSubDetail.getProductDescription());
+            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));
     }
 
@@ -125,9 +204,8 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:edit')")
     @Log(title = "生产子计划明细", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@RequestBody BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException
-    {
+    @PutMapping("/save")
+    public AjaxResult edit(@RequestBody BizProductionPlanDetailSubDetail bizProductionPlanDetailSubDetail) throws NoSuchFieldException, IllegalAccessException {
         setTenantId(bizProductionPlanDetailSubDetail);
         return toAjax(bizProductionPlanDetailSubDetailService.updateById(bizProductionPlanDetailSubDetail));
     }
@@ -137,9 +215,8 @@ public class BizProductionPlanDetailSubDetailController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('business:planDetailSubDetail:remove')")
     @Log(title = "生产子计划明细", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable List<Long> ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
         return toAjax(bizProductionPlanDetailSubDetailService.removeBatchByIds(ids));
     }
 }

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

@@ -0,0 +1,100 @@
+package cn.ezhizao.project.business.domain;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Excel;
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+/**
+ * 生产计划明细对象 biz_lot
+ *
+ * @author zhuangdezheng
+ * @date 2023-11-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "biz_lot")
+public class BizLot extends BaseEntity {
+    /**
+     * 租户(厂别)id
+     */
+    @ApiModelProperty(value = "租户(厂别)id")
+    private Long tenantId;
+
+    /**
+     * 批次号
+     */
+    @Excel(name = "批次号")
+    @ApiModelProperty(value = "批次号")
+    private String lotCode;
+
+    /**
+     * 计划单id
+     */
+    @ApiModelProperty(value = "计划单id")
+    private Long productionPlanId;
+
+    /**
+     * 计划单明细id
+     */
+    @ApiModelProperty(value = "计划单明细id")
+    private Long productionPlanDetailId;
+
+    /**
+     * 工艺id
+     */
+    @ApiModelProperty(value = "工艺id")
+    private Long technologicalProcessId;
+
+    /**
+     * 工艺版本
+     */
+    @ApiModelProperty(value = "工艺版本")
+    private String technologyVersion;
+
+    /**
+     * 产品id
+     */
+    @ApiModelProperty(value = "客户编码")
+    private Long productId;
+
+    /**
+     * 产品编码
+     */
+    @Excel(name = "产品编码")
+    @ApiModelProperty(value = "产品编码")
+    private String productCode;
+
+    /**
+     * 产品规格
+     */
+    @Excel(name = "产品规格")
+    @ApiModelProperty(value = "产品规格")
+    private String specification;
+
+    /**
+     * 产品图号
+     */
+    @Excel(name = "产品图号")
+    @ApiModelProperty(value = "产品图号")
+    private String drawingNumber;
+
+    /**
+     * 产品描述
+     */
+    @Excel(name = "产品描述")
+    @ApiModelProperty(value = "产品描述")
+    private String productDescription;
+
+    /**
+     * 生产数量
+     */
+    @Excel(name = "生产数量")
+    @ApiModelProperty(value = "生产数量")
+    private Integer productionQuantity;
+
+}

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

@@ -33,7 +33,7 @@ public class BizProductionPlanDetail extends BaseEntity
     private String transactionCode;
 
     /** 计划单id */
-    @ApiModelProperty(value = "交易代码")
+    @ApiModelProperty(value = "计划单id")
     private Long productionPlanId;
 
     /** 投料/计划单号 */
@@ -41,8 +41,13 @@ public class BizProductionPlanDetail extends BaseEntity
     @ApiModelProperty(value = "投料/计划单号")
     private String productionPlanNo;
 
+    /** 序号 */
+    @Excel(name = "序号")
+    @ApiModelProperty(value = "序号")
+    private Integer lineNumber;
+
     /** 领料部门id */
-    @ApiModelProperty(value = "投料/计划单号")
+    @ApiModelProperty(value = "领料部门id")
     private Long requisitionDepartmentId;
 
     /** 领料部门编码 */
@@ -89,6 +94,13 @@ public class BizProductionPlanDetail extends BaseEntity
     @ApiModelProperty(value = "${comment}")
     private Long technologicalProcessId;
 
+    /**
+     * 工艺版本
+     */
+    @ApiModelProperty(value = "${comment}")
+    private String technologyVersion;
+
+
 
     /** 库位 */
     @Excel(name = "库位")
@@ -107,7 +119,7 @@ public class BizProductionPlanDetail extends BaseEntity
 
     /** 状态id(对应数据字典id) */
     @ApiModelProperty(value = "限额领料量/投料数量")
-    private Long statusDictCode;
+    private Long statusId;
 
     /** NA:经营初始,FM:经营申请,JH:计划审核,OP:调度下单,YA:领料锁定,CL:全部领完,IN:部分领料 */
     @Excel(name = "NA:经营初始,FM:经营申请,JH:计划审核,OP:调度下单,YA:领料锁定,CL:全部领完,IN:部分领料")
@@ -116,7 +128,7 @@ public class BizProductionPlanDetail extends BaseEntity
 
     /** 批号状态id(对应数据字典id) */
     @ApiModelProperty(value = "NA:经营初始,FM:经营申请,JH:计划审核,OP:调度下单,YA:领料锁定,CL:全部领完,IN:部分领料")
-    private Long lotCodeStatusDictCode;
+    private Long lotCodeStatusId;
 
     /** 批号状态:NA:未生成批号,OK:已生成批号,CL:批号已完工 */
     @Excel(name = "批号状态:NA:未生成批号,OK:已生成批号,CL:批号已完工")
@@ -125,7 +137,7 @@ public class BizProductionPlanDetail extends BaseEntity
 
     /** 批次类型id(对应数据字典id) */
     @ApiModelProperty(value = "批号状态:NA:未生成批号,OK:已生成批号,CL:批号已完工")
-    private Long lotTypeDictCode;
+    private Long lotTypeId;
 
     /** 批次类型:Y:正常,新增批次;G:改料,不增批次;B:补料 */
     @Excel(name = "批次类型:Y:正常,新增批次;G:改料,不增批次;B:补料")
@@ -134,7 +146,7 @@ public class BizProductionPlanDetail extends BaseEntity
 
     /** 生产类型id */
     @ApiModelProperty(value = "批次类型:Y:正常,新增批次;G:改料,不增批次;B:补料")
-    private Long productionTypeDictCode;
+    private Long productionTypeId;
 
     /** 生产类型(Y:量产、X:样品、试制S) */
     @Excel(name = "生产类型", readConverterExp = "Y=:量产、X:样品、试制")
@@ -232,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 = "主批号/投料单号/计划单号")
@@ -249,11 +261,6 @@ public class BizProductionPlanDetail extends BaseEntity
     @ApiModelProperty(value = "订单编码")
     private String saleOrderCode;
 
-    /** 序号 */
-    @Excel(name = "序号")
-    @ApiModelProperty(value = "序号")
-    private Integer lineNumber;
-
     /** 是否外购生产 */
     @Excel(name = "是否外购生产")
     @ApiModelProperty(value = "是否外购生产")

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

@@ -0,0 +1,31 @@
+package cn.ezhizao.project.business.mapper;
+
+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 BizLotMapper extends BaseMapper<BizLot> {
+    /**
+     * 查询生产计划明细列表
+     *
+     * @param data 生产计划明细
+     * @return 生产计划明细集合
+     */
+    public List<BizLot> getList(BizLot data);
+
+    /**
+     * 物理删除
+     *
+     * @param data
+     * @return 删除结果
+     */
+    public int physicalDelete(BizLot data);
+}

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

@@ -0,0 +1,32 @@
+package cn.ezhizao.project.business.service;
+
+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 IBizLotService extends IService<BizLot>
+{
+    /**
+     * 查询生产计划明细列表
+     *
+     * @param data 生产计划明细
+     * @return 生产计划明细集合
+     */
+    List<BizLot> getList(BizLot data);
+
+    /**
+     * 物理删除
+     * @param data
+     * @return 删除结果
+     */
+    int physicalDelete(BizLot data);
+
+}

+ 47 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizLotServiceImpl.java

@@ -0,0 +1,47 @@
+package cn.ezhizao.project.business.service.impl;
+
+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业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-11-04
+ */
+@Service
+public class BizLotServiceImpl extends ServiceImpl<BizLotMapper, BizLot> implements IBizLotService {
+    @Resource
+    private BizLotMapper bizLotMapper;
+
+    /**
+     * 查询生产计划明细列表
+     *
+     * @param data 生产计划明细
+     * @return 生产计划明细
+     */
+    @Override
+    public List<BizLot> getList(BizLot data) {
+        return bizLotMapper.getList(data);
+    }
+
+    /**
+     * 物理删除
+     *
+     * @param data
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizLot data) {
+        return bizLotMapper.physicalDelete(data);
+    }
+
+    ;
+
+}