|
|
|
@ -34,6 +34,7 @@ import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.basic.MainIdRelIdAndProductResponse;
|
|
|
|
|
import com.glxp.api.res.inv.ThrInvResultResponse;
|
|
|
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.basic.ProductInfoService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
|
import com.glxp.api.service.basic.UdiRlSupService;
|
|
|
|
@ -310,6 +311,11 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
return thrInvOrderMapper.delete(uw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IBasicBussinessTypeService bussinessTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoAddInoutService addInoutService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean generateOrder(GenerateOrderRequest generateOrderRequest) {
|
|
|
|
|
String billNo = generateOrderRequest.getBillNo();
|
|
|
|
@ -329,39 +335,57 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
//校验单据的relId有null不生成单据
|
|
|
|
|
if (!inspectionDocuments(thrInvOrderDetails)) return false;
|
|
|
|
|
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
//todo 如果是患者收费明细需要根据患者进行分组拆单而且往来单位为患者信息
|
|
|
|
|
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
|
ioOrderEntity.setFromCorp(generateOrderRequest.getFromCorp());
|
|
|
|
|
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
|
|
|
|
|
ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
|
|
|
|
|
ioOrderEntity.setAction(generateOrderRequest.getAction());
|
|
|
|
|
|
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
|
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
|
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
|
|
|
|
|
ioOrderEntity.setCorpOrderId(billNo);//单据号
|
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findByAction(generateOrderRequest.getAction());
|
|
|
|
|
|
|
|
|
|
List<String> fromCorpList = new ArrayList<>();
|
|
|
|
|
Map<String, List<ThrInvOrderDetail>> grouped = new HashMap<>();
|
|
|
|
|
//往来类型为患者,则需要根据患者进行拆单
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT) {
|
|
|
|
|
|
|
|
|
|
grouped = thrInvOrderDetails.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(ThrInvOrderDetail::getSickerCode));
|
|
|
|
|
} else {
|
|
|
|
|
grouped.put(generateOrderRequest.getFromCorp(), thrInvOrderDetails);
|
|
|
|
|
}
|
|
|
|
|
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
|
|
|
|
|
//新单号
|
|
|
|
|
String newBillNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd"));
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
|
String fromCorp = addInoutService.updateCorp(bussinessTypeEntity, entry.getValue().get(0).getSickerName(), entry.getKey());
|
|
|
|
|
ioOrderEntity.setFromCorp(fromCorp);
|
|
|
|
|
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
|
|
|
|
|
ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
|
|
|
|
|
ioOrderEntity.setAction(generateOrderRequest.getAction());
|
|
|
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_WEBNEW);//网页新增
|
|
|
|
|
ioOrderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);//草稿
|
|
|
|
|
ioOrderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);//草稿
|
|
|
|
|
ioOrderEntity.setCorpOrderId(billNo);//单据号
|
|
|
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
|
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(grouped.values().size());
|
|
|
|
|
if (!copyOrderDetailBiz(entry.getValue(), newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
|
|
|
|
|
thrInvOrder.setUpdateTime(new Date());
|
|
|
|
|
thrInvOrder.setUpdateUser(userId + "");
|
|
|
|
|
thrInvOrderMapper.updateByPrimaryKey(thrInvOrder);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(thrInvOrderDetails.size());
|
|
|
|
|
if (!copyOrderDetailBiz(thrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
|
|
|
thrInvOrder.setStatus(ConstantStatus.SFIO_CFMD);//已确认
|
|
|
|
|
thrInvOrder.setUpdateTime(new Date());
|
|
|
|
|
thrInvOrder.setUpdateUser(userId + "");
|
|
|
|
|
thrInvOrderMapper.updateByPrimaryKey(thrInvOrder);
|
|
|
|
|
ioOrderDetailBizService.batchInsertBizs(newOrderDetailBiz);
|
|
|
|
|
|
|
|
|
|
// ioAddInoutService.stockGenScan(ioOrderEntity);
|
|
|
|
|
return true;
|
|
|
|
@ -636,7 +660,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param newOrderDetailBiz
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean copyOrderDetailBiz(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoOrderDetailBizEntity> newOrderDetailBiz, String newBillNo) {
|
|
|
|
|
private boolean copyOrderDetailBiz
|
|
|
|
|
(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoOrderDetailBizEntity> newOrderDetailBiz, String
|
|
|
|
|
newBillNo) {
|
|
|
|
|
List<Long> relIds = thrInvOrderDetails.stream().filter(x -> ObjectUtil.isNotNull(x.getRelId()))
|
|
|
|
|
.map(ThrInvOrderDetail::getRelId).collect(Collectors.toList());
|
|
|
|
|
List<BasicProductsEntity> basicProductsEntities = udiRelevanceDao.selectProductByRelIds(relIds);
|
|
|
|
@ -661,7 +687,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param newBillNo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean copyIoCodeTemps(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoCodeTempEntity> newIoCodeTemps, String newBillNo, GenerateOrderRequest generateOrderRequest) {
|
|
|
|
|
private boolean copyIoCodeTemps
|
|
|
|
|
(List<ThrInvOrderDetail> thrInvOrderDetails, List<IoCodeTempEntity> newIoCodeTemps, String
|
|
|
|
|
newBillNo, GenerateOrderRequest generateOrderRequest) {
|
|
|
|
|
|
|
|
|
|
thrInvOrderDetails.forEach(item -> {
|
|
|
|
|
IoCodeTempEntity ioCodeTempEntity = new IoCodeTempEntity();
|
|
|
|
@ -685,7 +713,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param basicProductsEntity
|
|
|
|
|
* @param ioOrderDetailBizEntity
|
|
|
|
|
*/
|
|
|
|
|
private void parameterPackag(BasicProductsEntity basicProductsEntity, IoOrderDetailBizEntity ioOrderDetailBizEntity, ThrInvOrderDetail thrInvOrderDetail) {
|
|
|
|
|
private void parameterPackag(BasicProductsEntity basicProductsEntity, IoOrderDetailBizEntity
|
|
|
|
|
ioOrderDetailBizEntity, ThrInvOrderDetail thrInvOrderDetail) {
|
|
|
|
|
ioOrderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
if (ObjectUtil.isNotNull(basicProductsEntity)) {
|
|
|
|
|
BeanUtils.copyProperties(basicProductsEntity, ioOrderDetailBizEntity);
|
|
|
|
@ -724,7 +753,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param thrInvOrder
|
|
|
|
|
* @param thrInvResultResponse
|
|
|
|
|
*/
|
|
|
|
|
private void handleExternalConvertThrInvOrder(String billNo, FilterInvProductRequest filterInvProductRequest, ThrInvOrder thrInvOrder, ThrInvResultResponse thrInvResultResponse, Integer SourceType) {
|
|
|
|
|
private void handleExternalConvertThrInvOrder(String billNo, FilterInvProductRequest
|
|
|
|
|
filterInvProductRequest, ThrInvOrder thrInvOrder, ThrInvResultResponse thrInvResultResponse, Integer SourceType) {
|
|
|
|
|
|
|
|
|
|
Date newDate = new Date();
|
|
|
|
|
thrInvOrder.setBillNo(billNo);//单据号
|
|
|
|
@ -751,7 +781,9 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
* @param thrInvOrderDetails
|
|
|
|
|
* @param billNo
|
|
|
|
|
*/
|
|
|
|
|
private void handleExternalConvertThrInvOrderDetail(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String thirdSys, ThrInvOrder thrInvOrder) {
|
|
|
|
|
private void handleExternalConvertThrInvOrderDetail
|
|
|
|
|
(List<ThrInvResultResponse> list, List<ThrInvOrderDetail> thrInvOrderDetails, String billNo, String
|
|
|
|
|
thirdSys, ThrInvOrder thrInvOrder) {
|
|
|
|
|
Integer inv_set_enable = Integer.valueOf(systemParamConfigService.selectValueByParamKey("inv_set_enable"));
|
|
|
|
|
if (inv_set_enable == null || inv_set_enable == 0) {//直接明细 不走项目组套
|
|
|
|
|
thrInvOrder.setSkProject(0);
|
|
|
|
|