|
|
|
@ -15,15 +15,22 @@ import com.glxp.api.dao.basic.UdiRelevanceDao;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.SysWorkplaceDocumentEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrder;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderBiz;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderBizOrigin;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderOrigin;
|
|
|
|
|
import com.glxp.api.entity.collect.*;
|
|
|
|
|
import com.glxp.api.entity.inout.IoSplitCodeEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoSplitFifoInv;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderBizRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
|
import com.glxp.api.req.collect.IoCollectCodeRequest;
|
|
|
|
|
import com.glxp.api.res.collect.CollectOrderBizResponse;
|
|
|
|
|
import com.glxp.api.res.collect.IoCollectCodeResponse;
|
|
|
|
|
import com.glxp.api.service.basic.SysWorkplaceDocumentService;
|
|
|
|
|
import com.glxp.api.service.inout.IoSplitCodeService;
|
|
|
|
|
import com.glxp.api.service.inout.IoSplitFifoInvService;
|
|
|
|
|
import com.glxp.api.util.BeanCopyUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.aspectj.weaver.ast.Var;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@ -56,6 +63,23 @@ public class IoCollectOriginService {
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCollectCodeBackService ioCollectCodeBackService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCollectOrderBackupService ioCollectOrderBackupService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoCollectOrderBizBackupService ioCollectOrderBizBackupService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoSplitCodeService splitCodeService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IoSplitFifoInvService splitFifoInvService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseResponse downloadOrderV2(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
//条件
|
|
|
|
|
String busType = collectOrderRequest.getBusType();
|
|
|
|
@ -211,4 +235,221 @@ public class IoCollectOriginService {
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse submitreturnOrder(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
if (StrUtil.isBlank(collectOrderRequest.getBillNo())) {
|
|
|
|
|
return ResultVOUtils.error(500, "单据号不能为空");
|
|
|
|
|
}
|
|
|
|
|
IoCollectOrderOrigin collectOrder = collectOrderOriginService.getByBillNo(collectOrderRequest.getBillNo());
|
|
|
|
|
//已完成处方单据
|
|
|
|
|
IoCollectOrderBackup prescriptionOrder = ioCollectOrderBackupService.getByBillNo(collectOrder.getRemark());
|
|
|
|
|
if (collectOrder == null) {
|
|
|
|
|
return ResultVOUtils.error(500, "未找到单据");
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isBlank(collectOrderRequest.getBusType())) {
|
|
|
|
|
return ResultVOUtils.error(500, "单据类型不能为空");
|
|
|
|
|
}
|
|
|
|
|
// collectOrder.setRemark("36351637");
|
|
|
|
|
//订单已经存在 如果后端 需要是否含有 处方号 没有的话返回错误
|
|
|
|
|
if (StrUtil.isBlank(collectOrder.getRemark())){
|
|
|
|
|
return ResultVOUtils.error(500, "退货处方单号为空");
|
|
|
|
|
}
|
|
|
|
|
CollectOrderBizRequest collectOrderBizRequest = new CollectOrderBizRequest();
|
|
|
|
|
collectOrderBizRequest.setOrderIdFk(collectOrder.getBillNo());
|
|
|
|
|
List<CollectOrderBizResponse> collectOrderBizResponses = collectOrderBizOriginService.filterList(collectOrderBizRequest);
|
|
|
|
|
String orginOrder = collectOrder.getRemark();
|
|
|
|
|
ArrayList<IoCollectCodeBackup> ioCollectCodeBackups = new ArrayList<>();
|
|
|
|
|
// 获取已完成处方码明细
|
|
|
|
|
for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponses){
|
|
|
|
|
//退货产品
|
|
|
|
|
IoCollectCodeRequest ioCollectCodeRequest = new IoCollectCodeRequest();
|
|
|
|
|
ioCollectCodeRequest.setBillNo(orginOrder);
|
|
|
|
|
ioCollectCodeRequest.setRelId(collectOrderBizResponse.getRelId());
|
|
|
|
|
List<IoCollectCodeResponse> ioCollectCodeResponses = ioCollectCodeBackService.filterList(ioCollectCodeRequest);
|
|
|
|
|
if (ioCollectCodeResponses.isEmpty()){
|
|
|
|
|
return ResultVOUtils.error(500,"码明细为空");
|
|
|
|
|
}
|
|
|
|
|
//码明细
|
|
|
|
|
for(IoCollectCodeResponse ioCollectCodeResponse : ioCollectCodeResponses){
|
|
|
|
|
//拆零码
|
|
|
|
|
if (ioCollectCodeResponse.getIsSplitCode() == 1){
|
|
|
|
|
//退回拆零码
|
|
|
|
|
IoSplitCodeEntity splitCode = splitCodeService.getOne(new LambdaQueryWrapper<IoSplitCodeEntity>().eq(IoSplitCodeEntity::getCode, ioCollectCodeResponse.getCode()));
|
|
|
|
|
//拆零码存在直接加库存
|
|
|
|
|
if (splitCode != null){
|
|
|
|
|
splitCode.setRemainCount(splitCode.getRemainCount() + ioCollectCodeResponse.getReCount());
|
|
|
|
|
splitCode.setUpdateTime(new Date());
|
|
|
|
|
splitCodeService.updateById(splitCode);
|
|
|
|
|
} else {
|
|
|
|
|
//不存在的话 插入
|
|
|
|
|
IoSplitCodeEntity splitCode1 = new IoSplitCodeEntity();
|
|
|
|
|
splitCode1.setCode(ioCollectCodeResponse.getCode());
|
|
|
|
|
splitCode1.setAction(collectOrder.getBusType());
|
|
|
|
|
splitCode1.setRemainCount(ioCollectCodeResponse.getReCount());
|
|
|
|
|
splitCode1.setScanCount(1);
|
|
|
|
|
splitCode1.setScanCount(1);
|
|
|
|
|
splitCode1.setStatus(2);
|
|
|
|
|
splitCode1.setOrderId(collectOrder.getBillNo());
|
|
|
|
|
splitCode1.setCreateTime(new Date());
|
|
|
|
|
splitCode1.setUpdateTime(new Date());
|
|
|
|
|
splitCode1.setUnpackTime(new Date());
|
|
|
|
|
splitCode1.setUnpackExpireTime(new Date());
|
|
|
|
|
splitCode1.setRelId(Long.valueOf(ioCollectCodeResponse.getRelId()));
|
|
|
|
|
splitCode1.setNameCode(ioCollectCodeResponse.getNameCode());
|
|
|
|
|
splitCode1.setSerialNo(ioCollectCodeResponse.getSerialNo());
|
|
|
|
|
splitCode1.setProduceDate(ioCollectCodeResponse.getProductDate());
|
|
|
|
|
splitCode1.setExpireDate(ioCollectCodeResponse.getExpireDate());
|
|
|
|
|
splitCodeService.save(splitCode1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//库存加码明细
|
|
|
|
|
// IoSplitFifoInv invServiceOne = splitFifoInvService.getOne(new LambdaQueryWrapper<IoSplitFifoInv>().eq(IoSplitFifoInv::getRelId, ioCollectCodeResponse.getRelId()));
|
|
|
|
|
// if (invServiceOne == null){
|
|
|
|
|
// throw new JsonException(500,"当前产品库存不村子啊");
|
|
|
|
|
// }
|
|
|
|
|
// invServiceOne.setAvailableCount(invServiceOne.getAvailableCount() + ioCollectCodeResponse.getReCount());
|
|
|
|
|
// invServiceOne.setReCount(invServiceOne.getReCount() + ioCollectCodeResponse.getReCount());
|
|
|
|
|
//// invServiceOne.setInCount(invServiceOne.getInCount() + ioCollectCodeResponse.getReCount());
|
|
|
|
|
// invServiceOne.setOutCount(invServiceOne.getOutCount() - ioCollectCodeResponse.getReCount());
|
|
|
|
|
// invServiceOne.setUpdateTime(new Date());
|
|
|
|
|
// splitFifoInvService.updateById(invServiceOne);
|
|
|
|
|
// /**
|
|
|
|
|
// * 赋码方式 1:自动拆零赋码;2:自动整取赋码;3.手动整取赋码,4.手动拆零赋码
|
|
|
|
|
// */
|
|
|
|
|
// if (ioCollectCodeResponse.getFifoSplit() == 1 || ioCollectCodeResponse.getFifoSplit() == 4){
|
|
|
|
|
// //拆零
|
|
|
|
|
//
|
|
|
|
|
// }else {
|
|
|
|
|
// //整取
|
|
|
|
|
// }
|
|
|
|
|
IoCollectCodeBackup collectCodeBackup = new IoCollectCodeBackup();
|
|
|
|
|
BeanUtils.copyProperties(ioCollectCodeResponse,collectCodeBackup);
|
|
|
|
|
collectCodeBackup.setBillNo(collectOrder.getBillNo());
|
|
|
|
|
collectCodeBackup.setId(null);
|
|
|
|
|
collectCodeBackup.setBusType(collectOrder.getBusType());
|
|
|
|
|
collectCodeBackup.setRelId(Long.valueOf(ioCollectCodeResponse.getRelId()));
|
|
|
|
|
ioCollectCodeBackups.add(collectCodeBackup);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ioCollectCodeBackService.saveBatch(ioCollectCodeBackups);
|
|
|
|
|
//删除单据
|
|
|
|
|
IoCollectOrder ioCollectOrder = collectOrderService.getByBillNo(collectOrder.getBillNo());
|
|
|
|
|
IoCollectOrderBackup orderBackup = new IoCollectOrderBackup();
|
|
|
|
|
BeanUtils.copyProperties(ioCollectOrder, orderBackup);
|
|
|
|
|
orderBackup.setTagStatus(3);
|
|
|
|
|
orderBackup.setWorkPlaceCode(prescriptionOrder.getWorkPlaceCode());
|
|
|
|
|
ioCollectOrderBackupService.save(orderBackup);
|
|
|
|
|
List<IoCollectOrderBiz> ioCollectOrderBizs = collectOrderBizService.listByBillNo(ioCollectOrder.getBillNo());
|
|
|
|
|
ArrayList<IoCollectOrderBizBackup> ioCollectOrderBizBackups = new ArrayList<>();
|
|
|
|
|
for (IoCollectOrderBiz ioCollectOrderBiz : ioCollectOrderBizs){
|
|
|
|
|
IoCollectOrderBizBackup ioCollectOrderBizBackup = new IoCollectOrderBizBackup();
|
|
|
|
|
BeanUtils.copyProperties(ioCollectOrderBiz,ioCollectOrderBizBackup);
|
|
|
|
|
ioCollectOrderBizBackup.setId(null);
|
|
|
|
|
ioCollectOrderBizBackups.add(ioCollectOrderBizBackup);
|
|
|
|
|
}
|
|
|
|
|
collectOrder.setTagStatus(3);
|
|
|
|
|
collectOrderOriginService.updateById(collectOrder);
|
|
|
|
|
ioCollectOrderBizBackupService.saveBatch(ioCollectOrderBizBackups);
|
|
|
|
|
collectOrderService.removeOrderByBillNo(ioCollectOrder);
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
// public BaseResponse errorHandleSubmit(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
// if (StrUtil.isBlank(collectOrderRequest.getBillNo())) {
|
|
|
|
|
// throw new JsonException(500, "单据号不能为空");
|
|
|
|
|
// }
|
|
|
|
|
//// if (collectOrderRequest.getTagStatus() != 4) {
|
|
|
|
|
//// throw new JsonException(500, "非异常单据,无需处理");
|
|
|
|
|
//// }
|
|
|
|
|
// if (StrUtil.isBlank(collectOrderRequest.getBusType())) {
|
|
|
|
|
// throw new JsonException(500, "单据类型不能为空");
|
|
|
|
|
// }
|
|
|
|
|
// String billNo = collectOrderRequest.getBillNo();
|
|
|
|
|
// List<IoCollectOrderOrigin> thrOrderEntities = collectOrderOriginService.list(new LambdaUpdateWrapper<IoCollectOrderOrigin>().eq(IoCollectOrderOrigin::getBillNo, billNo));
|
|
|
|
|
//
|
|
|
|
|
// if (CollUtil.isNotEmpty(thrOrderEntities)) {
|
|
|
|
|
// for (IoCollectOrderOrigin thrOrder : thrOrderEntities) {
|
|
|
|
|
// IoCollectOrder ioCollectOrder = new IoCollectOrder();
|
|
|
|
|
// BeanUtil.copyProperties(thrOrder, ioCollectOrder);
|
|
|
|
|
// StringBuilder errorMsg = new StringBuilder();
|
|
|
|
|
// List<IoCollectOrderBiz> bizList = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// List<IoCollectOrderBizOrigin> list = collectOrderBizOriginService.list(new LambdaUpdateWrapper<IoCollectOrderBizOrigin>().eq(IoCollectOrderBizOrigin::getOrderIdFk, thrOrder.getBillNo()));
|
|
|
|
|
// for (IoCollectOrderBizOrigin entity : list) {
|
|
|
|
|
// IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
|
|
|
|
|
// BeanUtil.copyProperties(entity, collectOrderBiz);
|
|
|
|
|
//
|
|
|
|
|
// if (BusTypeConstant.QXCF001.getBusType().equals(collectOrderRequest.getBusType())){
|
|
|
|
|
// collectOrderBiz.setRelId(entity.getRelId());
|
|
|
|
|
// BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getYbbm, entity.getYbbm()).last("limit 1"));
|
|
|
|
|
// if (StrUtil.isEmpty(basicProductsEntity.getNameCode())) {
|
|
|
|
|
// errorMsg.append(entity.getCpmctymc()).append("字典未对照").append(";");
|
|
|
|
|
// }
|
|
|
|
|
// collectOrderBiz.setTagStatus(1);
|
|
|
|
|
// collectOrderBiz.setUnTagCount(0);
|
|
|
|
|
// bizList.add(collectOrderBiz);
|
|
|
|
|
//
|
|
|
|
|
// }else {
|
|
|
|
|
// UdiRelevanceEntity basicUdirelEntity = udiRelevanceDao.selectOne(new LambdaQueryWrapper<UdiRelevanceEntity>().eq(UdiRelevanceEntity::getMainId, entity.getThrCode()));
|
|
|
|
|
// if (basicUdirelEntity != null) {
|
|
|
|
|
// collectOrderBiz.setRelId(basicUdirelEntity.getId());
|
|
|
|
|
// BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirelEntity.getUuid()).last("limit 1"));
|
|
|
|
|
// if (StrUtil.isEmpty(basicProductsEntity.getNameCode())) {
|
|
|
|
|
// errorMsg.append(entity.getCpmctymc()).append("字典未对照").append(";");
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// errorMsg.append(entity.getCpmctymc()).append("字典未对照").append(";");
|
|
|
|
|
// }
|
|
|
|
|
// collectOrderBiz.setTagStatus(1);
|
|
|
|
|
// collectOrderBiz.setUnTagCount(0);
|
|
|
|
|
// bizList.add(collectOrderBiz);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (StrUtil.isNotEmpty(errorMsg)) {
|
|
|
|
|
// thrOrder.setTagStatus(4);
|
|
|
|
|
// thrOrder.setErrorMsg(errorMsg.toString());
|
|
|
|
|
// collectOrderOriginService.updateById(thrOrder);
|
|
|
|
|
//
|
|
|
|
|
// List<IoCollectOrderBizOrigin> ioCollectOrderBizOrigins = BeanCopyUtils.copyList(bizList, IoCollectOrderBizOrigin.class);
|
|
|
|
|
// collectOrderBizOriginService.updateBatchById(ioCollectOrderBizOrigins);
|
|
|
|
|
// }else {
|
|
|
|
|
// thrOrder.setTagStatus(2);
|
|
|
|
|
// collectOrderOriginService.updateById(thrOrder);
|
|
|
|
|
//
|
|
|
|
|
// List<IoCollectOrderBizOrigin> ioCollectOrderBizOrigins = BeanCopyUtils.copyList(bizList, IoCollectOrderBizOrigin.class);
|
|
|
|
|
// collectOrderBizOriginService.updateBatchById(ioCollectOrderBizOrigins);
|
|
|
|
|
//
|
|
|
|
|
// //删除
|
|
|
|
|
// collectOrderService.remove(new LambdaQueryWrapper<IoCollectOrder>().eq(IoCollectOrder::getBillNo, billNo));
|
|
|
|
|
// //更改 原始单据表 为未处理
|
|
|
|
|
// collectOrderBizService.remove(new LambdaUpdateWrapper<IoCollectOrderBiz>().eq(IoCollectOrderBiz::getOrderIdFk, billNo));
|
|
|
|
|
//
|
|
|
|
|
// for (IoCollectOrderBiz ioCollectOrderBiz : bizList) {
|
|
|
|
|
// ioCollectOrderBiz.setId(null);
|
|
|
|
|
// }
|
|
|
|
|
// //新增
|
|
|
|
|
// collectOrderBizService.saveBatch(bizList);
|
|
|
|
|
// ioCollectOrder.setFromType("HIS系统");
|
|
|
|
|
// ioCollectOrder.setWorkPlaceCode(collectOrderRequest.getWorkPlaceCode());
|
|
|
|
|
// ioCollectOrder.setCreateTime(new Date());
|
|
|
|
|
// ioCollectOrder.setCreateUser(collectOrderRequest.getCreateUser());
|
|
|
|
|
// ioCollectOrder.setBackupOrderRemark1(null);
|
|
|
|
|
// ioCollectOrder.setUpdateTime(new Date());
|
|
|
|
|
// ioCollectOrder.setSplitStatus(0);
|
|
|
|
|
// ioCollectOrder.setTagStatus(1);
|
|
|
|
|
// ioCollectOrder.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
//
|
|
|
|
|
// collectOrderService.save(ioCollectOrder);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// return ResultVOUtils.success("提交成功");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|