|
|
|
@ -35,12 +35,17 @@ import com.glxp.api.res.inv.InvCountOrderResponse;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.service.inout.IoAddInoutService;
|
|
|
|
|
import com.glxp.api.service.inout.IoCheckInoutService;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
|
|
|
@ -73,7 +78,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicCorpDao unitMaintainDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderDao orderDao;
|
|
|
|
|
private IoOrderService orderService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCodeTempDao codesTempDao;
|
|
|
|
|
@Resource
|
|
|
|
@ -88,7 +93,13 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
private UdiRelevanceService udiRelevanceService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IBasicBussinessTypeService basicBussinessTypeService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private InvCountSettingService invCountSettingService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoAddInoutService addInoutService;
|
|
|
|
|
@Resource
|
|
|
|
|
@Lazy
|
|
|
|
|
IoCheckInoutService ioCheckInoutService;
|
|
|
|
|
|
|
|
|
|
public List<InvCountOrderResponse> filterList(FilterInvCountOrderRequest filterInvCountOrderRequest) {
|
|
|
|
|
if (null == filterInvCountOrderRequest) {
|
|
|
|
@ -101,6 +112,16 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InvCountOrderResponse selectJoinByOrderId(String orderId) {
|
|
|
|
|
FilterInvCountOrderRequest filterInvCountOrderRequest = new FilterInvCountOrderRequest();
|
|
|
|
|
filterInvCountOrderRequest.setOrderId(orderId);
|
|
|
|
|
List<InvCountOrderResponse> orderResponses = invCountOrderDao.selectList(filterInvCountOrderRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(orderResponses))
|
|
|
|
|
return orderResponses.get(0);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteOrder(String id) {
|
|
|
|
|
String orderId = invCountOrderDao.selectOrderIdById(id);
|
|
|
|
|
log.info("开始删除盘点单据,盘点单号: {}", orderId);
|
|
|
|
@ -118,12 +139,12 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
public BaseResponse saveCountOrder(InvCountOrderEntity invCountOrder) {
|
|
|
|
|
if (invCountOrder.getCountType() == 0 || invCountOrder.getCountType() == 2) {
|
|
|
|
|
//整库盘点
|
|
|
|
|
if (StrUtil.isBlank(invCountOrder.getInvStorageCode()) || StrUtil.isBlank(invCountOrder.getInvWarehouseCode())) {
|
|
|
|
|
if (StrUtil.isBlank(invCountOrder.getInvStorageCode())) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请选择仓库信息!");
|
|
|
|
|
}
|
|
|
|
|
} else if (invCountOrder.getCountType() == 1) {
|
|
|
|
|
//货位盘点
|
|
|
|
|
if (StrUtil.isBlank(invCountOrder.getInvStorageCode()) || StrUtil.isBlank(invCountOrder.getInvWarehouseCode()) || StrUtil.isBlank(invCountOrder.getInvSpaceCode())) {
|
|
|
|
|
if (StrUtil.isBlank(invCountOrder.getInvStorageCode()) || StrUtil.isBlank(invCountOrder.getInvWarehouseCode())) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "请选择仓库和货位信息!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -153,7 +174,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseResponse submitAudit(String id) {
|
|
|
|
|
InvCountOrderEntity invCountOrder = invCountOrderDao.selectById(id);
|
|
|
|
|
InvCountOrderEntity invCountOrder = invCountOrderDao.selectByOrderId(id);
|
|
|
|
|
if (null == invCountOrder) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "单据不存在");
|
|
|
|
|
}
|
|
|
|
@ -166,17 +187,17 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "请先选择盘点产品");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long codesCount = invCountCodesDao.countByOrderIdFk(invCountOrder.getOrderId());
|
|
|
|
|
if (codesCount == 0) {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "请扫描需要盘点的产品");
|
|
|
|
|
}
|
|
|
|
|
// Long codesCount = invCountCodesDao.countByOrderIdFk(invCountOrder.getOrderId());
|
|
|
|
|
// if (codesCount == 0) {
|
|
|
|
|
// return ResultVOUtils.error(ResultEnum.DATA_ERROR, "请扫描需要盘点的产品");
|
|
|
|
|
// }
|
|
|
|
|
//更新状态
|
|
|
|
|
invCountOrder.setStatus(1);
|
|
|
|
|
invCountOrder.setUpdateTime(new Date());
|
|
|
|
|
//查询单据详情,计算盘点盈亏状态
|
|
|
|
|
List<InvCountOrderDetailEntity> detailList = invCountOrderDetailDao.selectByOrderId(invCountOrder.getOrderId());
|
|
|
|
|
for (InvCountOrderDetailEntity invCountOrderDetail : detailList) {
|
|
|
|
|
int diff = invCountOrderDetail.getInvNum() - invCountOrderDetail.getCountNum();
|
|
|
|
|
int diff = IntUtil.value(invCountOrderDetail.getInvNum()) - IntUtil.value(invCountOrderDetail.getCountNum());
|
|
|
|
|
if (diff > 0) {
|
|
|
|
|
invCountOrderDetail.setLossNum(Math.abs(diff));
|
|
|
|
|
//盘亏
|
|
|
|
@ -212,10 +233,6 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
//审核通过
|
|
|
|
|
//根据单据详情生成相关单据
|
|
|
|
|
log.info("单据审核通过后将会生成对应盘盈盘亏单是否继续?,开始生成扫码单据");
|
|
|
|
|
// ThreadUtil.execAsync(() -> {
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
countTransferOrder(invCountOrder);
|
|
|
|
|
}
|
|
|
|
|
invCountOrderDao.updateById(invCountOrder);
|
|
|
|
@ -246,7 +263,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
* 盘点单据转扫码单
|
|
|
|
|
*/
|
|
|
|
|
private void countOrderTransfer(InvCountOrderEntity invCountOrder) {
|
|
|
|
|
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
|
|
|
|
|
List<InvCountSettingEntity> list = invCountSettingDao.selectList(null);
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
log.error("未配置盘点单据设置参数,无法转单");
|
|
|
|
|
return;
|
|
|
|
@ -277,7 +294,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
|
|
|
|
|
if (invCountOrder.getCountType() == 1) {
|
|
|
|
|
//按照货位盘点,查询库存详情添加货位条件
|
|
|
|
|
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
|
|
|
|
|
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvWarehouseCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FilterInvCountOrderDetailRequest detailRequest = new FilterInvCountOrderDetailRequest();
|
|
|
|
@ -437,7 +454,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
invCountOrder.setInOrderIds(order.getBillNo());
|
|
|
|
|
orderDao.insert(order);
|
|
|
|
|
orderService.insertOrder(order);
|
|
|
|
|
codesTempDao.insertBatch(inOrderCodes);
|
|
|
|
|
log.info("盘盈入库单据生成成功");
|
|
|
|
|
}
|
|
|
|
@ -455,7 +472,7 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
invCountOrder.setOutOrderIds(order.getBillNo());
|
|
|
|
|
orderDao.insert(order);
|
|
|
|
|
orderService.insertOrder(order);
|
|
|
|
|
codesTempDao.insertBatch(outOrderCodes);
|
|
|
|
|
log.info("盘亏入库单据生成成功");
|
|
|
|
|
}
|
|
|
|
@ -470,13 +487,11 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
*/
|
|
|
|
|
private void countTransferOrder(InvCountOrderEntity invCountOrder) {
|
|
|
|
|
|
|
|
|
|
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
InvCountSettingEntity invCountSettingEntity = invCountSettingService.findByInvSpace(invCountOrder.getInvStorageCode(), invCountOrder.getInvWarehouseCode());
|
|
|
|
|
if (invCountSettingEntity == null) {
|
|
|
|
|
log.error("未配置盘点单据设置参数,无法转单");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
InvCountSettingEntity invCountSettingEntity = list.get(0);
|
|
|
|
|
|
|
|
|
|
List<InvCountOrderDetailEntity> orderDetailList = invCountOrderDetailDao.selectByOrderId(invCountOrder.getOrderId());
|
|
|
|
|
List<IoCodeTempEntity> lossCodesList = new ArrayList<>();
|
|
|
|
|
List<IoCodeTempEntity> profitCodesList = new ArrayList<>();
|
|
|
|
@ -504,8 +519,14 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
warehouseEntity.setAction(order.getAction());
|
|
|
|
|
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
|
|
|
|
|
});
|
|
|
|
|
orderDao.insert(order);
|
|
|
|
|
orderService.insertOrder(order);
|
|
|
|
|
codesTempDao.insertBatch(lossCodesList);
|
|
|
|
|
|
|
|
|
|
addInoutService.dealProcess(order);
|
|
|
|
|
if (!ioCheckInoutService.checkManual(order.getBillNo())) {
|
|
|
|
|
ioCheckInoutService.check(order.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成盘盈入库单
|
|
|
|
@ -516,8 +537,14 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
warehouseEntity.setAction(order.getAction());
|
|
|
|
|
warehouseEntity.setCorpOrderId(order.getCorpOrderId());
|
|
|
|
|
});
|
|
|
|
|
orderDao.insert(order);
|
|
|
|
|
orderService.insertOrder(order);
|
|
|
|
|
codesTempDao.insertBatch(profitCodesList);
|
|
|
|
|
|
|
|
|
|
addInoutService.dealProcess(order);
|
|
|
|
|
if (!ioCheckInoutService.checkManual(order.getBillNo())) {
|
|
|
|
|
ioCheckInoutService.check(order.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -548,7 +575,9 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
warehouseEntity.setCount(invCountOrderDetail.getLossNum());
|
|
|
|
|
warehouseEntity.setReCount(invCountOrderDetail.getLossNum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
warehouseEntity.setCreateTime(new Date());
|
|
|
|
|
warehouseEntity.setUpdateTime(new Date());
|
|
|
|
|
warehouseEntity.setDeptCode(invCountOrder.getDeptCode());
|
|
|
|
|
return warehouseEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -632,11 +661,14 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
*/
|
|
|
|
|
public IoOrderEntity createOrder(InvCountSettingEntity invCountSettingEntity, InvCountOrderEntity invCountOrder, String type) {
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity;
|
|
|
|
|
|
|
|
|
|
BasicCorpEntity unitMaintainEntity = null;
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(type)) {
|
|
|
|
|
bussinessTypeEntity = basicBussinessTypeService.findByAction(invCountSettingEntity.getInAction());
|
|
|
|
|
bussinessTypeEntity = basicBussinessTypeService.findByAction(invCountSettingEntity.getInAction()); //查询单据往来单位数据
|
|
|
|
|
unitMaintainEntity = unitMaintainDao.selectByErpId(invCountSettingEntity.getInFromCorp());
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
bussinessTypeEntity = basicBussinessTypeService.findByAction(invCountSettingEntity.getOutAction());
|
|
|
|
|
unitMaintainEntity = unitMaintainDao.selectByErpId(invCountSettingEntity.getOutFromCorp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//构造单据数据
|
|
|
|
@ -645,14 +677,22 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
orderEntity.setAction(bussinessTypeEntity.getAction());
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setInvCode(invCountOrder.getInvStorageCode());
|
|
|
|
|
//查询单据往来单位数据
|
|
|
|
|
BasicCorpEntity unitMaintainEntity = unitMaintainDao.selectByErpId(bussinessTypeEntity.getDefaultUnit());
|
|
|
|
|
orderEntity.setFromCorp(unitMaintainEntity.getErpId());
|
|
|
|
|
if (unitMaintainEntity != null) {
|
|
|
|
|
orderEntity.setFromCorp(unitMaintainEntity.getErpId());
|
|
|
|
|
}
|
|
|
|
|
orderEntity.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
|
orderEntity.setExportStatus(0); //设置导出状态为未导出
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
|
|
|
orderEntity.setCreateUser(invCountOrder.getAuditUser());
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setUpdateUser(invCountOrder.getAuditUser());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setCustomerId("110");
|
|
|
|
|
orderEntity.setOrderType(2);
|
|
|
|
|
|
|
|
|
|
orderEntity.setFromType(ConstantStatus.FROM_COUNT); //单据来源设置为盘点单据转单
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
orderEntity.setBillNo(orderNo);
|
|
|
|
|
return orderEntity;
|
|
|
|
|
}
|
|
|
|
@ -666,4 +706,9 @@ public class InvCountOrderService extends ServiceImpl<InvCountOrderMapper, InvCo
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public InvCountOrderEntity selectByOrderId(String orderId) {
|
|
|
|
|
return invCountOrderDao.selectByOrderId(orderId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|