|
|
|
@ -2,24 +2,31 @@ package com.glxp.api.service.collect;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.dao.collect.IoCollectOrderMapper;
|
|
|
|
|
import com.glxp.api.dao.inout.IoCodeTempDao;
|
|
|
|
|
import com.glxp.api.entity.auth.SysWorkplace;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicCollectBustypeEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.SysWorkplaceDocumentEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrder;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderBiz;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderCodeAuto;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderCodeMan;
|
|
|
|
|
import com.glxp.api.entity.inout.IoCodeTempEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.inv.InvCountOrderDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.inv.InvCountOrderEntity;
|
|
|
|
|
import com.glxp.api.entity.inv.InvCountSettingEntity;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
|
import com.glxp.api.req.basic.FilterUdiRelRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderBizRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
|
import com.glxp.api.req.inout.DeleteTageCodeRequest;
|
|
|
|
@ -31,14 +38,12 @@ import com.glxp.api.res.collect.IoCollectOrderResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoOrderResponse;
|
|
|
|
|
import com.glxp.api.service.auth.SysWorkplaceService;
|
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
|
import com.glxp.api.service.inout.IoCodeTempService;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
|
import com.glxp.api.service.inout.IoSplitFifoCodeService;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.service.inout.impl.IoCodeService;
|
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
|
import com.glxp.api.util.MsDateUtil;
|
|
|
|
|
import com.glxp.api.util.*;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@ -77,6 +82,12 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
SysWorkplaceDocumentService sysWorkplaceDocumentService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoSplitFifoCodeService splitFifoCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderCodeAutoService collectOrderCodeAutoService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderCodeManService collectOrderCodeManService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectCodeService collectCodeService;
|
|
|
|
|
|
|
|
|
|
public IoCollectOrder getByBillNo(String billNo) {
|
|
|
|
|
return collectOrderMapper.selectOne(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, billNo).last("limit 1"));
|
|
|
|
@ -99,10 +110,6 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderCodeAutoService collectOrderCodeAutoService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderCodeManService collectOrderCodeManService;
|
|
|
|
|
|
|
|
|
|
public List<CollectOrderBizResponse> combieOrderDetail(CollectOrderBizRequest collectOrderBizRequest) {
|
|
|
|
|
List<CollectOrderBizResponse> list = collectOrderBizService.filterList(collectOrderBizRequest);
|
|
|
|
@ -467,4 +474,115 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
.eq(IoCollectOrder::getId, collectOrderRequest.getId()).update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void finishOrder(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
IoCollectOrder collectOrder = new IoCollectOrder();
|
|
|
|
|
BeanUtils.copyProperties(collectOrderRequest, collectOrder);
|
|
|
|
|
collectOrder.setTagStatus(3);
|
|
|
|
|
collectOrder.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
|
|
updateByBillNo(collectOrder);
|
|
|
|
|
|
|
|
|
|
ThreadUtil.execAsync(() -> {
|
|
|
|
|
//插入到码表
|
|
|
|
|
collectCodeService.insertCodesByBill(collectOrderRequest.getBillNo());
|
|
|
|
|
|
|
|
|
|
//更新数据至第三方系统
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IBasicBussinessTypeService bussinessTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
private GennerOrderUtils gennerOrderUtils;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCodeTempDao codesTempDao;
|
|
|
|
|
@Resource
|
|
|
|
|
IoAddInoutService addInoutService;
|
|
|
|
|
@Resource
|
|
|
|
|
@Lazy
|
|
|
|
|
IoCheckInoutService ioCheckInoutService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param billNo
|
|
|
|
|
*/
|
|
|
|
|
private void generateOrder(String billNo) {
|
|
|
|
|
|
|
|
|
|
IoCollectOrder collectOrder = getByBillNo(billNo);
|
|
|
|
|
SysWorkplaceDocumentEntity sysWorkplaceDocumentEntity = sysWorkplaceDocumentService.findByWorkplaceCode(collectOrder.getWorkPlaceCode(), collectOrder.getBusType());
|
|
|
|
|
//1.内部系统,且单据为扫码生成业务单则创建系统单据
|
|
|
|
|
if (IntUtil.value(sysWorkplaceDocumentEntity.getIsMatching()) == 1 && sysWorkplaceDocumentEntity.getScanType() == 1) {
|
|
|
|
|
List<IoCollectOrderCodeMan> collectOrderCodes = collectOrderCodeManService.listByBillNo(collectOrder.getBillNo());
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity;
|
|
|
|
|
sysWorkplaceDocumentEntity.getInoutType();
|
|
|
|
|
|
|
|
|
|
//构造单据数据
|
|
|
|
|
IoOrderEntity orderEntity = new IoOrderEntity();
|
|
|
|
|
bussinessTypeEntity = bussinessTypeService.findByAction(sysWorkplaceDocumentEntity.getDocumentTypeCode());
|
|
|
|
|
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
|
|
|
|
|
orderEntity.setAction(bussinessTypeEntity.getAction());
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setInvCode(sysWorkplaceDocumentEntity.getInvCode() + "");
|
|
|
|
|
orderEntity.setDeptCode("");
|
|
|
|
|
orderEntity.setFromCorp(collectOrder.getFromCorp());
|
|
|
|
|
orderEntity.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
|
orderEntity.setExportStatus(0);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
|
|
|
orderEntity.setCreateUser(collectOrder.getCreateUser());
|
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
|
orderEntity.setUpdateUser(collectOrder.getCreateUser());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setCustomerId("110");
|
|
|
|
|
orderEntity.setOrderType(2);
|
|
|
|
|
orderEntity.setFromType(2);
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
orderEntity.setBillNo(orderNo);
|
|
|
|
|
List<IoCodeTempEntity> lossCodesList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (IoCollectOrderCodeMan collectOrderCodeMan : collectOrderCodes) {
|
|
|
|
|
lossCodesList.add(buildCodeEntity(collectOrderCodeMan, orderEntity));
|
|
|
|
|
}
|
|
|
|
|
orderService.insertOrder(orderEntity);
|
|
|
|
|
codesTempDao.insertBatch(lossCodesList);
|
|
|
|
|
addInoutService.dealProcess(orderEntity);
|
|
|
|
|
if (!ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
} else if (IntUtil.value(sysWorkplaceDocumentEntity.getIsMatching()) == 1 && sysWorkplaceDocumentEntity.getScanType() != 1) {
|
|
|
|
|
//更新单据为已完成
|
|
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(collectOrder.getBillNo());
|
|
|
|
|
orderEntity.setStatus(7);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
} else if (IntUtil.value(sysWorkplaceDocumentEntity.getIsMatching()) == 2) {
|
|
|
|
|
//todo 根据单据类型上传医保或者第三方系统
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IoCodeTempEntity buildCodeEntity(IoCollectOrderCodeMan collectOrderCodeMan, IoOrderEntity orderEntity) {
|
|
|
|
|
IoCodeTempEntity tempEntity = new IoCodeTempEntity();
|
|
|
|
|
tempEntity.setOrderId(orderEntity.getBillNo());
|
|
|
|
|
tempEntity.setCode(collectOrderCodeMan.getUdiCode());
|
|
|
|
|
tempEntity.setRelId(collectOrderCodeMan.getRelId());
|
|
|
|
|
tempEntity.setMainAction(orderEntity.getMainAction());
|
|
|
|
|
tempEntity.setInvCode(orderEntity.getInvCode());
|
|
|
|
|
tempEntity.setBatchNo(collectOrderCodeMan.getBatchNo());
|
|
|
|
|
tempEntity.setProduceDate(collectOrderCodeMan.getProductDate());
|
|
|
|
|
tempEntity.setExpireDate(collectOrderCodeMan.getExpireDate());
|
|
|
|
|
tempEntity.setSerialNo(collectOrderCodeMan.getSerialNo());
|
|
|
|
|
tempEntity.setNameCode(collectOrderCodeMan.getNameCode());
|
|
|
|
|
tempEntity.setCount(collectOrderCodeMan.getScanCount());
|
|
|
|
|
tempEntity.setReCount(collectOrderCodeMan.getScanCount());
|
|
|
|
|
tempEntity.setCreateTime(new Date());
|
|
|
|
|
tempEntity.setUpdateTime(new Date());
|
|
|
|
|
tempEntity.setDeptCode(orderEntity.getDeptCode());
|
|
|
|
|
return tempEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|