|
@@ -126,37 +126,101 @@ public class BizOutsourcedOrderController extends BaseController
|
|
|
public AjaxResult add(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
{
|
|
|
setTenantId(bizOutsourcedOrder);
|
|
|
- /* 生成单号 */
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义日期格式
|
|
|
- String formattedDate =dateFormat.format(bizOutsourcedOrder.getFormDate());
|
|
|
- String codeValue =("WX"+formattedDate+"001");
|
|
|
- String codeType = "outsourcedOrderCode";
|
|
|
- //查询redis中外协单号的值
|
|
|
- List<String> previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : new ArrayList<>();
|
|
|
- //若不存在,则直接存入
|
|
|
- if (previous.size()==0) {
|
|
|
- previous.add(codeValue);
|
|
|
+
|
|
|
+ //若有id,则说将之前的明细删除不生成新的单号
|
|
|
+ if(bizOutsourcedOrder.getId()!=null){
|
|
|
+ List<Long> ids=new ArrayList<>();
|
|
|
+ ids.add(bizOutsourcedOrder.getId());
|
|
|
+ //先将之前的明细删除
|
|
|
+ bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
+ bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
}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);
|
|
|
+ /* 生成单号 */
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义日期格式
|
|
|
+ String formattedDate =dateFormat.format(bizOutsourcedOrder.getFormDate());
|
|
|
+ String codeValue =("WX"+formattedDate+"001");
|
|
|
+ String codeType = "outsourcedOrderCode";
|
|
|
+ //查询redis中外协单号的值
|
|
|
+ List<String> previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : new ArrayList<>();
|
|
|
+ //若不存在,则直接存入
|
|
|
+ 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);
|
|
|
}
|
|
|
- previous.add(codeValue);
|
|
|
+ //存到redis中
|
|
|
+ redisCache.setCacheObject(codeType, previous);
|
|
|
+ bizOutsourcedOrder.setFormCode(previous.get(previous.size()-1));
|
|
|
}
|
|
|
+ bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
+
|
|
|
+ List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrder.getDetails();
|
|
|
+ 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
|
|
|
+ {
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
+ //若有id,则说将之前的明细删除不生成新的单号
|
|
|
+ if(bizOutsourcedOrder.getId()!=null){
|
|
|
+ List<Long> ids=new ArrayList<>();
|
|
|
+ ids.add(bizOutsourcedOrder.getId());
|
|
|
+ //先将之前的明细删除
|
|
|
+ bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
+ bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
+ }else {
|
|
|
+ /* 生成单号 */
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义日期格式
|
|
|
+ String formattedDate = dateFormat.format(bizOutsourcedOrder.getFormDate());
|
|
|
+ String codeValue = ("WX" + formattedDate + "001");
|
|
|
+ String codeType = "outsourcedOrderCode";
|
|
|
+ //查询redis中外协单号的值
|
|
|
+ List<String> previous = redisCache.hasKey(codeType) ? redisCache.getCacheObject(codeType) : new ArrayList<>();
|
|
|
+ //若不存在,则直接存入
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- //存到redis中
|
|
|
- redisCache.setCacheObject(codeType, previous);
|
|
|
- bizOutsourcedOrder.setFormCode(previous.get(previous.size()-1));
|
|
|
- bizOutsourcedOrderService.save(bizOutsourcedOrder);
|
|
|
+ //存到redis中
|
|
|
+ redisCache.setCacheObject(codeType, previous);
|
|
|
+ bizOutsourcedOrder.setFormCode(previous.get(previous.size() - 1));
|
|
|
+ }
|
|
|
+ bizOutsourcedOrder.setIsSubmit(1);
|
|
|
|
|
|
+ //修改主表信息
|
|
|
+ bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
+ //新增明细信息
|
|
|
List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrder.getDetails();
|
|
|
- outsourcedOrderDetails=bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails,bizOutsourcedOrder);
|
|
|
|
|
|
/**********查询周转新信息修改周转状态,新增一条外协部门报工信息,将对应daywork状态修改为进行中************/
|
|
|
List<BizDayworkItem> dayworkItems=new ArrayList<>();//原周转信息集合
|
|
@@ -217,34 +281,6 @@ public class BizOutsourcedOrderController extends BaseController
|
|
|
});
|
|
|
iBizDayworkCarrierService.saveBatch(carrierList);
|
|
|
}
|
|
|
- return success(bizOutsourcedOrderDetailProcessService.batchSave(outsourcedOrderDetails));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改外协单主
|
|
|
-带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:outsource:edit')")
|
|
|
- @Log(title = "外协单主带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
- @Transactional
|
|
|
- public AjaxResult edit(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
- {
|
|
|
- setTenantId(bizOutsourcedOrder);
|
|
|
- List<Long> ids=new ArrayList<>();
|
|
|
- ids.add(bizOutsourcedOrder.getId());
|
|
|
- //先将之前的明细删除
|
|
|
- bizOutsourcedOrderDetailService.removeByMasterIds(ids);
|
|
|
- bizOutsourcedOrderDetailProcessService.removeByMasterIds(ids);
|
|
|
- //修改主表信息
|
|
|
- bizOutsourcedOrderService.saveOrUpdate(bizOutsourcedOrder);
|
|
|
- //新增明细信息
|
|
|
- List<BizOutsourcedOrderDetail> outsourcedOrderDetails=bizOutsourcedOrder.getDetails();
|
|
|
- //判断是否使用新箱子
|
|
|
- if(bizOutsourcedOrder.getPackagingMethod().equals("1")){
|
|
|
- List<Long> dayworkIds=outsourcedOrderDetails.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
- iBizDayworkCarrierService.removeByDayworkIds(dayworkIds);
|
|
|
- }
|
|
|
outsourcedOrderDetails=bizOutsourcedOrderDetailService.batchSave(outsourcedOrderDetails,bizOutsourcedOrder);
|
|
|
return toAjax(bizOutsourcedOrderDetailProcessService.batchSave(outsourcedOrderDetails));
|
|
|
}
|
|
@@ -274,20 +310,32 @@ public class BizOutsourcedOrderController extends BaseController
|
|
|
}
|
|
|
|
|
|
List<Long> processIds=bizOutsourcedOrderDetailProcessList.stream().map(BizOutsourcedOrderDetailProcess::getTechnologicalProcessDetailId).collect(Collectors.toList());
|
|
|
- //找到对应的报工信息
|
|
|
+ //找到对应的外协所有报工信息
|
|
|
List<BizDayworkItem> bizDayworkItemList=bizDayworkItemService.getListByDayworkIdsForOutsourced(dayworkIds);
|
|
|
- // 使用流来筛选出包含在 processIds 列表中的 BizDayworkItem 对象
|
|
|
+
|
|
|
+ // 使用流来筛选出当前的信息
|
|
|
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);
|
|
|
//删除明细信息
|