|
@@ -11,6 +11,7 @@ import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import cn.ezhizao.common.utils.PdfUtil;
|
|
@@ -110,6 +111,10 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
private IBizFurnaceNoInfoService furnaceNoInfoService;
|
|
|
@Resource
|
|
|
private IBizReturnReceiptService bizReturnReceiptService;
|
|
|
+ @Resource
|
|
|
+ private IBizDayworkItemExamineService bizDayworkItemExamineService;
|
|
|
+ @Resource
|
|
|
+ HttpServletRequest request;
|
|
|
|
|
|
/**
|
|
|
* 查询外协单主
|
|
@@ -268,6 +273,15 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
outputStream.close();
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/innerList")
|
|
|
+ @Log(title = "查询内部外协单", businessType = BusinessType.SELECT)
|
|
|
+ public TableDataInfo innerList(BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
+ startPage();
|
|
|
+ List<BizOutsourcedOrder> list = bizOutsourcedOrderService.getInnerList(bizOutsourcedOrder);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
// @Log(title = "外协打印", businessType = BusinessType.EXPORT)
|
|
|
// @PostMapping("/printDetailPdf")
|
|
|
// public void SocialSecurityPdf(BizOutsourcedOrder bizOutsourcedOrder, HttpServletResponse response) throws IOException, TemplateException, freemarker.template.TemplateException {
|
|
@@ -405,6 +419,50 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
bizOutsourcedOrder.setDetails(outsourcedOrderDetails);
|
|
|
return success(bizOutsourcedOrder);
|
|
|
}
|
|
|
+ @GetMapping(value = "/getInnerOrder")
|
|
|
+ @Log(title = "查询内部外协单详情", businessType = BusinessType.SELECT)
|
|
|
+ public AjaxResult getInnerOrder(BizOutsourcedOrder outsourcedOrder) {
|
|
|
+ BizOutsourcedOrder bizOutsourcedOrder = bizOutsourcedOrderService.getInnerById(outsourcedOrder);
|
|
|
+ BizOutsourcedOrderDetail bizOutsourcedOrderDetail = new BizOutsourcedOrderDetail();
|
|
|
+ bizOutsourcedOrderDetail.setMasterId(outsourcedOrder.getId());
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrderDetailService.getInnerList(bizOutsourcedOrderDetail);
|
|
|
+ //因为新箱子保存的时候,是用“id|code,id|code”的字符串形式存储的所以查询的时候需要进行拆分
|
|
|
+ //如果保存的时候没有选择新箱子则会把旧箱号复制到新箱号中,所有不会有“|”所以下方需要进行判断
|
|
|
+ outsourcedOrderDetails.forEach(detail -> {
|
|
|
+ // 将字符串拆分转为对象
|
|
|
+ List<BizCarrier> carriers = new ArrayList<>();
|
|
|
+ // 因为需要显示箱号,所以需要拆分出code重新拼接到NewCarrier
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
+ // 为了减少前段的逻辑,所以需要先将拆分后的id也拼接起来
|
|
|
+ List<Long> carrierIds = new ArrayList<>();
|
|
|
+
|
|
|
+ //使用 StringTokenizer 来分割字符串
|
|
|
+ StringTokenizer tokenizer = new StringTokenizer(detail.getNewCarrier(), ",");
|
|
|
+ while (tokenizer.hasMoreTokens()) {
|
|
|
+ String token = tokenizer.nextToken();
|
|
|
+ // 检查当前 token 是否包含 "|" 字符 如果没有表示不是新箱,则跳过当前 token
|
|
|
+ if (token.contains("|")) {
|
|
|
+ String[] idCode = token.split("\\|"); // 安全地分割 token
|
|
|
+ if (idCode.length == 2) {
|
|
|
+ codeList.add(idCode[1]);
|
|
|
+ carrierIds.add(Long.parseLong(idCode[0]));
|
|
|
+ BizCarrier bizCarrier = new BizCarrier();
|
|
|
+ bizCarrier.setId(Long.parseLong(idCode[0]));
|
|
|
+ bizCarrier.setCode(idCode[1]);
|
|
|
+ carriers.add(bizCarrier);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detail.setNewCarriers(carriers);
|
|
|
+ detail.setCarrierIds(carrierIds);
|
|
|
+ if (codeList.size() > 0) {
|
|
|
+ detail.setNewCarrier(String.join(",", codeList));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ bizOutsourcedOrder.setDetails(outsourcedOrderDetails);
|
|
|
+ return success(bizOutsourcedOrder);
|
|
|
+ }
|
|
|
|
|
|
@GetMapping(value = "/getFirst/{id}")
|
|
|
@Log(title = "查询首序外协详情", businessType = BusinessType.SELECT)
|
|
@@ -464,6 +522,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 新增外协单主
|
|
|
* 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
@@ -553,7 +612,8 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
@PostMapping("/submitDetails")
|
|
|
@Transactional
|
|
|
public AjaxResult submitDetails(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
- setTenantId(bizOutsourcedOrder);
|
|
|
+ String tenantId = request.getHeader("tenantId");
|
|
|
+ bizOutsourcedOrder.setTenantId(Long.valueOf(tenantId));
|
|
|
Boolean isFirst = true;
|
|
|
//若有id,则说将之前的明细删除不生成新的单号
|
|
|
if (bizOutsourcedOrder.getId() != null) {
|
|
@@ -747,12 +807,215 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
bizOutsourcedOrderDetailProcessService.updateOrSave(newDetaillist);
|
|
|
return success();
|
|
|
}
|
|
|
+ @Log(title = "内部外协发出单", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/submitInnerDetails")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult submitInnerDetails(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ bizOutsourcedOrder.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
+ Boolean isFirst = true;
|
|
|
+ //若有id,则说将之前的明细删除不生成新的单号
|
|
|
+ if (bizOutsourcedOrder.getId() != null) {
|
|
|
+ isFirst = false;
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
+ ids.add(bizOutsourcedOrder.getId());
|
|
|
+// //删除dayworkItem表
|
|
|
+// List<Long> detailIds = bizOutsourcedOrderDetailService.query().eq("master_id", bizOutsourcedOrder.getId()).list().stream().map(BizOutsourcedOrderDetail::getId).collect(Collectors.toList());
|
|
|
+// List<BizDayworkItem> oldItems = bizDayworkItemService.selectItemByOutsourcedDetailIds(detailIds);
|
|
|
+// bizDayworkItemService.removeBatchByIds(oldItems);
|
|
|
+ } else {
|
|
|
+ /* 生成单号 */
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); // 定义日期格式
|
|
|
+ String formattedDate = dateFormat.format(new Date());
|
|
|
+ String codeValue;
|
|
|
+ String codeType = "outsourcedOrderCode";
|
|
|
+ //查询redis中外协单号的值
|
|
|
+ String previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : "";
|
|
|
+ //若不存在,则直接存入
|
|
|
+ if (previous.isEmpty()) {
|
|
|
+ //如果没有数据再去数据库中查询该类型的流水号是否存在,如果存在找到最新一条,
|
|
|
+ // 在最新一条基础上进行继续追加并存到redias中,如果数据库中也没有该类型的流水号再从00001开始
|
|
|
+ List<BizOutsourcedOrder> outsourcedOrderDetailList = bizOutsourcedOrderService.getAllList();
|
|
|
+ if(!outsourcedOrderDetailList.isEmpty()){
|
|
|
+ codeValue = outsourcedOrderDetailList.get(0).getFormCode();
|
|
|
+ int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
|
|
|
+ lastFourDigits += 1; // 加1
|
|
|
+ codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
|
|
|
+ previous = codeValue;
|
|
|
+ }else{
|
|
|
+ previous = ("WFD" + formattedDate + "00001");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ codeValue = previous;
|
|
|
+ int lastFourDigits = Integer.parseInt(codeValue.substring(5, 10));
|
|
|
+ lastFourDigits += 1; // 加1
|
|
|
+ codeValue = codeValue.substring(0, 5) + String.format("%05d", lastFourDigits);
|
|
|
+ previous = codeValue;
|
|
|
+ }
|
|
|
+ //存到redis中
|
|
|
+ redisCache.setCacheObject(codeType, previous);
|
|
|
+ bizOutsourcedOrder.setFormCode(previous);
|
|
|
+ generateQrCodeImg(bizOutsourcedOrder.getFormCode(), bizOutsourcedOrder.getFormCode(), bizOutsourcedOrder);
|
|
|
+ generateBarCodeImg(bizOutsourcedOrder.getFormCode(), bizOutsourcedOrder.getFormCode(), bizOutsourcedOrder);
|
|
|
+ }
|
|
|
+ bizOutsourcedOrder.setIsSubmit(1);
|
|
|
+ //新增明细信息
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrder.getDetails();
|
|
|
+ //绑定的新箱子集合
|
|
|
+ List<BizDayworkCarrier> carrierList = new ArrayList<>();
|
|
|
+ List<String> originalCarrierCodeList = outsourcedOrderDetails.stream()
|
|
|
+ .map(item -> Arrays.asList(item.getOriginalCarrier().split(","))) // 将每个元素的字符串拆分并封装为List
|
|
|
+ .flatMap(List::stream) // 将所有拆分后的字符串扁平化为一个流
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> orginalDayworkIds = outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+ List<BizDayworkCarrier> orignalCarrierList = iBizDayworkCarrierService.query().eq("is_changed", 0).in("carrier_code", originalCarrierCodeList).in("daywork_id", orginalDayworkIds).list();
|
|
|
+
|
|
|
+ //绑定新箱子
|
|
|
+ outsourcedOrderDetails.forEach(detail -> {
|
|
|
+ detail.setSettlementType(bizOutsourcedOrder.getSettlementType());
|
|
|
+ detail.setPackagingMethod(bizOutsourcedOrder.getPackagingMethod());
|
|
|
+ detail.setDeliveryMethod(bizOutsourcedOrder.getDeliveryMethod());
|
|
|
+ /**
|
|
|
+ * 与暂存逻辑类似,但因为是彻底保存提交了,所以需要解绑原先的箱子,并且在没有新箱子时,需要将原先箱号复制到新箱号中
|
|
|
+ */
|
|
|
+ if (detail.getNewCarriers().size() > 0) {
|
|
|
+ //这一步将绑定的新箱子以“id|code”一组,以英文“,”分割(例:1|A,2|B,3|C)
|
|
|
+ String formattedString = detail.getNewCarriers().stream()
|
|
|
+ .map(item -> item.getId() + "|" + item.getCode())
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ //赋值给新箱号
|
|
|
+ detail.setNewCarrierName(detail.getNewCarriers().stream().map(BizCarrier::getCode)
|
|
|
+ .collect(Collectors.joining(",")));
|
|
|
+ detail.setNewCarrier(formattedString);
|
|
|
+
|
|
|
+ //将新箱号绑定至dayworkId
|
|
|
+ detail.getNewCarriers().forEach(carrier -> {
|
|
|
+ BizDayworkCarrier bizDayworkCarrier = new BizDayworkCarrier();
|
|
|
+ bizDayworkCarrier.setCarrierId(carrier.getId());
|
|
|
+ bizDayworkCarrier.setCarrierCode(carrier.getCode());
|
|
|
+ bizDayworkCarrier.setDayworkId(detail.getDayworkId());
|
|
|
+ bizDayworkCarrier.setLotId(detail.getLotId());
|
|
|
+ carrierList.add(bizDayworkCarrier);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ //将原箱号复制到新新箱号
|
|
|
+ //如果没点换箱,用的原箱,也要像新箱那种方式存,为了拿到newCarriers
|
|
|
+ List<String> detailOriginalCarriers = Arrays.stream(detail.getOriginalCarrier().split(",")).collect(Collectors.toList());
|
|
|
+ List<BizCarrier> orignialCarries = new ArrayList<>();
|
|
|
+ for (int i = 0; i < detailOriginalCarriers.size(); i++) {
|
|
|
+ for (int j = 0; j < orignalCarrierList.size(); j++) {
|
|
|
+ if (detailOriginalCarriers.get(i).equals(orignalCarrierList.get(j).getCarrierCode())) {
|
|
|
+ BizCarrier bizCarrier = new BizCarrier();
|
|
|
+ bizCarrier.setCode(orignalCarrierList.get(j).getCarrierCode());
|
|
|
+ bizCarrier.setId(orignalCarrierList.get(j).getCarrierId());
|
|
|
+ orignialCarries.add(bizCarrier);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String formattedString = orignialCarries.stream()
|
|
|
+ .map(item -> item.getId() + "|" + item.getCode())
|
|
|
+ .distinct().collect(Collectors.joining(","));
|
|
|
+ detail.setNewCarrier(formattedString);
|
|
|
+ detail.setNewCarrierName(orignialCarries.stream()
|
|
|
+ .map(BizCarrier::getCode)
|
|
|
+ .distinct().collect(Collectors.joining(",")));
|
|
|
+ // detail.setNewCarrier(detail.getOriginalCarrier());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<BizOutsourcedRecords> outsourcedRecordsList = new ArrayList<>();
|
|
|
+ Date now = new Date();
|
|
|
+ // 创建一个 SimpleDateFormat 对象,并设置所需的日期格式
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 格式化 Date 对象
|
|
|
+ String formattedDate = dateFormat.format(now);
|
|
|
+ // 创建一个 SimpleDateFormat 对象,并设置所需的日期格式
|
|
|
+ //保存修改记录
|
|
|
+ outsourcedOrderDetails.forEach(detail -> {
|
|
|
+ BizOutsourcedRecords saveRecords = new BizOutsourcedRecords();
|
|
|
+ saveRecords.setUserName(SecurityUtils.getLoginUser().getUser().getUserName());
|
|
|
+ saveRecords.setNickName(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
+ if (bizOutsourcedOrder.getId() == null) {
|
|
|
+ saveRecords.setMethod("创建");
|
|
|
+ } else {
|
|
|
+ saveRecords.setMethod("修改");
|
|
|
+ }
|
|
|
+ saveRecords.setFormCode(bizOutsourcedOrder.getFormCode());
|
|
|
+ saveRecords.setSupplierId(bizOutsourcedOrder.getSupplierId());
|
|
|
+ saveRecords.setSupplierName(bizOutsourcedOrder.getSupplierName());
|
|
|
+ saveRecords.setLotId(detail.getLotId());
|
|
|
+ saveRecords.setLotCode(detail.getLotCode());
|
|
|
+ saveRecords.setProductDescription(detail.getProductDescription());
|
|
|
+ saveRecords.setProductNum(detail.getProductNum());
|
|
|
+ if (detail.getNewCarriers().size() > 0) {
|
|
|
+ saveRecords.setNewCarrier(detail.getNewCarriers().stream()
|
|
|
+ .map(BizCarrier::getCode)
|
|
|
+ .collect(Collectors.joining(",")));
|
|
|
+ } else {
|
|
|
+ saveRecords.setNewCarrier(detail.getOriginalCarrier());
|
|
|
+ }
|
|
|
+ saveRecords.setProcessNames(detail.getProcessNames());
|
|
|
+ saveRecords.setIsPackage(detail.getIsPackage());
|
|
|
+ saveRecords.setStartTime(new Date());
|
|
|
+ outsourcedRecordsList.add(saveRecords);
|
|
|
+ });
|
|
|
+ //修改主表信息
|
|
|
+ bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
+ outsourcedRecordsList.forEach(item -> {
|
|
|
+ item.setMasterId(bizOutsourcedOrder.getId());
|
|
|
+ });
|
|
|
+ bizOutsourcedRecordsService.saveBatch(outsourcedRecordsList);
|
|
|
+
|
|
|
+
|
|
|
+ //判断是否使用新箱子
|
|
|
+ //根据 detail.getNewCarriers()判断是否绑定了新箱子,如果有数据表示绑定新箱子,找出对应的dayworkId,解绑对应的箱子
|
|
|
+ List<Long> dayworkIds = outsourcedOrderDetails.stream().filter(detail -> detail.getNewCarriers().size() > 0).map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+ if (dayworkIds.size() > 0) {
|
|
|
+ //解绑箱,不包括外协箱
|
|
|
+ int i = iBizDayworkCarrierService.changedCarrierStatus(dayworkIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ iBizDayworkCarrierService.saveBatch(carrierList);
|
|
|
+ //下序是否签票
|
|
|
+ bizDayworkItemExamineService.updateOrSave(outsourcedOrderDetails, bizOutsourcedOrder);
|
|
|
+ outsourcedOrderDetails = bizOutsourcedOrderDetailService.updateOrSave(outsourcedOrderDetails, bizOutsourcedOrder);
|
|
|
+ List<BizOutsourcedOrderDetail> oldDetailList = bizOutsourcedOrderDetailService.query().eq("master_id", bizOutsourcedOrder.getId()).list();
|
|
|
+ //删除或修改收回明细(通过工序判断,如果工序变了,如果已经填写了收回单,则删除收回单该批次的明细,如果只是修改了箱号,则编辑回收单该批次的明细)
|
|
|
+ bizReturnReceiptDetailService.removeOrEditDetails(outsourcedOrderDetails, oldDetailList);
|
|
|
+ //修改外协明细表
|
|
|
+ saveOrUpdateBatch(bizOutsourcedOrderDetailService,outsourcedOrderDetails,oldDetailList);
|
|
|
+ //新建发出单时,对dayworkItem保存
|
|
|
+ if(isFirst) {
|
|
|
+ List<BizDaywork> dayworkList =bizDayworkItemService.saveDayworkItemForInnerOutsource(outsourcedOrderDetails,bizOutsourcedOrder);
|
|
|
+ if(dayworkList.size()>0){
|
|
|
+ //修改报工工段及下序投产数
|
|
|
+ bizDayworkService.updateBatchById(dayworkList);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //对发出单进行编辑,则需要判断
|
|
|
+ List<BizDaywork> dayworkList = bizDayworkItemService.updateDayworkItemForInnerOutsource(outsourcedOrderDetails,oldDetailList,bizOutsourcedOrder);
|
|
|
+ if(dayworkList.size()>0){
|
|
|
+ //修改报工工段及下序投产数
|
|
|
+ bizDayworkService.updateBatchById(dayworkList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> formCodeList = outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getFormCode).collect(Collectors.toList());
|
|
|
+ List<BizOutsourcedOrderDetail> newDetaillist = bizOutsourcedOrderDetailService.query().in("form_code", formCodeList).list();
|
|
|
+ for (int i = 0; i < newDetaillist.size(); i++) {
|
|
|
+ for (int j = 0; j < outsourcedOrderDetails.size(); j++) {
|
|
|
+ if (newDetaillist.get(i).getLotId().equals(outsourcedOrderDetails.get(j).getLotId())) {
|
|
|
+ newDetaillist.get(i).setProcesses(outsourcedOrderDetails.get(j).getProcesses());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //操作外协发出工序表
|
|
|
+ bizOutsourcedOrderDetailProcessService.updateOrSave(newDetaillist);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
|
|
|
@Log(title = "首序外协保存方法", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/submitDetailsOnFirst")
|
|
|
@Transactional
|
|
|
public AjaxResult submitDetailsOnFirst(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
- setTenantId(bizOutsourcedOrder);
|
|
|
+ bizOutsourcedOrder.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
//若有id,则说将之前的明细删除不生成新的单号
|
|
|
// List<BizOutsourcedOrderDetail> insertDetail = new ArrayList<>();
|
|
|
// List<BizOutsourcedOrderDetail> updateDetail = new ArrayList<>();
|
|
@@ -832,6 +1095,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
daywork.setIsAmend(lot != null ? lot.getIsAmend() : null);
|
|
|
daywork.setIsWasteRecycling(lot != null ? lot.getIsWasteRecycling() : null);
|
|
|
daywork.setId(snowflakeIdWorker.nextId());
|
|
|
+ daywork.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
dayworks.add(daywork);
|
|
|
BizOutsourcedRecords record = new BizOutsourcedRecords();
|
|
|
record.setMasterId(bizOutsourcedOrder.getId());
|
|
@@ -890,6 +1154,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
item.setTechnologicalProcessDetailId(v.getTechnologicalProcessDetailId());
|
|
|
item.setIsWx(1);
|
|
|
item.setNickName(bizOutsourcedOrder.getSupplierName());
|
|
|
+ item.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
items.add(item);
|
|
|
});
|
|
|
|
|
@@ -1010,6 +1275,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
item.setProductionPlanDetailId(v.getDetail().getProductionPlanDetailId());
|
|
|
item.setTechnologicalProcessId(v.getDetail().getTechnologicalProcessId());
|
|
|
item.setTechnologicalProcessDetailId(v.getTechnologicalProcessDetailId());
|
|
|
+ item.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
item.setIsWx(1);
|
|
|
items.add(item);
|
|
|
});
|
|
@@ -1269,6 +1535,49 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
//删除主表信息
|
|
|
return toAjax(bizOutsourcedOrderService.removeBatchByIds(ids));
|
|
|
}
|
|
|
+ @Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/delInnerOrder/{ids}")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult delInnerOrder(@PathVariable List<Long> ids) {
|
|
|
+ //删除表,如果有报工数据,则不能删除
|
|
|
+ Boolean flag = false;
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedDetailList = bizOutsourcedOrderDetailService.query().in("master_id", ids).list();
|
|
|
+ List<Long> outsourcedDetailIds = outsourcedDetailList.stream().map(BizOutsourcedOrderDetail::getId).collect(Collectors.toList());
|
|
|
+ //德迈仕审核,flag为true
|
|
|
+ List<BizDayworkItem> dayworkItemList = bizDayworkItemService.query().in("outsource_detail_id", outsourcedDetailIds).list();
|
|
|
+ flag = dayworkItemList.stream().filter(v->v.getStatus().equals("0")||v.getStatus().equals("1") || v.getStatus().equals("2")||v.getStatus().equals("3")).collect(Collectors.toList()).isEmpty()?false:true;
|
|
|
+ if(flag) {
|
|
|
+ return error("发出单内的批次存在报工数据,不能删除!");
|
|
|
+ }
|
|
|
+ //删除收回单明细及收回单主表信息
|
|
|
+ bizReturnReceiptDetailService.removeByMasterIds(ids);
|
|
|
+ //删除明细信息
|
|
|
+ bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
+ //删除报工信息
|
|
|
+ bizDayworkItemService.removeByOutsourceIds(outsourcedDetailIds);
|
|
|
+ //修改daywork的工段数据及合格数
|
|
|
+ List<Long> dayworkIds = dayworkItemList.stream().map(BizDayworkItem::getDayworkId).distinct().collect(Collectors.toList());
|
|
|
+ List<BizDaywork> dayworkList = bizDayworkService.query().in("id", dayworkIds).list();
|
|
|
+ List<BizDayworkItem> bizDayworkItemList = bizDayworkItemService.query().in("daywork_id", dayworkIds).list();
|
|
|
+ for(BizDaywork daywork:dayworkList) {
|
|
|
+ BizDayworkItem lastDayworkItem = bizDayworkItemList.stream()
|
|
|
+ .filter(v -> v.getDayworkId().equals(daywork.getId()))
|
|
|
+ .sorted(Comparator.comparing(BizDayworkItem::getProcessStepNumber).reversed())
|
|
|
+ .sorted(Comparator.comparing(BizDayworkItem::getCreateTime).reversed()).findFirst().orElse(null);
|
|
|
+ daywork.setDeptId(lastDayworkItem.getDeptId());
|
|
|
+ List<BizDayworkItem> lastDayworkItemList = bizDayworkItemList.stream()
|
|
|
+ .filter(v -> v.getDayworkId().equals(daywork.getId()) && v.getProcessStepNumber().equals(lastDayworkItem.getProcessStepNumber()) && (v.getStatus().equals("2") || v.getStatus().equals("3"))).collect(Collectors.toList());
|
|
|
+ int sum = lastDayworkItemList.stream().mapToInt(BizDayworkItem::getQualifiedNum).sum();
|
|
|
+ daywork.setProcessQualifiedNum(sum);
|
|
|
+ daywork.setTemporaryProcessQualifiedNum(sum);
|
|
|
+ }
|
|
|
+ bizDayworkService.updateBatchById(dayworkList);
|
|
|
+ //删除明细对应的工序
|
|
|
+ bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
+
|
|
|
+ //删除主表信息
|
|
|
+ return toAjax(bizOutsourcedOrderService.removeBatchByIds(ids));
|
|
|
+ }
|
|
|
|
|
|
@Log(title="删除外协首序外协的外协单", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/removeForFirst/{ids}")
|
|
@@ -1466,6 +1775,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
daywork.setIsWaste(lot != null ? lot.getIsWaste() : null);
|
|
|
daywork.setIsAmend(lot != null ? lot.getIsAmend() : null);
|
|
|
daywork.setIsWasteRecycling(lot != null ? lot.getIsWasteRecycling() : null);
|
|
|
+ daywork.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
daywork.setId(snowflakeIdWorker.nextId());
|
|
|
dayworks.add(daywork);
|
|
|
BizOutsourcedRecords record = new BizOutsourcedRecords();
|
|
@@ -1524,6 +1834,7 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
item.setTechnologicalProcessId(l.getTechnologicalProcessId());
|
|
|
item.setTechnologicalProcessDetailId(v.getTechnologicalProcessDetailId());
|
|
|
item.setIsWx(1);
|
|
|
+ item.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
|
item.setNickName(finalBizOutsourcedOrder.getSupplierName());
|
|
|
items.add(item);
|
|
|
});
|