|
@@ -1,25 +1,26 @@
|
|
package com.imcs.admin.business.service.impl;
|
|
package com.imcs.admin.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.imcs.admin.business.constants.Status;
|
|
import com.imcs.admin.business.strategy.*;
|
|
import com.imcs.admin.business.strategy.*;
|
|
-import com.imcs.admin.entity.WInventoryManagement;
|
|
|
|
-import com.imcs.admin.entity.WPInventoryCountPallet;
|
|
|
|
|
|
+import com.imcs.admin.common.Result;
|
|
|
|
+import com.imcs.admin.entity.*;
|
|
import com.imcs.admin.business.dao.WPInventoryCountPalletDao;
|
|
import com.imcs.admin.business.dao.WPInventoryCountPalletDao;
|
|
import com.imcs.admin.business.service.WPInventoryCountPalletService;
|
|
import com.imcs.admin.business.service.WPInventoryCountPalletService;
|
|
-import com.imcs.admin.entity.WPInventoryCountPlan;
|
|
|
|
-import com.imcs.admin.entity.WPInventoryCountTask;
|
|
|
|
|
|
+import com.imcs.admin.entity.assemble.PolicyInputResult;
|
|
|
|
+import com.imcs.admin.entity.query.PolicyInputQuery;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 盘点托盘明细(WPInventoryCountPallet)表服务实现类
|
|
* 盘点托盘明细(WPInventoryCountPallet)表服务实现类
|
|
@@ -78,9 +79,87 @@ public class WPInventoryCountPalletServiceImpl extends BaseServiceImpl implement
|
|
* @param wPInventoryCountPallet 实例对象
|
|
* @param wPInventoryCountPallet 实例对象
|
|
* @return 实例对象
|
|
* @return 实例对象
|
|
*/
|
|
*/
|
|
|
|
+ @Transactional
|
|
@Override
|
|
@Override
|
|
public WPInventoryCountPallet insert(WPInventoryCountPallet wPInventoryCountPallet) {
|
|
public WPInventoryCountPallet insert(WPInventoryCountPallet wPInventoryCountPallet) {
|
|
|
|
+ wPInventoryCountPallet.setWPInventoryCountTaskId(wPInventoryCountPallet.getTaskId());
|
|
this.wPInventoryCountPalletDao.insert(wPInventoryCountPallet);
|
|
this.wPInventoryCountPalletDao.insert(wPInventoryCountPallet);
|
|
|
|
+ wPInventoryCountPallet.getDetailList().forEach(vo->{
|
|
|
|
+ WInventoryManagementDetail wInventoryManagementDetail=new WInventoryManagementDetail();
|
|
|
|
+ BeanUtils.copyProperties(vo,wInventoryManagementDetail);
|
|
|
|
+ wInventoryManagementDetail.setAmount(vo.getRealAmount());
|
|
|
|
+ wInventoryManagementDetailDao.updateById(wInventoryManagementDetail);
|
|
|
|
+ vo.setId(null);
|
|
|
|
+ vo.setWPInventoryCountPalletId(wPInventoryCountPallet.getId());
|
|
|
|
+ wpInventoryCountPalletDetailDao.insert(vo);
|
|
|
|
+ // TODO 更新库存
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //这个状态最适合的位置应该是在 wcs入库完成后去更改任务状态
|
|
|
|
+ /*WPInventoryCountTask wpInventoryCountTask=new WPInventoryCountTask();
|
|
|
|
+ wpInventoryCountTask.setId(wPInventoryCountPallet.getTaskId());
|
|
|
|
+ if(wPInventoryCountPallet.getIsFinsh()){
|
|
|
|
+ wpInventoryCountTask.setStatus(2);
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ wpInventoryCountTask.setStatus(1);
|
|
|
|
+ }
|
|
|
|
+ //更新盘库任务状态
|
|
|
|
+ wPInventoryCountTaskDao.update(wpInventoryCountTask);*/
|
|
|
|
+
|
|
|
|
+ //入库任务
|
|
|
|
+ //获取入库口 对应的 大小托盘
|
|
|
|
+ Dic entryPointPalletType = dicDao.getListByLabel("entryPointPalletType", wPInventoryCountPallet.getEntryPoint());
|
|
|
|
+ PolicyInputQuery policyQuery = createPolicyQuery(Integer.valueOf(entryPointPalletType.getValue()),null);
|
|
|
|
+ Result importPolicy = importOrExportPolicyService.findImportPolicy(policyQuery);
|
|
|
|
+ if(importPolicy.getData() == null){
|
|
|
|
+ throw new RuntimeException("无可用库位,请联系管理员!");
|
|
|
|
+ }
|
|
|
|
+ PolicyInputResult policyResult = (PolicyInputResult)importPolicy.getData();
|
|
|
|
+ String locationCode = policyResult.getLocationCode();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ WInventoryTransactionTask wInventoryTransactionTask=new WInventoryTransactionTask();
|
|
|
|
+ wInventoryTransactionTask.setTaskCode(generateSerial.generateSerialNumber("inTask"));
|
|
|
|
+ wInventoryTransactionTask.setStartPosition(wPInventoryCountPallet.getEntryPoint());
|
|
|
|
+ wInventoryTransactionTask.setEndPosition(locationCode);
|
|
|
|
+ wInventoryTransactionTask.setVectorCode(wPInventoryCountPallet.getPalletCode());
|
|
|
|
+ wInventoryTransactionTask.setStatus(0);
|
|
|
|
+ wInventoryTransactionTask.setTaskType(4);
|
|
|
|
+ wInventoryTransactionTask.setWPInventoryCountTaskId(wPInventoryCountPallet.getTaskId());
|
|
|
|
+ wInventoryTransactionTask.setCreatedAt(new Date());
|
|
|
|
+ wInventoryTransactionTask.setCreatedBy(getUserId());
|
|
|
|
+ taskDao.insert(wInventoryTransactionTask);
|
|
|
|
+ Long id = wInventoryTransactionTask.getId();
|
|
|
|
+
|
|
|
|
+ //入库任务详情
|
|
|
|
+ wPInventoryCountPallet.getDetailList().forEach(vo->{
|
|
|
|
+ WInventoryTransactionTaskDetail taskDetail=new WInventoryTransactionTaskDetail();
|
|
|
|
+
|
|
|
|
+ /* taskDetail.setBatchNo(vo.getBatchNo());
|
|
|
|
+ taskDetail.setUnit(vo.getUnit());
|
|
|
|
+ taskDetail.setExpirationDate(vo.getExpirationDate());
|
|
|
|
+ taskDetail.setProductionDate(vo.getProductionDate());*/
|
|
|
|
+ taskDetail.setMaterialCode(vo.getMaterialCode());
|
|
|
|
+ taskDetail.setInventoryTransactionTaskId(id);
|
|
|
|
+ taskDetail.setStatus(0);
|
|
|
|
+ taskDetail.setCreatedAt(new Date());
|
|
|
|
+ taskDetail.setCreatedBy(getUserId());
|
|
|
|
+ taskDetail.setAmount(vo.getRealAmount());
|
|
|
|
+ taskDetailDao.insert(taskDetail);
|
|
|
|
+ });
|
|
|
|
+ List<WInventoryTransactionChildTask> subList=new ArrayList<>();
|
|
|
|
+ createSubTask(locationCode, subList, id, Status.IN.getCode());
|
|
|
|
+ //保存移库子任务
|
|
|
|
+ saveSubTask(subList,null);
|
|
|
|
+
|
|
|
|
+ WInventoryTransactionChildTask wInventoryTransactionChildTask=new WInventoryTransactionChildTask(
|
|
|
|
+ id,generateSerial.generateSerialNumber("childTask"),wInventoryTransactionTask.getStartPosition(),locationCode,wInventoryTransactionTask.getVectorCode(),0,wInventoryTransactionTask.getTaskType(),new Date(),getUserId(),null);
|
|
|
|
+ childTaskDao.insert(wInventoryTransactionChildTask);
|
|
|
|
+
|
|
return wPInventoryCountPallet;
|
|
return wPInventoryCountPallet;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -109,18 +188,28 @@ public class WPInventoryCountPalletServiceImpl extends BaseServiceImpl implement
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<WInventoryManagement> getPalletList(Long id) {
|
|
public List<WInventoryManagement> getPalletList(Long id) {
|
|
- List<WInventoryManagement> wInventoryManagementList = wPInventoryCountPalletDao.selectInventoryManagementList(id);
|
|
|
|
- if(CollectionUtils.isEmpty(wInventoryManagementList)){
|
|
|
|
- WPInventoryCountTask wpInventoryCountTask = wPInventoryCountTaskDao.queryById(id);
|
|
|
|
- WPInventoryCountPlan wpInventoryCountPlan = wPInventoryCountPlanDao.queryById(wpInventoryCountTask.getWPInventoryCountPlanId());
|
|
|
|
- List<WInventoryManagement> execute = strategyMap.get(wpInventoryCountPlan.getPlanType()).execute(wpInventoryCountPlan);
|
|
|
|
- return execute;
|
|
|
|
- }else{
|
|
|
|
- wInventoryManagementList.forEach(vo->{
|
|
|
|
- vo.setDetailList(wPInventoryCountPalletDao.selectDetailList(vo.getId()));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ List<WInventoryManagement> wInventoryManagementList=new ArrayList<>();
|
|
|
|
+ wInventoryManagementList = wPInventoryCountPalletDao.selectInventoryManagementList(id);
|
|
|
|
+ wInventoryManagementList.forEach(vo->{
|
|
|
|
+ vo.setDetailList(wPInventoryCountPalletDao.selectDetailList(vo.getId()));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ WPInventoryCountTask wpInventoryCountTask = wPInventoryCountTaskDao.queryById(id);
|
|
|
|
+ WPInventoryCountPlan wpInventoryCountPlan = wPInventoryCountPlanDao.queryById(wpInventoryCountTask.getWPInventoryCountPlanId());
|
|
|
|
+ List<WInventoryManagement> execute = strategyMap.get(wpInventoryCountPlan.getPlanType()).execute(wpInventoryCountPlan);
|
|
|
|
|
|
|
|
+
|
|
|
|
+ Iterator<WInventoryManagement> iterator = execute.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ WInventoryManagement execItem = iterator.next();
|
|
|
|
+ for (WInventoryManagement wItem : wInventoryManagementList) {
|
|
|
|
+ if (wItem.getPalletCode().equals(execItem.getPalletCode())) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wInventoryManagementList.addAll(execute);
|
|
return wInventoryManagementList;
|
|
return wInventoryManagementList;
|
|
}
|
|
}
|
|
}
|
|
}
|