|
@@ -1,9 +1,11 @@
|
|
|
package cn.ezhizao.project.business.controller;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.StringTokenizer;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -11,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import cn.ezhizao.framework.redis.RedisCache;
|
|
|
import cn.ezhizao.project.business.domain.*;
|
|
|
import cn.ezhizao.project.business.service.*;
|
|
|
+import cn.ezhizao.project.system.domain.SysUser;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -30,15 +33,14 @@ import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
|
|
|
/**
|
|
|
* 外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子Controller
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子Controller
|
|
|
*
|
|
|
* @author 庄德政
|
|
|
* date 2024-04-26
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/business/outsource")
|
|
|
-public class BizOutsourcedOrderController extends BaseController
|
|
|
-{
|
|
|
+public class BizOutsourcedOrderController extends BaseController {
|
|
|
@Resource
|
|
|
private IBizOutsourcedOrderService bizOutsourcedOrderService;
|
|
|
|
|
@@ -58,19 +60,18 @@ public class BizOutsourcedOrderController extends BaseController
|
|
|
private IBizCarrierService iBizCarrierService;
|
|
|
|
|
|
@Resource
|
|
|
- private IBizDayworkCarrierService iBizDayworkCarrierService;
|
|
|
+ private IBizDayworkCarrierService iBizDayworkCarrierService;
|
|
|
|
|
|
@Resource
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
/**
|
|
|
* 查询外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
- {
|
|
|
+ public TableDataInfo list(BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
setTenantId(bizOutsourcedOrder);
|
|
|
startPage();
|
|
|
List<BizOutsourcedOrder> list = bizOutsourcedOrderService.getList(bizOutsourcedOrder);
|
|
@@ -83,261 +84,280 @@ public class BizOutsourcedOrderController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:export')")
|
|
|
@Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
- {
|
|
|
- setTenantId(bizOutsourcedOrder);
|
|
|
- List<BizOutsourcedOrder> list = bizOutsourcedOrderService.getList(bizOutsourcedOrder);
|
|
|
- ExcelUtil<BizOutsourcedOrder> util = new ExcelUtil<BizOutsourcedOrder>(BizOutsourcedOrder.class);
|
|
|
- util.exportExcel(response, list, "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子数据");
|
|
|
+ public void export(HttpServletResponse response, BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException, IOException {
|
|
|
+ bizOutsourcedOrder = bizOutsourcedOrderService.getById(bizOutsourcedOrder);
|
|
|
+ BizOutsourcedOrderDetail bizOutsourcedOrderDetail = new BizOutsourcedOrderDetail();
|
|
|
+ bizOutsourcedOrderDetail.setMasterId(bizOutsourcedOrder.getId());
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrderDetailService.getList(bizOutsourcedOrderDetail);
|
|
|
+ bizOutsourcedOrder.setDetails(outsourcedOrderDetails);
|
|
|
+ bizOutsourcedOrderService.exportTemplateProvinceAreaData(response, bizOutsourcedOrder);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子详细信息
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子详细信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
- BizOutsourcedOrder bizOutsourcedOrder= bizOutsourcedOrderService.getById(id);
|
|
|
- BizOutsourcedOrderDetail bizOutsourcedOrderDetail=new BizOutsourcedOrderDetail();
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
+ BizOutsourcedOrder bizOutsourcedOrder = bizOutsourcedOrderService.getById(id);
|
|
|
+ BizOutsourcedOrderDetail bizOutsourcedOrderDetail = new BizOutsourcedOrderDetail();
|
|
|
bizOutsourcedOrderDetail.setMasterId(id);
|
|
|
- List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrderDetailService.getList(bizOutsourcedOrderDetail);
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrderDetailService.getList(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);
|
|
|
}
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:query')")
|
|
|
@GetMapping(value = "/carrierForOutsource")
|
|
|
- public TableDataInfo carrierForOutsource(BizCarrier carrier)
|
|
|
- {
|
|
|
- startPage();
|
|
|
- return getDataTable(iBizCarrierService.query().eq("category_id",1783783697558847489L).eq("deleted",0).list());
|
|
|
+ public TableDataInfo carrierForOutsource(BizCarrier carrier) {
|
|
|
+ carrier.setNotInUse(1);
|
|
|
+ List<BizCarrier> list = iBizCarrierService.getListFromOutsource(carrier);
|
|
|
+ return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:add')")
|
|
|
@Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/add")
|
|
|
@Transactional
|
|
|
- public AjaxResult add(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
setTenantId(bizOutsourcedOrder);
|
|
|
|
|
|
//若有id,则说将之前的明细删除不生成新的单号
|
|
|
- if(bizOutsourcedOrder.getId()!=null){
|
|
|
- List<Long> ids=new ArrayList<>();
|
|
|
+ if (bizOutsourcedOrder.getId() != null) {
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
ids.add(bizOutsourcedOrder.getId());
|
|
|
//先将之前的明细删除
|
|
|
bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
/* 生成单号 */
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义日期格式
|
|
|
- String formattedDate =dateFormat.format(bizOutsourcedOrder.getFormDate());
|
|
|
- String codeValue =("WX"+formattedDate+"001");
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); // 定义日期格式
|
|
|
+ String formattedDate = dateFormat.format(new Date());
|
|
|
+ String codeValue;
|
|
|
String codeType = "outsourcedOrderCode";
|
|
|
//查询redis中外协单号的值
|
|
|
- List<String> previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : new ArrayList<>();
|
|
|
+ String previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) :"";
|
|
|
//若不存在,则直接存入
|
|
|
- if (previous.size()==0) {
|
|
|
- previous.add(codeValue);
|
|
|
- }else{
|
|
|
- //存在则检查是否有相同的值
|
|
|
- for (String item : previous) {//如果有相同的值则找到最新的值进行+1
|
|
|
- if (item.equals(codeValue)) {
|
|
|
- codeValue = previous.get(previous.size() - 1);
|
|
|
- int lastFourDigits = Integer.parseInt(codeValue.substring(10, 13));
|
|
|
- lastFourDigits += 1; // 加1
|
|
|
- codeValue = codeValue.substring(0, 10) + String.format("%03d", lastFourDigits);
|
|
|
- }
|
|
|
- }
|
|
|
- previous.add(codeValue);
|
|
|
+ if (previous.isEmpty()) {
|
|
|
+ previous = ("WFD" + formattedDate + "000001");
|
|
|
+ } else {
|
|
|
+ codeValue=previous;
|
|
|
+ int lastFourDigits = Integer.parseInt(codeValue.substring(10, 13));
|
|
|
+ lastFourDigits += 1; // 加1
|
|
|
+ codeValue = codeValue.substring(0, 10) + String.format("%03d", lastFourDigits);
|
|
|
+ previous=codeValue;
|
|
|
}
|
|
|
//存到redis中
|
|
|
redisCache.setCacheObject(codeType, previous);
|
|
|
- bizOutsourcedOrder.setFormCode(previous.get(previous.size()-1));
|
|
|
+ bizOutsourcedOrder.setFormCode(previous);
|
|
|
}
|
|
|
bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
-
|
|
|
- List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrder.getDetails();
|
|
|
- outsourcedOrderDetails=bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails,bizOutsourcedOrder);
|
|
|
-
|
|
|
+ //新增明细信息
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrder.getDetails();
|
|
|
+ outsourcedOrderDetails.forEach(detail -> {
|
|
|
+ if (detail.getNewCarriers().size() > 0) {
|
|
|
+ /**
|
|
|
+ * 因为是暂存,暂存的时候不解绑原先的箱子,所以在暂存的时候需要保存新箱号的id和code所以用新箱号id和code用‘|’分割每组用逗号分割
|
|
|
+ * 取出来的时候再进行拆分
|
|
|
+ */
|
|
|
+ //这一步将绑定的新箱子以“id|code”一组,以英文“,”分割(例:1|A,2|B,3|C)
|
|
|
+ String formattedString = detail.getNewCarriers().stream()
|
|
|
+ .map(item -> item.getId() + "|" + item.getCode())
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ //赋值给新箱号
|
|
|
+ detail.setNewCarrier(formattedString);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ outsourcedOrderDetails = bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails, bizOutsourcedOrder);
|
|
|
return success(bizOutsourcedOrderDetailProcessService.batchSave(outsourcedOrderDetails));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:edit')")
|
|
|
@Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
@Transactional
|
|
|
- public AjaxResult submitOrder(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
- {
|
|
|
+ public AjaxResult submitOrder(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
setTenantId(bizOutsourcedOrder);
|
|
|
//若有id,则说将之前的明细删除不生成新的单号
|
|
|
- if(bizOutsourcedOrder.getId()!=null){
|
|
|
- List<Long> ids=new ArrayList<>();
|
|
|
+ if (bizOutsourcedOrder.getId() != null) {
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
ids.add(bizOutsourcedOrder.getId());
|
|
|
//先将之前的明细删除
|
|
|
bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
/* 生成单号 */
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义日期格式
|
|
|
- String formattedDate = dateFormat.format(bizOutsourcedOrder.getFormDate());
|
|
|
- String codeValue = ("WX" + formattedDate + "001");
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); // 定义日期格式
|
|
|
+ String formattedDate = dateFormat.format(new Date());
|
|
|
+ String codeValue;
|
|
|
String codeType = "outsourcedOrderCode";
|
|
|
//查询redis中外协单号的值
|
|
|
- List<String> previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : new ArrayList<>();
|
|
|
+ String previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) :"";
|
|
|
//若不存在,则直接存入
|
|
|
- if (previous.size() == 0) {
|
|
|
- previous.add(codeValue);
|
|
|
+ if (previous.isEmpty()) {
|
|
|
+ previous = ("WFD" + formattedDate + "000001");
|
|
|
} else {
|
|
|
- //存在则检查是否有相同的值
|
|
|
- for (String item : previous) {//如果有相同的值则找到最新的值进行+1
|
|
|
- if (item.equals(codeValue)) {
|
|
|
- codeValue = previous.get(previous.size() - 1);
|
|
|
- int lastFourDigits = Integer.parseInt(codeValue.substring(10, 13));
|
|
|
- lastFourDigits += 1; // 加1
|
|
|
- codeValue = codeValue.substring(0, 10) + String.format("%03d", lastFourDigits);
|
|
|
- }
|
|
|
- }
|
|
|
- previous.add(codeValue);
|
|
|
+ codeValue=previous;
|
|
|
+ int lastFourDigits = Integer.parseInt(codeValue.substring(10, 13));
|
|
|
+ lastFourDigits += 1; // 加1
|
|
|
+ codeValue = codeValue.substring(0, 10) + String.format("%03d", lastFourDigits);
|
|
|
+ previous=codeValue;
|
|
|
}
|
|
|
-
|
|
|
//存到redis中
|
|
|
redisCache.setCacheObject(codeType, previous);
|
|
|
- bizOutsourcedOrder.setFormCode(previous.get(previous.size() - 1));
|
|
|
+ bizOutsourcedOrder.setFormCode(previous);
|
|
|
}
|
|
|
bizOutsourcedOrder.setIsSubmit(1);
|
|
|
-
|
|
|
//修改主表信息
|
|
|
bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
//新增明细信息
|
|
|
- List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrder.getDetails();
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails = bizOutsourcedOrder.getDetails();
|
|
|
|
|
|
- /**********查询周转新信息修改周转状态,新增一条外协部门报工信息,将对应daywork状态修改为进行中************/
|
|
|
- List<BizDayworkItem> dayworkItems=new ArrayList<>();//原周转信息集合
|
|
|
- List<BizDayworkItem> newDayworkItems=new ArrayList<>();//新增报工信息集合
|
|
|
-
|
|
|
- //修改报工信息
|
|
|
- outsourcedOrderDetails.forEach(detail->{
|
|
|
- //查询周转信息
|
|
|
- BizDayworkItem bizDayworkItem=new BizDayworkItem();
|
|
|
- bizDayworkItem.setDayworkId(detail.getDayworkId());
|
|
|
- bizDayworkItem= bizDayworkService.getItemListFromOutsourced(bizDayworkItem).get(0);
|
|
|
- //修改状态
|
|
|
- bizDayworkItem.setStatus("7");
|
|
|
- dayworkItems.add(bizDayworkItem);
|
|
|
-
|
|
|
- //每一道工序新增一条报工信息
|
|
|
- BizDayworkItem finalBizDayworkItem = bizDayworkItem;
|
|
|
- detail.getProcesses().forEach(process->{
|
|
|
- //新的报工信息
|
|
|
- BizDayworkItem newBizDayworkItem=new BizDayworkItem();
|
|
|
- newBizDayworkItem.setDayworkId(detail.getDayworkId());
|
|
|
- newBizDayworkItem.setLotId(detail.getLotId());
|
|
|
- newBizDayworkItem.setProcessId(process.getProcessId());
|
|
|
- newBizDayworkItem.setProcessStepNumber(process.getProcessStepNumber());
|
|
|
- newBizDayworkItem.setStatus("1");
|
|
|
- newBizDayworkItem.setProdNum(finalBizDayworkItem.getProdNum());
|
|
|
- newBizDayworkItem.setDeptId(finalBizDayworkItem.getDeptId());
|
|
|
- newBizDayworkItem.setDeptName(finalBizDayworkItem.getDeptName());
|
|
|
- newBizDayworkItem.setDeptCode(finalBizDayworkItem.getDeptCode());
|
|
|
- newBizDayworkItem.setProductionPlanDetailId(finalBizDayworkItem.getProductionPlanDetailId());
|
|
|
- newBizDayworkItem.setTechnologicalProcessId(finalBizDayworkItem.getTechnologicalProcessId());
|
|
|
- newBizDayworkItem.setTechnologicalProcessDetailId(process.getTechnologicalProcessDetailId());
|
|
|
- newBizDayworkItem.setIsWx(1);
|
|
|
- newDayworkItems.add(newBizDayworkItem);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- bizDayworkItemService.saveOrUpdateBatch(dayworkItems);
|
|
|
- bizDayworkItemService.saveBatch(newDayworkItems);
|
|
|
+ //将周转信息修改为7,添加外协报工信息
|
|
|
+ bizDayworkItemService.updateDayworkItemForOutsource(outsourcedOrderDetails);
|
|
|
|
|
|
//判断是否使用新箱子
|
|
|
- if(bizOutsourcedOrder.getPackagingMethod().equals("1")){
|
|
|
- //解绑原来箱子
|
|
|
- List<Long> dayworkIds=outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+ //根据 detail.getNewCarriers()判断是否绑定了新箱子,如果有数据表示绑定新箱子,找出对应的dayworkId,解绑对应的箱子
|
|
|
+ List<Long> dayworkIds = outsourcedOrderDetails.stream().filter(detail -> detail.getNewCarriers().size() > 0).map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+ if(dayworkIds.size()>0){
|
|
|
iBizDayworkCarrierService.removeByDayworkIds(dayworkIds);
|
|
|
-
|
|
|
- List<BizDayworkCarrier> carrierList=new ArrayList<>();
|
|
|
- //绑定新箱子
|
|
|
- outsourcedOrderDetails.forEach(detail->{
|
|
|
- detail.getNewCarriers().forEach(carrier->{
|
|
|
- BizDayworkCarrier bizDayworkCarrier=new BizDayworkCarrier();
|
|
|
+ }
|
|
|
+ //绑定的新箱子集合
|
|
|
+ List<BizDayworkCarrier> carrierList = new ArrayList<>();
|
|
|
+ //绑定新箱子
|
|
|
+ outsourcedOrderDetails.forEach(detail -> {
|
|
|
+ /**
|
|
|
+ * 与暂存逻辑类似,但因为是彻底保存提交了,所以需要解绑原先的箱子,并且在没有新箱子时,需要将原先箱号复制到新箱号中
|
|
|
+ */
|
|
|
+ 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.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);
|
|
|
});
|
|
|
- });
|
|
|
- iBizDayworkCarrierService.saveBatch(carrierList);
|
|
|
- }
|
|
|
- outsourcedOrderDetails=bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails,bizOutsourcedOrder);
|
|
|
+ } else {
|
|
|
+ //将原箱号复制到新新箱号
|
|
|
+ detail.setNewCarrier(detail.getOriginalCarrier());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ iBizDayworkCarrierService.saveBatch(carrierList);
|
|
|
+ outsourcedOrderDetails = bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails, bizOutsourcedOrder);
|
|
|
return toAjax(bizOutsourcedOrderDetailProcessService.batchSave(outsourcedOrderDetails));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
+ * 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('business:outsource:remove')")
|
|
|
@Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
@Transactional
|
|
|
- public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
- {
|
|
|
- //查找需要删除的从表信息
|
|
|
- List<BizOutsourcedOrderDetail> outsourcedOrderDetails =bizOutsourcedOrderDetailService.query().in("master_id",ids).list();
|
|
|
- List<Long> dayworkIds=outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
-
|
|
|
- /*查询需要删除的外协工序信息,因为可能出现二次外协周转不能删除所有的外协报工,所以要查询当前外协需要加工的工序*/
|
|
|
- List<BizOutsourcedOrderDetailProcess> bizOutsourcedOrderDetailProcessList=bizOutsourcedOrderDetailProcessService.query().in("master_id",ids).list();
|
|
|
+ public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
|
+ /**
|
|
|
+ *删除工能暂时不可删除已经提交的数据,如果后续想要删除,将下方代码解开
|
|
|
+ *解开后要加上:如果使用的是新箱子,则需要解绑箱子并将对应的周转报工删除
|
|
|
+ *不删除只解绑箱子会出现错误,删除后可在手机端重新绑定箱子进行周转(也可使用别的方式进行绑定)
|
|
|
+ */
|
|
|
|
|
|
- //判断是否已经报工,如果存在投入数则表示已经报工不能删除
|
|
|
- for (BizOutsourcedOrderDetailProcess process : bizOutsourcedOrderDetailProcessList) {
|
|
|
- if(process.getProductionNum()>0){
|
|
|
- throw new RuntimeException("【"+process.getLotCode()+"】批次存在已报工的工序,不能删除");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<Long> processIds=bizOutsourcedOrderDetailProcessList.stream().map(BizOutsourcedOrderDetailProcess::getTechnologicalProcessDetailId).collect(Collectors.toList());
|
|
|
- //找到对应的外协所有报工信息
|
|
|
- List<BizDayworkItem> bizDayworkItemList=bizDayworkItemService.getListByDayworkIdsForOutsourced(dayworkIds);
|
|
|
-
|
|
|
- // 使用流来筛选出当前的信息
|
|
|
- List<BizDayworkItem> filteredList = bizDayworkItemList.stream()
|
|
|
- .filter(item -> processIds.contains(item.getTechnologicalProcessDetailId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- //删除报工信息
|
|
|
- List<Long> dayworkItemIds= filteredList.stream().map(BizDayworkItem::getId).collect(Collectors.toList());
|
|
|
- bizDayworkItemService.removeBatchByIds(dayworkItemIds);
|
|
|
-
|
|
|
- //修改对应的周转信息,将周转信息改为待周转
|
|
|
- bizDayworkItemList= bizDayworkItemService.selectLatestItemByDayworkIds(dayworkIds);
|
|
|
-
|
|
|
- bizDayworkItemList.forEach(item->{
|
|
|
- item.setStatus("4");
|
|
|
- });
|
|
|
-
|
|
|
- List<Long> removeIds=outsourcedOrderDetails.stream().filter(detail -> detail.getPackagingMethod().equals("1")).map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
- if(removeIds.size()>0) {
|
|
|
- iBizDayworkCarrierService.removeByDayworkIds(removeIds);
|
|
|
- }
|
|
|
-
|
|
|
- //此方法待定
|
|
|
- iBizDayworkCarrierService.updateByDayworkIds(outsourcedOrderDetails);
|
|
|
-
|
|
|
- //修改周转信息
|
|
|
- bizDayworkItemService.saveOrUpdateBatch(bizDayworkItemList);
|
|
|
+ //查找需要删除的从表信息
|
|
|
+// List<BizOutsourcedOrderDetail> outsourcedOrderDetails =bizOutsourcedOrderDetailService.query().in("master_id",ids).list();
|
|
|
+// List<Long> dayworkIds=outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// /*查询需要删除的外协工序信息,因为可能出现二次外协周转不能删除所有的外协报工,所以要查询当前外协需要加工的工序*/
|
|
|
+// List<BizOutsourcedOrderDetailProcess> bizOutsourcedOrderDetailProcessList=bizOutsourcedOrderDetailProcessService.query().in("master_id",ids).list();
|
|
|
+//
|
|
|
+// //判断是否已经报工,如果存在投入数则表示已经报工不能删除
|
|
|
+// for (BizOutsourcedOrderDetailProcess process : bizOutsourcedOrderDetailProcessList) {
|
|
|
+// if(process.getProductionNum()>0){
|
|
|
+// throw new RuntimeException("【"+process.getLotCode()+"】批次存在已报工的工序,不能删除");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<Long> processIds=bizOutsourcedOrderDetailProcessList.stream().map(BizOutsourcedOrderDetailProcess::getTechnologicalProcessDetailId).collect(Collectors.toList());
|
|
|
+// //找到对应的外协所有报工信息
|
|
|
+// List<BizDayworkItem> bizDayworkItemList=bizDayworkItemService.getListByDayworkIdsForOutsourced(dayworkIds);
|
|
|
+//
|
|
|
+// // 使用流来筛选出当前的信息
|
|
|
+// List<BizDayworkItem> filteredList = bizDayworkItemList.stream()
|
|
|
+// .filter(item -> processIds.contains(item.getTechnologicalProcessDetailId()))
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// //删除报工信息
|
|
|
+// List<Long> dayworkItemIds= filteredList.stream().map(BizDayworkItem::getId).collect(Collectors.toList());
|
|
|
+// bizDayworkItemService.removeBatchByIds(dayworkItemIds);
|
|
|
+//
|
|
|
+// //修改对应的周转信息,将周转信息改为待周转
|
|
|
+// bizDayworkItemList= bizDayworkItemService.selectLatestItemByDayworkIds(dayworkIds);
|
|
|
+//
|
|
|
+// bizDayworkItemList.forEach(item->{
|
|
|
+// item.setStatus("4");
|
|
|
+// });
|
|
|
+//
|
|
|
+// List<Long> removeIds=outsourcedOrderDetails.stream().filter(detail -> detail.getPackagingMethod().equals("1")).map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+// if(removeIds.size()>0) {
|
|
|
+// iBizDayworkCarrierService.removeByDayworkIds(removeIds);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //此方法待定
|
|
|
+// iBizDayworkCarrierService.updateByDayworkIds(outsourcedOrderDetails);
|
|
|
+//
|
|
|
+//
|
|
|
+// //修改周转信息
|
|
|
+// bizDayworkItemService.saveOrUpdateBatch(bizDayworkItemList);
|
|
|
//删除明细信息
|
|
|
bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
//删除明细对应的工序
|