|
@@ -1,12 +1,15 @@
|
|
|
package cn.ezhizao.project.business.controller;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
|
+import cn.ezhizao.common.utils.uuid.SnowflakeIdWorker;
|
|
|
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
@@ -55,6 +58,16 @@ public class BizLotController extends BaseController
|
|
|
@Resource
|
|
|
private IBizTechnologicalProcessDetailService bizTechnologicalProcessDetailService;
|
|
|
@Resource
|
|
|
+ private IBizProductionPlanDetailService bizProductionPlanDetailService;
|
|
|
+ @Resource
|
|
|
+ private IBizProductService bizProductService;
|
|
|
+ @Resource
|
|
|
+ private IBizDayworkItemService bizDayworkItemService;
|
|
|
+ @Resource
|
|
|
+ private IBizDayworkService bizDayworkService;
|
|
|
+ @Resource
|
|
|
+ private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
+ @Resource
|
|
|
HttpServletRequest request;
|
|
|
|
|
|
/**
|
|
@@ -274,20 +287,74 @@ public class BizLotController extends BaseController
|
|
|
return toAjax(bizLotService.removeBatchByIds(ids));
|
|
|
}
|
|
|
|
|
|
-// @PreAuthorize("@ss.hasPermi('business:lot:query')")
|
|
|
-// @Log(title="分批信息", businessType = BusinessType.SELECT)
|
|
|
-// @PostMapping("/getLotInfoForInBatches")
|
|
|
-// public AjaxResult getLotInfoForInBatches(@RequestBody BizLot bizLot) {
|
|
|
-// // 分批信息需要批次信息
|
|
|
-// // 下达日期
|
|
|
-// // 当前工段
|
|
|
-// // 当前工序投产量
|
|
|
-// List<BizLot> lots = bizLotService.getList(bizLot);
|
|
|
-// if (lots.size() == 0) {
|
|
|
-// return error("没有找到批次信息");
|
|
|
-// }
|
|
|
-// BizLot lot = lots.get(0);
|
|
|
-//
|
|
|
-// return success(bizLotService.getLotInfoForInBatches(bizLot));
|
|
|
-// }
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:lot:query')")
|
|
|
+ @Log(title="分批信息", businessType = BusinessType.SELECT)
|
|
|
+ @PostMapping("/getLotInfoForInBatches")
|
|
|
+ public AjaxResult getLotInfoForInBatches(@RequestBody BizLot bizLot) {
|
|
|
+ // 分批信息需要批次信息
|
|
|
+
|
|
|
+ List<BizLot> lots = bizLotService.getList(bizLot);
|
|
|
+ if (lots.size() == 0) {
|
|
|
+ return error("没有找到批次信息");
|
|
|
+ }
|
|
|
+ BizLot lot = lots.get(0);
|
|
|
+ // 产品描述
|
|
|
+ BizProduct product = bizProductService.getById(lot.getProductId());
|
|
|
+ lot.setProductCode(product.getProductCode());
|
|
|
+ lot.setProductDescription(product.getDescription());
|
|
|
+ // 计划单号
|
|
|
+ BizProductionPlanDetail productionPlanDetail = bizProductionPlanDetailService.getById(lot.getProductionPlanDetailId());
|
|
|
+ lot.setProductionPlanNo(productionPlanDetail.getProductionPlanNo());
|
|
|
+ // 下达日期
|
|
|
+ lot.setIssueDate(productionPlanDetail.getIssueDate());
|
|
|
+ // 当前工段
|
|
|
+// BizDaywork bizDaywork = bizDayworkService.query().eq("lot_id", bizLot.getId()).one();
|
|
|
+ BizDayworkItem conditions = new BizDayworkItem();
|
|
|
+ conditions.setLotId(lot.getId());
|
|
|
+ List<BizDayworkItem> dayworkItemList = bizDayworkItemService.getList(conditions);
|
|
|
+ BizDayworkItem dayworkItem = dayworkItemList.stream().filter(v -> !Arrays.asList("4", "5", "7").contains(v.getStatus())).collect(Collectors.toList()).stream().findFirst().orElse(new BizDayworkItem());
|
|
|
+ lot.setCurrentDept(dayworkItem.getDeptName());
|
|
|
+ // 当前工序投产量
|
|
|
+ lot.setProdNum(dayworkItem.getProdNum());
|
|
|
+ return success(lot);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:lot:add')")
|
|
|
+ @Log(title="分批保存", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/saveIsBatches")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public AjaxResult saveInBatches(@RequestBody BizLot bizLot) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ List<BizLot> sparateList = bizLot.getSparateList();
|
|
|
+ List<BizDaywork> bizDayworks = new ArrayList<>();
|
|
|
+ List<BizDayworkItem> bizDayworkItems = new ArrayList<>();
|
|
|
+ // 判断是否已报工
|
|
|
+ List<BizDaywork> baseDayworks = bizDayworkService.getList(new BizDaywork().setLotId(bizLot.getId()));
|
|
|
+ List<BizDayworkItem> baseDayworkItems = bizDayworkItemService.getList(new BizDayworkItem().setLotId(bizLot.getId()));
|
|
|
+ if (baseDayworks.size() > 0) {
|
|
|
+ sparateList.forEach(l -> {
|
|
|
+ if (l.getId() == null) {
|
|
|
+ // 分批复制报工详情
|
|
|
+ List<BizDaywork> newDayworks = new ArrayList<>();
|
|
|
+ baseDayworks.forEach(v -> {
|
|
|
+ BizDaywork newDaywork = new BizDaywork(v);
|
|
|
+ v.setId(snowflakeIdWorker.nextId());
|
|
|
+ v.setProcessQualifiedNum(l.getProdNum());
|
|
|
+ List<BizDayworkItem> items = baseDayworkItems.stream().filter(e -> e.getDayworkId().equals(v.getId())).collect(Collectors.toList());
|
|
|
+ items.forEach(e -> {
|
|
|
+ BizDayworkItem item = new BizDayworkItem(e);
|
|
|
+ item.setDayworkId(newDaywork.getId());
|
|
|
+ item.setId(null);
|
|
|
+ bizDayworkItems.add(item);
|
|
|
+ });
|
|
|
+ newDayworks.add(newDaywork);
|
|
|
+ });
|
|
|
+ bizDayworks.addAll(newDayworks);
|
|
|
+ } else {
|
|
|
+ // 本批将当前报工数量改成分批后的数量。
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 将报工信息复制一份
|
|
|
+ return toAjax(bizLotService.saveOrUpdateBatch(sparateList) && (bizDayworks.isEmpty() || bizDayworkService.saveOrUpdateBatch(bizDayworks)) && (bizDayworkItems.isEmpty() || bizDayworkItemService.saveOrUpdateBatch(bizDayworkItems)));
|
|
|
+ }
|
|
|
}
|