|
|
|
@ -55,6 +55,7 @@ import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import com.glxp.api.util.udi.UdiCalCountUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.regexp.RE;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -135,14 +136,14 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
thrInvOrderMapper.insert(thrInvOrder);
|
|
|
|
|
thrInvOrderDetailMapper.insertBatch(thrInvOrderDetails);
|
|
|
|
|
|
|
|
|
|
//是否自动生成出入库单据
|
|
|
|
|
if (IntUtil.value(systemParamConfigService.selectValueByParamKey("fee_out_auto_gen")) > 0) {
|
|
|
|
|
GenerateOrderRequest generateOrderRequest = new GenerateOrderRequest();
|
|
|
|
|
generateOrderRequest.setBillNo(thrInvOrder.getBillNo());
|
|
|
|
|
generateOrderRequest.setAction(thrInvOrder.getBillType());
|
|
|
|
|
generateOrderRequest.setFromCorp(thrInvOrder.getFromCorp());
|
|
|
|
|
generateOrder(generateOrderRequest);
|
|
|
|
|
}
|
|
|
|
|
// //是否自动生成出入库单据
|
|
|
|
|
// if (IntUtil.value(systemParamConfigService.selectValueByParamKey("fee_out_auto_gen")) > 0) {
|
|
|
|
|
// GenerateOrderRequest generateOrderRequest = new GenerateOrderRequest();
|
|
|
|
|
// generateOrderRequest.setBillNo(thrInvOrder.getBillNo());
|
|
|
|
|
// generateOrderRequest.setAction(thrInvOrder.getBillType());
|
|
|
|
|
// generateOrderRequest.setFromCorp(thrInvOrder.getFromCorp());
|
|
|
|
|
// generateOrder(generateOrderRequest);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -930,7 +931,6 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除原来的明细
|
|
|
|
@ -949,22 +949,39 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
if (CollectionUtil.isNotEmpty(updateThrInvOrderDetails)) {
|
|
|
|
|
thrInvOrderDetailMapper.updateBatchById(updateThrInvOrderDetails);
|
|
|
|
|
}
|
|
|
|
|
genOrder(newBillNo, updateThrInvOrderDetails, addThrInvOrderDetails, thrInvOrder, bussinessTypeEntity);
|
|
|
|
|
genOrder(newBillNo, thrInvOrder, bussinessTypeEntity);
|
|
|
|
|
log.info("扫描处理第三方收费明细生成单据定时任务结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void genOrder(String newBillNo,
|
|
|
|
|
List<ThrInvOrderDetail> updateThrInvOrderDetails, List<ThrInvOrderDetail> addThrInvOrderDetails,
|
|
|
|
|
ThrInvOrder thrInvOrder, BasicBussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
if (updateThrInvOrderDetails.size() > 0 || addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
public boolean genOrder(String newBillNo,
|
|
|
|
|
ThrInvOrder thrInvOrder, BasicBussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
QueryWrapper<ThrInvOrderDetail> qwd = new QueryWrapper<>();
|
|
|
|
|
qwd.eq("orderIdFk", thrInvOrder.getBillNo());
|
|
|
|
|
List<ThrInvOrderDetail> thrInvOrderDetails = thrInvOrderDetailMapper.selectList(qwd);
|
|
|
|
|
if (CollectionUtil.isEmpty(thrInvOrderDetails))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
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(thrInvOrder.getFromCorp(), thrInvOrderDetails);
|
|
|
|
|
}
|
|
|
|
|
for (Map.Entry<String, List<ThrInvOrderDetail>> entry : grouped.entrySet()) {
|
|
|
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
|
|
|
ioOrderEntity.setBillNo(newBillNo);
|
|
|
|
|
ioOrderEntity.setMainAction(thrInvOrder.getMainAction());
|
|
|
|
|
ioOrderEntity.setFromCorp(thrInvOrder.getFromCorp());
|
|
|
|
|
String fromCorp;
|
|
|
|
|
if (entry.getValue().get(0).getSickerCode() != null || entry.getValue().get(0).getSickerName() != null)
|
|
|
|
|
fromCorp = addInoutService.updateCorp(bussinessTypeEntity, entry.getValue().get(0).getSickerName(), entry.getKey());
|
|
|
|
|
else
|
|
|
|
|
fromCorp = entry.getKey();
|
|
|
|
|
ioOrderEntity.setFromCorp(fromCorp);
|
|
|
|
|
ioOrderEntity.setInvCode(thrInvOrder.getInvCode());
|
|
|
|
|
ioOrderEntity.setDeptCode(thrInvOrder.getDeptCode());
|
|
|
|
|
ioOrderEntity.setAction(thrInvOrder.getBillType());
|
|
|
|
@ -986,19 +1003,12 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
ioOrderEntity.setCreateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setUpdateUser(userId + "");
|
|
|
|
|
ioOrderEntity.setOrderType(ConstantStatus.ORDER_TYPE_SCAN);//正常单据处理
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>(updateThrInvOrderDetails.size());
|
|
|
|
|
|
|
|
|
|
if (updateThrInvOrderDetails.size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(updateThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
List<IoOrderDetailBizEntity> newOrderDetailBiz = new ArrayList<>();
|
|
|
|
|
if (entry.getValue().size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(entry.getValue(), newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (addThrInvOrderDetails.size() > 0) {
|
|
|
|
|
if (!copyOrderDetailBiz(addThrInvOrderDetails, newOrderDetailBiz, newBillNo)) {
|
|
|
|
|
throw new JsonException("第三方收费明细自动转化单据异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String toBillNo = (thrInvOrder.getToBillNo() == null ? "" : thrInvOrder.getToBillNo()) + ("," + newBillNo);
|
|
|
|
|
// 检查字符串是否以逗号开始
|
|
|
|
|
if (toBillNo.startsWith(",")) {
|
|
|
|
@ -1013,6 +1023,8 @@ public class ThrInvOrderServiceImpl implements ThrInvOrderService {
|
|
|
|
|
//自动处理业务单据
|
|
|
|
|
ioAddInoutService.dealBusProcess(ioOrderEntity, bussinessTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|