|  |  |  | @ -3,8 +3,12 @@ package com.glxp.api.service.sync; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.dev.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.thrsys.ThrManufacturerMapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.RelCodeBatch; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.RelCodeDetail; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.dev.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.res.inv.InnerOrderPrintResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.RelCodeBatchService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.RelCodeDetailService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.dev.*; | 
			
		
	
		
			
				
					|  |  |  |  | import org.junit.Test; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
	
		
			
				
					|  |  |  | @ -69,6 +73,7 @@ import java.io.IOException; | 
			
		
	
		
			
				
					|  |  |  |  | import java.time.LocalDateTime; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.function.Function; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_ORDER; | 
			
		
	
		
			
				
					|  |  |  |  | import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_UDIS; | 
			
		
	
	
		
			
				
					|  |  |  | @ -305,6 +310,12 @@ public class HeartService { | 
			
		
	
		
			
				
					|  |  |  |  | //                if (needExec(info.getDeviceTask())) {
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //默认开启
 | 
			
		
	
		
			
				
					|  |  |  |  |                 uploadData(exportType, taskId, x -> x.getDeviceTaskData(info, taskId, now, syncTime)); | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  |                 break; | 
			
		
	
		
			
				
					|  |  |  |  |             case DRUG_DATA_TASK: | 
			
		
	
		
			
				
					|  |  |  |  | //                if (needExec(info.getDeviceTask())) {
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //默认开启
 | 
			
		
	
		
			
				
					|  |  |  |  |                 uploadData(exportType, taskId, x -> x.getDrugDataTaskData(info, taskId, now, syncTime)); | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  |                 break; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -1108,6 +1119,10 @@ public class HeartService { | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     DeviceInspectTaskService deviceInspectTaskService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     RelCodeDetailService relCodeDetailService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     RelCodeBatchService relCodeBatchService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     DeviceInspectTaskDetailService deviceInspectTaskDetailService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Value("${file_path}") | 
			
		
	
		
			
				
					|  |  |  |  |     private String filePath; | 
			
		
	
	
		
			
				
					|  |  |  | @ -1164,6 +1179,50 @@ public class HeartService { | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return dataResponse; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * @param info | 
			
		
	
		
			
				
					|  |  |  |  |      * @param taskId | 
			
		
	
		
			
				
					|  |  |  |  |      * @param now | 
			
		
	
		
			
				
					|  |  |  |  |      * @param syncTime | 
			
		
	
		
			
				
					|  |  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private SpsSyncDrugDataTaskResponse getDrugDataTaskData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) { | 
			
		
	
		
			
				
					|  |  |  |  |         SpsSyncDrugDataTaskResponse dataResponse = null; | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> syncTimeMap = new WeakHashMap<>(3); | 
			
		
	
		
			
				
					|  |  |  |  |         syncTimeMap.put("isNew", true); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean ge = false; | 
			
		
	
		
			
				
					|  |  |  |  |         if (syncTime != null) { | 
			
		
	
		
			
				
					|  |  |  |  |             ge = true; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         StringBuffer remark = new StringBuffer(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (needExec(info.getDrugDataTask())) { | 
			
		
	
		
			
				
					|  |  |  |  |             Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DRUG_DATA_TASK); | 
			
		
	
		
			
				
					|  |  |  |  |             List<RelCodeBatch> relCodeBatches = relCodeBatchService.list(Wrappers.lambdaQuery(RelCodeBatch.class) | 
			
		
	
		
			
				
					|  |  |  |  |                     .le(!ge && (boolean) map.get("isNew"), RelCodeBatch::getUpdateTime, now) | 
			
		
	
		
			
				
					|  |  |  |  |                     .between(ge, RelCodeBatch::getUpdateTime, syncTime, now) | 
			
		
	
		
			
				
					|  |  |  |  |                     .between(!ge && !(boolean) map.get("isNew"), RelCodeBatch::getUpdateTime | 
			
		
	
		
			
				
					|  |  |  |  |                             , map.get("oldDate"), now) | 
			
		
	
		
			
				
					|  |  |  |  |             ); | 
			
		
	
		
			
				
					|  |  |  |  |             if (CollectionUtil.isNotEmpty(relCodeBatches)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 dataResponse = new SpsSyncDrugDataTaskResponse(); | 
			
		
	
		
			
				
					|  |  |  |  |                 dataResponse.setRelCodeBatches(relCodeBatches); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //增加明细数据
 | 
			
		
	
		
			
				
					|  |  |  |  |                 List<Integer> batchIds = relCodeBatches.stream().map(RelCodeBatch::getId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |                 List<RelCodeDetail> list = relCodeDetailService.list(Wrappers.lambdaQuery(RelCodeDetail.class) | 
			
		
	
		
			
				
					|  |  |  |  |                         .in(RelCodeDetail::getBatchIdFk,batchIds)); | 
			
		
	
		
			
				
					|  |  |  |  |                 dataResponse.setRelCodeDetails(list); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 remark.append("药品关联信息任务:").append(relCodeBatches.size()).append("条\n"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         if (dataResponse != null) { | 
			
		
	
		
			
				
					|  |  |  |  |             dataResponse.setTaskId(taskId); | 
			
		
	
		
			
				
					|  |  |  |  |             dataResponse.setType(BasicExportTypeEnum.DRUG_DATA_TASK.getRemark()); | 
			
		
	
		
			
				
					|  |  |  |  |             dataResponse.setSyncRemark(remark.toString()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return dataResponse; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
	
		
			
				
					|  |  |  | 
 |