|  |  |  | @ -7,14 +7,17 @@ import cn.hutool.core.util.IdUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.basic.BasicProductsDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.basic.SysWorkplaceDocumentDao; | 
			
		
	
		
			
				
					|  |  |  |  | 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.dao.basic.UdiRelevanceDao; | 
			
		
	
		
			
				
					|  |  |  |  | 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.IoCollectOrderBizOrigin; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderOrigin; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.http.ErpBasicClient; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.basic.GetSickPrescribeRequest; | 
			
		
	
	
		
			
				
					|  |  |  | @ -25,12 +28,14 @@ import com.glxp.api.res.PageSimpleResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.basic.BasicSkPrescribeResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.basic.SysWorkplaceDocumentResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.BeanCopyUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.time.LocalDateTime; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Date; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | /** | 
			
		
	
	
		
			
				
					|  |  |  | @ -57,6 +62,14 @@ public class IoCollectOriginService { | 
			
		
	
		
			
				
					|  |  |  |  |     private SysWorkplaceDocumentDao sysWorkplaceDocumentDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private SysWorkplaceDocumentService sysWorkplaceDocumentService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoCollectOrderOriginService collectOrderOriginService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IoCollectOrderBizOriginService collectOrderBizOriginService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private UdiRelevanceDao udiRelevanceDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private BasicProductsDao basicProductsDao; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse downloadOrderV2(CollectOrderRequest collectOrderRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         //条件
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -86,7 +99,7 @@ public class IoCollectOriginService { | 
			
		
	
		
			
				
					|  |  |  |  |      * @param collectOrderRequest | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |  |     public void errorHandle(CollectOrderRequest collectOrderRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse errorHandle(CollectOrderRequest collectOrderRequest) { | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isBlank(collectOrderRequest.getBillNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "单据号不能为空"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -103,7 +116,78 @@ public class IoCollectOriginService { | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoCollectOrder::getBillNo, collectOrderRequest.getBillNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoCollectOrder::getTagStatus, 4)); | 
			
		
	
		
			
				
					|  |  |  |  |         //重新拉取
 | 
			
		
	
		
			
				
					|  |  |  |  |         this.downloadOrderV2(collectOrderRequest); | 
			
		
	
		
			
				
					|  |  |  |  |         return this.downloadOrderV2(collectOrderRequest); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  |     @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)); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrder> ioCollectOrderList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         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); | 
			
		
	
		
			
				
					|  |  |  |  |                     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.isNotBlank(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(0); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderOriginService.updateById(thrOrder); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     List<IoCollectOrderBizOrigin> ioCollectOrderBizOrigins = BeanCopyUtils.copyList(bizList, IoCollectOrderBizOrigin.class); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBizOriginService.updateBatchById(ioCollectOrderBizOrigins); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     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(0); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderService.save(ioCollectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success("提交成功"); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } |