Commit 282587fab948d26b4b7b68f0b043d92f9a61faf1

Authored by liquanyu
1 parent 7324b78d84

update

Showing 5 changed files with 70 additions and 6 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/MongoSyncService.java View file @ 282587f
... ... @@ -48,9 +48,9 @@
48 48  
49 49 public static String mongo_crypto_key = Config.getItem("mongo_crypto_key", "0");
50 50  
51   - public boolean syncData(String action, String id, String className, String json) {
  51 + public boolean syncData(String action, String id, String className, String json,String url) {
52 52  
53   - logger.info("action:" + action + ",id:"+id+",className:"+className+",json:"+json +"|");
  53 + logger.info("action:" + action + ",id:"+id+",className:"+className+",json:"+json +"|"+"url:"+url);
54 54 try {
55 55 if ("UPDATEMULTI".equals(action)) {
56 56 Class cla = Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key));
... ... @@ -166,7 +166,11 @@
166 166 }
167 167 return false;
168 168 } catch (Exception e) {
169   - ExceptionUtils.catchException(e,"syncData Error. id :" +id+",action:" +action+",json:"+json +",className:"+className);
  169 + try {
  170 + ExceptionUtils.catchException(e,"syncData Error. id :" +id+",action:" +action+",json:"+json +",className:"+Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key)).toString()+"url:"+url);
  171 + } catch (Exception e1) {
  172 +
  173 + }
170 174 return true;
171 175 }
172 176 }
platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java View file @ 282587f
... ... @@ -348,7 +348,7 @@
348 348 if (value == null || !StringUtils.isNotEmpty(value.toString()) || "/".equals(value)) {
349 349 return null;
350 350 }
351   - return value.toString() + unit;
  351 + return "正常".equals(value.toString()) ? value.toString() : value.toString() + unit;
352 352 }
353 353  
354 354 public static <T> List<T> covertToList(String s, Class<T> clazz) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MongoSyncController.java View file @ 282587f
... ... @@ -44,7 +44,7 @@
44 44 return "success";
45 45 }
46 46  
47   - boolean boo = mongoSyncService.syncData(action,id, className, jsonData);
  47 + boolean boo = mongoSyncService.syncData(action,id, className, jsonData,"");
48 48 if (boo) {
49 49 return "success";
50 50 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 282587f
... ... @@ -4183,5 +4183,65 @@
4183 4183 return "syncPatFirstTime finish";
4184 4184 }
4185 4185  
  4186 +
  4187 +
  4188 +
  4189 + @RequestMapping(value = "/syncPatientByHospitalId", method = RequestMethod.GET)
  4190 + @ResponseBody
  4191 + public String syncPatientByHospitalId(@RequestParam(required = false) String hospitalId, String startDate,String endDate) {
  4192 + PatientsQuery patientQuery = new PatientsQuery();
  4193 + patientQuery.setYn(YnEnums.YES.getId());
  4194 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(hospitalId)) {
  4195 + patientQuery.setHospitalId(hospitalId);
  4196 + }
  4197 + patientQuery.setCreatedTimeStart(DateUtil.parseYMD(startDate));
  4198 + patientQuery.setCreatedTimeEnd(DateUtil.parseYMD(endDate));
  4199 + //patientQuery.setId("5fe9830199325d067a7be05a");
  4200 +
  4201 + List<Patients> patientses = patientsService.queryPatient(patientQuery);
  4202 + System.out.println("patientses size "+ patientses.size());
  4203 + int batchSize = 1000;
  4204 + int end = 0;
  4205 + for (int i = 0; i < patientses.size(); i += batchSize) {
  4206 + end = (end + batchSize);
  4207 + if (end > patientses.size()) {
  4208 + end = patientses.size();
  4209 + }
  4210 + System.out.println("start:" + i + ",end:" + end);
  4211 + final List<Patients> tempList = patientses.subList(i, end);
  4212 + commonThreadPool.execute(new Runnable() {
  4213 + @Override
  4214 + public void run() {
  4215 + if (CollectionUtils.isNotEmpty(tempList)) {
  4216 + for (Patients pat : tempList) {
  4217 + String patientId = pat.getId();
  4218 + mongoTemplate.remove(Query.query(Criteria.where("_id").is(patientId)), Patients.class);
  4219 + pat.setModified(new Date());
  4220 + patientsService.addPatient(pat);
  4221 +
  4222 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(pat.getPid()))
  4223 + {
  4224 + PersonModelQuery personModelQuery = new PersonModelQuery();
  4225 + personModelQuery.setYn(YnEnums.YES.getId());
  4226 + personModelQuery.setId(pat.getPid());
  4227 +
  4228 + List<PersonModel> personModels = personService.queryPersons(personModelQuery);
  4229 + if (CollectionUtils.isNotEmpty(personModels))
  4230 + {
  4231 + PersonModel personModel = personModels.get(0);
  4232 + personModel.setModified(new Date());
  4233 + mongoTemplate.remove(Query.query(Criteria.where("_id").is(pat.getPid())), PersonModel.class);
  4234 + personService.addPerson(personModel);
  4235 + }
  4236 + }
  4237 + }
  4238 + }
  4239 + }
  4240 + });
  4241 + }
  4242 +
  4243 + return "syncPatientByHospitalId finish";
  4244 + }
  4245 +
4186 4246 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java View file @ 282587f
... ... @@ -176,7 +176,7 @@
176 176 }
177 177 else
178 178 {
179   - boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData());
  179 + boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData(),url);
180 180 }
181 181  
182 182 }