|
|
|
@ -29,20 +29,20 @@ import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRlSupService;
|
|
|
|
|
import com.glxp.api.service.inv.InvProductDetailService;
|
|
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.MsDateUtil;
|
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import com.glxp.api.util.*;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.glxp.api.constant.ConstantStatus.ORDER_STATUS_CHECK_PROCESS;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class IoAddInoutService {
|
|
|
|
|
|
|
|
|
@ -408,7 +408,7 @@ public class IoAddInoutService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端上传生成扫码单据
|
|
|
|
|
* 手持终端-----新增出入库单据
|
|
|
|
|
*
|
|
|
|
|
* @param pdaPostOrderRequest
|
|
|
|
|
* @return
|
|
|
|
@ -438,112 +438,141 @@ public class IoAddInoutService {
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("单据上传成功!");
|
|
|
|
|
|
|
|
|
|
// List<PostOrderRequest.PostOrder> postOrders = postOrderRequest.getPostOrders();
|
|
|
|
|
// if (postOrders != null && postOrders.size() > 0) {
|
|
|
|
|
// for (int i = 0; i < postOrders.size(); i++) {
|
|
|
|
|
// PostOrderRequest.PostOrder postOrder = postOrders.get(i);
|
|
|
|
|
// //创建单据
|
|
|
|
|
// PdaOrderEntity pdaOrderEntity = postOrder.getOrderBean();
|
|
|
|
|
// IoOrderEntity orderEntity = null;
|
|
|
|
|
// if (StrUtil.isNotEmpty(pdaOrderEntity.getDocid())) {
|
|
|
|
|
// orderEntity = orderService.findByBillNo(pdaOrderEntity.getDocid());
|
|
|
|
|
// }
|
|
|
|
|
// if (orderEntity != null) {
|
|
|
|
|
// //已包含业务单据校验
|
|
|
|
|
// orderEntity.setUpdateUser(postOrderRequest.getUserId() + "");
|
|
|
|
|
// orderEntity.setUpdateTime(new Date());
|
|
|
|
|
// orderService.update(orderEntity);
|
|
|
|
|
// List<PdaCodeEntity> pdaCodeEntities = postOrder.getCodes();
|
|
|
|
|
// if (pdaCodeEntities != null && pdaCodeEntities.size() > 0) {
|
|
|
|
|
// PdaCodeEntity pdaCodeEntity = pdaCodeEntities.get(0);
|
|
|
|
|
// //写入条码
|
|
|
|
|
// List<IoCodeTempEntity> ioCodeEnttities = new ArrayList<>();
|
|
|
|
|
// for (int index = 0; index < pdaCodeEntities.size(); index++) {
|
|
|
|
|
// IoCodeTempEntity codeEnttity = new IoCodeTempEntity();
|
|
|
|
|
// BeanUtil.copyProperties(pdaCodeEntities.get(index), codeEnttity);
|
|
|
|
|
// codeEnttity.setAction(orderEntity.getAction());
|
|
|
|
|
// codeEnttity.setMainAction(orderEntity.getMainAction());
|
|
|
|
|
// codeEnttity.setDeptCode(orderEntity.getDeptCode());
|
|
|
|
|
// codeEnttity.setOrderId(orderEntity.getBillNo());
|
|
|
|
|
// codeEnttity.setInvCode(orderEntity.getInvCode());
|
|
|
|
|
// codeEnttity.setReCount(codeEnttity.getCount() * udiCalCountUtil.getActCount(codeEnttity.getNameCode()));
|
|
|
|
|
// codeEnttity.setUpdateTime(new Date());
|
|
|
|
|
// codeEnttity.setCreateTime(MsDateUtil.parseDate(pdaCodeEntity.getActDate()));
|
|
|
|
|
// ioCodeEnttities.add(codeEnttity);
|
|
|
|
|
// }
|
|
|
|
|
// codeTempService.insertBatch(ioCodeEnttities);
|
|
|
|
|
// dealProcess(orderEntity);
|
|
|
|
|
// if (!ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
// ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// //创建新单据
|
|
|
|
|
// BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(pdaOrderEntity.getType());
|
|
|
|
|
// String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
// IoOrderEntity orderSaveRequest = new IoOrderEntity();
|
|
|
|
|
// orderSaveRequest.setBillNo(orderNo);
|
|
|
|
|
// orderSaveRequest.setMainAction(pdaOrderEntity.getInout());
|
|
|
|
|
// orderSaveRequest.setAction(pdaOrderEntity.getType());
|
|
|
|
|
// orderSaveRequest.setCorpOrderId(pdaOrderEntity.getOrder());
|
|
|
|
|
// orderSaveRequest.setFromCorp(pdaOrderEntity.getFromCorpID());
|
|
|
|
|
// orderSaveRequest.setCustomerId(postOrderRequest.getCustomerId());
|
|
|
|
|
// orderSaveRequest.setFromDeptCode(pdaOrderEntity.getFromDeptCode());
|
|
|
|
|
// orderSaveRequest.setFromInvCode(pdaOrderEntity.getFromInvCode());
|
|
|
|
|
// orderSaveRequest.setDeptCode(pdaOrderEntity.getDeptCode());
|
|
|
|
|
// orderSaveRequest.setInvCode(pdaOrderEntity.getInvCode());
|
|
|
|
|
// orderSaveRequest.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
|
|
|
|
|
// orderSaveRequest.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
// orderSaveRequest.setCreateUser(postOrderRequest.getUserId() + "");
|
|
|
|
|
// orderSaveRequest.setUpdateUser(postOrderRequest.getUserId() + "");
|
|
|
|
|
// orderSaveRequest.setUpdateTime(new Date());
|
|
|
|
|
// orderSaveRequest.setBusType(bussinessTypeEntity.getBusType());
|
|
|
|
|
// orderSaveRequest.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);
|
|
|
|
|
// if (postOrder.getErpOrders() != null && postOrder.getErpOrders().size() > 0)
|
|
|
|
|
// orderSaveRequest.setFromType(ConstantStatus.FROM_PDAED);
|
|
|
|
|
// else
|
|
|
|
|
// orderSaveRequest.setFromType(ConstantStatus.FROM_PDAUN);
|
|
|
|
|
// List<PdaCodeEntity> pdaCodeEntities = postOrder.getCodes();
|
|
|
|
|
// if (pdaCodeEntities != null && pdaCodeEntities.size() > 0) {
|
|
|
|
|
// PdaCodeEntity pdaCodeEntity = pdaCodeEntities.get(0);
|
|
|
|
|
// if (pdaCodeEntity.getActDate() != null) {
|
|
|
|
|
// orderSaveRequest.setCreateTime(MsDateUtil.parseDate(pdaCodeEntity.getActDate()));
|
|
|
|
|
// }
|
|
|
|
|
// //写入条码
|
|
|
|
|
// List<IoCodeTempEntity> ioCodeEnttities = new ArrayList<>();
|
|
|
|
|
// for (int index = 0; index < pdaCodeEntities.size(); index++) {
|
|
|
|
|
// IoCodeTempEntity codeEnttity = new IoCodeTempEntity();
|
|
|
|
|
// BeanUtil.copyProperties(pdaCodeEntities.get(index), codeEnttity);
|
|
|
|
|
// codeEnttity.setAction(orderSaveRequest.getAction());
|
|
|
|
|
// codeEnttity.setMainAction(orderSaveRequest.getMainAction());
|
|
|
|
|
// codeEnttity.setDeptCode(orderSaveRequest.getDeptCode());
|
|
|
|
|
// codeEnttity.setOrderId(orderSaveRequest.getBillNo());
|
|
|
|
|
// codeEnttity.setInvCode(orderSaveRequest.getInvCode());
|
|
|
|
|
// codeEnttity.setReCount(codeEnttity.getCount() * udiCalCountUtil.getActCount(codeEnttity.getNameCode()));
|
|
|
|
|
// codeEnttity.setUpdateTime(new Date());
|
|
|
|
|
// codeEnttity.setCreateTime(MsDateUtil.parseDate(pdaCodeEntity.getActDate()));
|
|
|
|
|
// ioCodeEnttities.add(codeEnttity);
|
|
|
|
|
// }
|
|
|
|
|
// codeTempService.insertBatch(ioCodeEnttities);
|
|
|
|
|
// }
|
|
|
|
|
// orderService.insertOrder(orderSaveRequest);
|
|
|
|
|
// dealProcess(orderSaveRequest);
|
|
|
|
|
// if (!ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
// ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待配货,待校验单据提交
|
|
|
|
|
* 手持终端-----待配货(无三期,有三期)单据提交
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse waitOrderByPda(PdaPostOrderRequest pdaPostOrderRequest) {
|
|
|
|
|
if (CollUtil.isEmpty(pdaPostOrderRequest.getOrderDetailCodeEntities())) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,单据还未扫码或和扫码校验存在异常!");
|
|
|
|
|
}
|
|
|
|
|
IoOrderEntity orderEntity = pdaPostOrderRequest.getOrderEntity();
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = pdaPostOrderRequest.getOrderDetailBizEntities();
|
|
|
|
|
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = pdaPostOrderRequest.getOrderDetailCodeEntities();
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = pdaPostOrderRequest.getCodeTempEntities();
|
|
|
|
|
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
orderDetailCodeService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
codeTempService.deleteByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
orderDetailBizEntities.forEach(orderDetailBizEntity -> {
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailCodeEntities)) {
|
|
|
|
|
orderDetailCodeEntities.forEach(orderDetailCodeEntity -> {
|
|
|
|
|
orderDetailCodeService.insert(orderDetailCodeEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(codeTempEntities)) {
|
|
|
|
|
codeTempEntities.forEach(codeTempEntity -> {
|
|
|
|
|
codeTempService.insert(codeTempEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
if (ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
if (bussinessTypeEntity.getCheckWebNew() == 1) {
|
|
|
|
|
String errMsg = ioCheckInoutService.bizOrderCheck(orderDetailBizEntities, orderDetailCodeEntities);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
errMsg = ioCheckInoutService.codeOrderCheck(orderDetailCodeEntities, orderDetailBizEntities);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
// saveOrderWeb(addOrderRequest);
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
String errMsg = ioCheckInoutService.bizNoPiCheck(orderDetailBizEntities, orderEntity);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
for (IoOrderDetailCodeEntity orderDetailCodeEntity : orderDetailCodeEntities) {
|
|
|
|
|
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
|
BeanUtil.copyProperties(orderDetailCodeEntity, orderDetailBizEntity);
|
|
|
|
|
orderDetailBizEntity.setId(null);
|
|
|
|
|
orderDetailBizEntity.setCount(IntUtil.value(orderDetailCodeEntity.getReCount()));
|
|
|
|
|
ioCheckInoutService.getSomeBiz(orderDetailBizEntities, orderDetailBizEntity);
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
}
|
|
|
|
|
// saveOrderWeb(addOrderRequest);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error(500, "单据校验提交失败,请先录入业务单据!");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端------扫码结果提交
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse checkCodeResultByPda(Integer checkWebNewType, PdaPostOrderRequest pdaPostOrderRequest) {
|
|
|
|
|
|
|
|
|
|
IoOrderEntity orderEntity = pdaPostOrderRequest.getOrderEntity();
|
|
|
|
|
IoOrderEntity temp = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
|
|
BaseResponse tempResponse = checkSubmitEnable(temp);
|
|
|
|
|
if (tempResponse != null)
|
|
|
|
|
return tempResponse;
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = pdaPostOrderRequest.getOrderDetailBizEntities();
|
|
|
|
|
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = pdaPostOrderRequest.getOrderDetailCodeEntities();
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = pdaPostOrderRequest.getCodeTempEntities();
|
|
|
|
|
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
orderDetailCodeService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
codeTempService.deleteByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
orderDetailBizEntities.forEach(orderDetailBizEntity -> {
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailCodeEntities)) {
|
|
|
|
|
orderDetailCodeEntities.forEach(orderDetailCodeEntity -> {
|
|
|
|
|
orderDetailCodeService.insert(orderDetailCodeEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(codeTempEntities)) {
|
|
|
|
|
codeTempEntities.forEach(codeTempEntity -> {
|
|
|
|
|
codeTempService.insert(codeTempEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
|
|
|
|
|
if (checkWebNewType == 0) {
|
|
|
|
|
ioCheckInoutService.checkCodeResult(orderEntity.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
ioCheckInoutService.checkRightResult(orderEntity.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -729,4 +758,41 @@ public class IoAddInoutService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 临床出库时更新往来单位信息
|
|
|
|
|
*/
|
|
|
|
|
public String updateCorp(BasicBussinessTypeEntity bussinessTypeEntity, String fromCorp) {
|
|
|
|
|
BasicCorpEntity basicCorpEntity;
|
|
|
|
|
//要是特殊往来信息没有就创建
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT && bussinessTypeEntity.isGenUnit()) {
|
|
|
|
|
basicCorpEntity = basicCorpService.selectByName(fromCorp);
|
|
|
|
|
if (basicCorpEntity == null) {
|
|
|
|
|
basicCorpEntity = new BasicCorpEntity();
|
|
|
|
|
basicCorpEntity.setErpId(CustomUtil.getUnitId());
|
|
|
|
|
basicCorpEntity.setCorpType(ConstantStatus.CORP_SICK);
|
|
|
|
|
basicCorpEntity.setOutType(ConstantStatus.CORP_SICK_SICK);
|
|
|
|
|
basicCorpEntity.setName(fromCorp);
|
|
|
|
|
basicCorpEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
basicCorpService.insert(basicCorpEntity);
|
|
|
|
|
}
|
|
|
|
|
return basicCorpEntity.getErpId();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return fromCorp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseResponse checkSubmitEnable(IoOrderEntity orderEntity) {
|
|
|
|
|
if (orderEntity == null) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,请先添加物资!");
|
|
|
|
|
}
|
|
|
|
|
if (orderEntity.getStatus() == ORDER_STATUS_CHECK_PROCESS || orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_PROCESS
|
|
|
|
|
|| orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_PROCESSING) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,单据正在处理,请稍后刷新查看!");
|
|
|
|
|
}
|
|
|
|
|
if (orderEntity.getStatus() != 1 && orderEntity.getStatus() != 3 && orderEntity.getStatus() != 4 && orderEntity.getStatus() != 6) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,单据已提交,请稍后刷新查看!");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|