|
@@ -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));
|
|
|
}
|
|
|
|