|
@@ -1,5 +1,7 @@
|
|
|
package com.imcs.admin.business.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -7,23 +9,25 @@ import com.imcs.admin.business.dao.MaterialDao;
|
|
|
import com.imcs.admin.business.dao.WInventoryTransactionOrdersDao;
|
|
|
import com.imcs.admin.business.dao.WInventoryTransactionOrdersDetailDao;
|
|
|
import com.imcs.admin.business.service.OrderService;
|
|
|
-import com.imcs.admin.entity.WInventoryTransactionOrders;
|
|
|
-import com.imcs.admin.entity.WMaterial;
|
|
|
+import com.imcs.admin.entity.*;
|
|
|
+import com.imcs.admin.util.GenerateSerial;
|
|
|
+import com.imcs.admin.util.StringUtil;
|
|
|
+import org.apache.commons.beanutils.BeanUtils;
|
|
|
+import org.bouncycastle.asn1.cms.PasswordRecipientInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Transactional
|
|
|
@Service
|
|
|
-public class OrderServiceImpl implements OrderService {
|
|
|
- @Autowired
|
|
|
- private WInventoryTransactionOrdersDao ordersDao;
|
|
|
- @Autowired
|
|
|
- private WInventoryTransactionOrdersDetailDao ordersDetailDao;
|
|
|
- @Autowired
|
|
|
- private MaterialDao materialDao;
|
|
|
+public class OrderServiceImpl extends BaseServiceImpl implements OrderService {
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Page getInList(Page page) {
|
|
|
LambdaQueryWrapper<WInventoryTransactionOrders> wrapper = Wrappers.lambdaQuery(WInventoryTransactionOrders.class).eq(WInventoryTransactionOrders::getInOutType,2);
|
|
@@ -40,6 +44,100 @@ public class OrderServiceImpl implements OrderService {
|
|
|
//入库单 save
|
|
|
saveOrder(orders);
|
|
|
|
|
|
+ //入库任务 save
|
|
|
+ saveOrderTask(orders);
|
|
|
+
|
|
|
+ //获取目标库位
|
|
|
+ getEndPosition(orders);
|
|
|
+
|
|
|
+ //生成 移库 子任务
|
|
|
+ createSubTask(orders.getEndPosition());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createSubTask(String endPosition) {
|
|
|
+ //判断是否需要移库
|
|
|
+ if(checkStorageRelocation(endPosition)){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean checkStorageRelocation(String endPosition) {
|
|
|
+ WShelfManagement shelfManagement = storageLocationDao.getShelfManagement(endPosition);
|
|
|
+ Integer inOut = shelfManagement.getInOut();
|
|
|
+ //内侧不需要移库
|
|
|
+ if(inOut == 1){
|
|
|
+ return false;
|
|
|
+ }else if(inOut == 2){
|
|
|
+
|
|
|
+ //find 同一个区域的货架
|
|
|
+ LambdaQueryWrapper<WShelfManagement> wrapper = Wrappers.lambdaQuery(WShelfManagement.class)
|
|
|
+ .eq(WShelfManagement::getArea,shelfManagement.getArea())
|
|
|
+ .ne(WShelfManagement::getShelfCode,shelfManagement.getShelfCode());
|
|
|
+ WShelfManagement wShelfManagement = shelfDao.selectOne(wrapper);
|
|
|
+
|
|
|
+ //定位到同一层 同高度
|
|
|
+ String result = endPosition.substring(endPosition.indexOf("-") + 1);
|
|
|
+
|
|
|
+ //不确定需要 移库的库位
|
|
|
+ String other=wShelfManagement.getShelfCode()+"-"+result;
|
|
|
+
|
|
|
+ //找小库位
|
|
|
+ List<String> subStorage = storageLocationDao.getSubStorage(other);
|
|
|
+
|
|
|
+ subStorage.add(other);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<WInventoryManagement> inventoryWrapper = Wrappers.lambdaQuery(WInventoryManagement.class)
|
|
|
+ .in(WInventoryManagement::getStorageLocationCode,subStorage);
|
|
|
+
|
|
|
+ //如果目标库位的内侧库位存在托盘阻挡,则需要移库
|
|
|
+ List<WInventoryManagement> wInventoryManagements = inventoryDao.selectList(inventoryWrapper);
|
|
|
+
|
|
|
+ if(CollectionUtil.isNotEmpty(wInventoryManagements)){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getEndPosition(WInventoryTransactionOrders orders) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveOrderTask(WInventoryTransactionOrders orders) {
|
|
|
+ //入库任务
|
|
|
+
|
|
|
+ WInventoryTransactionTask.WInventoryTransactionTaskBuilder inTask = WInventoryTransactionTask.builder().taskCode(generateSerial.generateSerialNumber("inTask"))
|
|
|
+ .startPosition(orders.getStartPosition())
|
|
|
+ //TODO
|
|
|
+ .endPosition(orders.getEndPosition())
|
|
|
+ .vectorCode(orders.getVectorCode())
|
|
|
+ .status(0)
|
|
|
+ .taskType(2)
|
|
|
+ .startTime(new Date())
|
|
|
+ .createdAt(new Date())
|
|
|
+ .createdBy(getUserId());
|
|
|
+ int insert = taskDao.insert(inTask.build());
|
|
|
+
|
|
|
+ //入库任务详情
|
|
|
+ orders.getDetailList().forEach(vo->{
|
|
|
+ WInventoryTransactionTaskDetail taskDetail=new WInventoryTransactionTaskDetail();
|
|
|
+ taskDetail.setInventoryTransactionTaskId(Long.valueOf(insert));
|
|
|
+ try {
|
|
|
+ BeanUtils.copyProperties(taskDetail,vo);
|
|
|
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
|
|
+ throw new RuntimeException("转换异常");
|
|
|
+ }
|
|
|
+ taskDetail.setCreatedAt(new Date());
|
|
|
+ taskDetail.setCreatedBy(getUserId());
|
|
|
+ taskDetail.setAmount(vo.getRealAmount());
|
|
|
+ taskDetailDao.insert(taskDetail);
|
|
|
+ });
|
|
|
+
|
|
|
+ //判断目标库是否需要
|
|
|
|
|
|
}
|
|
|
|