Commit 53db73325f4b464ae637683050ae9e5943df35fa

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java

Showing 23 changed files

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java View file @ 53db733
... ... @@ -5,7 +5,6 @@
5 5 import com.lyms.platform.pojo.Patients;
6 6 import com.lyms.platform.pojo.PuerperaModel;
7 7  
8   -import java.util.HashMap;
9 8 import java.util.List;
10 9  
11 10 /**
... ... @@ -33,7 +32,5 @@
33 32 void findAndModify(MongoQuery query,Patients obj);
34 33  
35 34 void updatePatientOneCol(String id, String colName, Object colValue);
36   -
37   - List<HashMap> aggregateOne(MongoQuery mongoQuery);
38 35 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java View file @ 53db733
... ... @@ -40,8 +40,8 @@
40 40 }
41 41  
42 42 @Override
43   - public void updatePatientOneCol(String id, String colName, Object colValue) {
44   - this.mongoTemplate.updateFirst(new Query(Criteria.where("id").is(id)), Update.update(colName, colValue), Patients.class);
  43 + public void updatePatientOneCol(String id, Object colValue) {
  44 + this.mongoTemplate.updateFirst(new Query(Criteria.where("id").is(id)), Update.update("nextCheckTime", colValue), Patients.class);
45 45 }
46 46  
47 47 @Override
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/MongoSyncService.java View file @ 53db733
... ... @@ -58,10 +58,18 @@
58 58 Class cla = Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key));
59 59 // 批量修改的情况下,ID字段是要修改的CLASS
60 60 Class updateClass = Class.forName(LymsEncodeUtil.aesDecrypt(id, mongo_crypto_key));
61   - Object obj = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), cla);
  61 + Object obj = null;
  62 + try {
  63 + obj = SerializUtils.byteToObj(Base64.decodeBase64(json));
  64 + } catch (Exception ee) {
  65 + obj = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), cla);
  66 + }
62 67 if (obj instanceof UpdateMultiData) {
63 68 UpdateMultiData data = (UpdateMultiData) obj;
64   - if (data.getQuery() != null && data.getUpdate() != null) {
  69 + if (data.getMongoQuery() != null && data.getMongoUpdate() != null) {
  70 + mongoTemplate.updateMulti(data.getMongoQuery(), data.getMongoUpdate(), updateClass);
  71 + return true;
  72 + } else if (data.getQuery() != null && data.getUpdate() != null) {
65 73 MongoCondition c = null;
66 74 for (String key:data.getQuery().keySet()) {
67 75 if (c == null) {
68 76  
... ... @@ -80,13 +88,23 @@
80 88 }
81 89 }
82 90 } else if ("ADD".equals(action)) {
83   - Object entity = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key)));
  91 + Object entity = null;
  92 + try {
  93 + entity = SerializUtils.byteToObj(Base64.decodeBase64(json));
  94 + } catch (Exception ee) {
  95 + entity = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key)));
  96 + }
84 97 Assert.notNull(entity, "execute insert method must not null.");
85 98 mongoTemplate.save(entity);
86 99 return true;
87 100 } else if ("UPDATE".equals(action)) {
88 101 Class cla = Class.forName(LymsEncodeUtil.aesDecrypt(className, mongo_crypto_key));
89   - Object obj = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), cla);
  102 + Object obj = null;
  103 + try {
  104 + obj = SerializUtils.byteToObj(Base64.decodeBase64(json));
  105 + } catch (Exception ee) {
  106 + obj = JsonUtil.jkstr2Obj(LymsEncodeUtil.aesDecrypt(json, mongo_crypto_key), cla);
  107 + }
90 108 Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(obj));
91 109 Assert.notNull(update, "execute update method must not null.");
92 110 mongoTemplate.updateMulti(new MongoQuery(new MongoCondition("id", LymsEncodeUtil.aesDecrypt(id, mongo_crypto_key), MongoOper.IS)).convertToMongoQuery(), update, cla);
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java View file @ 53db733
... ... @@ -110,9 +110,9 @@
110 110 return iPatientDao.getPatient(id);
111 111 }
112 112  
113   - public void updatePatientOneCol(String id,String colName,Object colValue)
  113 + public void updatePatientOneCol(String id,Object colValue)
114 114 {
115   - iPatientDao.updatePatientOneCol(id,colName,colValue);
  115 + iPatientDao.updatePatientOneCol(id,colValue);
116 116 }
117 117  
118 118 /**
platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAOImpl.java View file @ 53db733
... ... @@ -4,6 +4,7 @@
4 4 import com.lyms.platform.common.pojo.SyncDataModel;
5 5 import com.lyms.platform.common.pojo.UpdateMultiData;
6 6 import com.lyms.platform.common.utils.*;
  7 +import org.apache.commons.codec.binary.Base64;
7 8 import org.apache.commons.collections.CollectionUtils;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.data.mongodb.core.MongoTemplate;
... ... @@ -11,6 +12,7 @@
11 12 import org.springframework.data.mongodb.core.query.Update;
12 13 import org.springframework.util.Assert;
13 14  
  15 +import java.io.Serializable;
14 16 import java.util.Collection;
15 17 import java.util.Date;
16 18 import java.util.List;
... ... @@ -142,6 +144,7 @@
142 144 // 数据上传
143 145 UpdateMultiData data = new UpdateMultiData();
144 146 data.setMongoQuery(query);
  147 + data.setMongoUpdate(update);
145 148 data.setUpdate(ReflectionUtils.getUpdateField(obj));
146 149 // 批量修改的情况下,ID字段是要修改的CLASS
147 150 addSyncData("UPDATEMULTI", data, obj.getClass().getName());
... ... @@ -162,7 +165,8 @@
162 165 model.setAction(action);
163 166 if (null != data) {
164 167 model.setClassName(LymsEncodeUtil.aesEncrypt(data.getClass().getName(), mongo_crypto_key));
165   - model.setJsonData(LymsEncodeUtil.aesEncrypt(JsonUtil.obj2Str(data), mongo_crypto_key));
  168 + model.setJsonData(Base64.encodeBase64String(SerializUtils.objToByte((Serializable)data)));
  169 + model.setType(1);
166 170 }
167 171 model.setCreated(new Date());
168 172 model.setModified(model.getCreated());
... ... @@ -173,6 +177,7 @@
173 177 mongoTemplate.insert(model);
174 178 } catch (Exception e) {
175 179 e.printStackTrace();
  180 + System.out.println(data);
176 181 }
177 182 }
178 183 }
platform-common/src/main/java/com/lyms/platform/common/pojo/SyncDataModel.java View file @ 53db733
... ... @@ -20,7 +20,16 @@
20 20 private String className;
21 21 private String jsonData;
22 22 private String dataId;
23   - private Integer status;
  23 + private Integer status; // 1:未同步 , 2:已同步
  24 + private Integer type; // null:旧版本(JSON),1:jsonData 为 SerializData
  25 +
  26 + public Integer getType() {
  27 + return type;
  28 + }
  29 +
  30 + public void setType(Integer type) {
  31 + this.type = type;
  32 + }
24 33  
25 34 public Integer getStatus() {
26 35 return status;
platform-common/src/main/java/com/lyms/platform/common/pojo/UpdateMultiData.java View file @ 53db733
... ... @@ -4,17 +4,38 @@
4 4 import org.springframework.data.mongodb.core.query.Query;
5 5 import org.springframework.data.mongodb.core.query.Update;
6 6  
  7 +import java.io.Serializable;
7 8 import java.util.HashMap;
8 9 import java.util.Map;
9 10  
10 11 /**
11 12 * Created by riecard on 2016/10/30.
12 13 */
13   -public class UpdateMultiData {
  14 +public class UpdateMultiData implements Serializable {
14 15  
  16 + /**
  17 + *
  18 + */
  19 + private static final long serialVersionUID = 1L;
  20 +
15 21 private Map<String, Object> query;
16 22 private Map<String, Object> update;
17 23  
  24 + private Query mongoQuery;
  25 + private Update mongoUpdate;
  26 +
  27 + public Update getMongoUpdate() {
  28 + return mongoUpdate;
  29 + }
  30 +
  31 + public void setMongoUpdate(Update mongoUpdate) {
  32 + this.mongoUpdate = mongoUpdate;
  33 + }
  34 +
  35 + public Query getMongoQuery() {
  36 + return mongoQuery;
  37 + }
  38 +
18 39 public void setQuery(Map<String, Object> query) {
19 40 this.query = query;
20 41 }
... ... @@ -24,6 +45,7 @@
24 45 }
25 46  
26 47 public void setMongoQuery(Query query) {
  48 + this.mongoQuery = query;
27 49 DBObject dbObject = query.getQueryObject();
28 50 this.query = new HashMap<>();
29 51 for (String key:dbObject.keySet()) {
platform-dal/src/main/java/com/lyms/platform/pojo/AntenatalExaminationModel.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 import java.util.Date;
... ... @@ -12,7 +13,7 @@
12 13 * Created by Administrator on 2016/6/16 0016.
13 14 */
14 15 @Document(collection = "lyms_antex")
15   -public class AntenatalExaminationModel {
  16 +public class AntenatalExaminationModel extends BaseModel {
16 17  
17 18 private String id;
18 19 private String pid;
platform-dal/src/main/java/com/lyms/platform/pojo/AwModel.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 /**
... ... @@ -7,7 +8,7 @@
7 8 * Created by Administrator on 2016/6/22.
8 9 */
9 10 @Document(collection = "lyms_healthconfig")
10   -public class AwModel {
  11 +public class AwModel extends BaseModel {
11 12 private String id;
12 13 private Integer sex;
13 14 private Integer age;
platform-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
3 3 import com.lyms.platform.common.enums.YnEnums;
  4 +import com.lyms.platform.common.result.BaseModel;
4 5 import org.springframework.data.mongodb.core.mapping.Document;
5 6  
6 7 import java.util.List;
... ... @@ -11,7 +12,7 @@
11 12 *
12 13 */
13 14 @Document(collection="lyms_communityConfig")
14   -public class CommunityConfig {
  15 +public class CommunityConfig extends BaseModel {
15 16 private String id;
16 17 private String name;
17 18 private Integer yn;
platform-dal/src/main/java/com/lyms/platform/pojo/LisCrisisItem.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 import java.util.Date;
... ... @@ -8,7 +9,7 @@
8 9 * Created by Administrator on 2016/10/19 0019.
9 10 */
10 11 @Document(collection = "lyms_lis_crisis_item")
11   -public class LisCrisisItem {
  12 +public class LisCrisisItem extends BaseModel {
12 13  
13 14 private String id;
14 15 private String hospitalId;
platform-dal/src/main/java/com/lyms/platform/pojo/LisReport.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.apache.commons.lang.StringUtils;
4 5 import org.springframework.data.mongodb.core.mapping.Document;
5 6  
... ... @@ -10,7 +11,7 @@
10 11 * Created by Administrator on 2016/10/19 0019.
11 12 */
12 13 @Document(collection = "lyms_lis_report")
13   -public class LisReport {
  14 +public class LisReport extends BaseModel {
14 15  
15 16 private String id;
16 17 private String hospitalId;
platform-dal/src/main/java/com/lyms/platform/pojo/MaternalDeliverModel.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.apache.commons.lang.math.NumberUtils;
4 5 import org.springframework.data.mongodb.core.mapping.Document;
5 6  
... ... @@ -13,7 +14,7 @@
13 14 * Created by Administrator on 2016/6/16 0016.
14 15 */
15 16 @Document(collection = "lyms_matdeliver")
16   -public class MaternalDeliverModel {
  17 +public class MaternalDeliverModel extends BaseModel {
17 18  
18 19 private String id;
19 20 //产妇id
platform-dal/src/main/java/com/lyms/platform/pojo/ReferralApplyOrderModel.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 import java.util.Date;
... ... @@ -11,7 +12,7 @@
11 12 * Created by Administrator on 2016/6/15 0015.
12 13 */
13 14 @Document(collection = "lyms_referralapplyorder")
14   -public class ReferralApplyOrderModel {
  15 +public class ReferralApplyOrderModel extends BaseModel {
15 16  
16 17 private String id;
17 18 //患者id
platform-dal/src/main/java/com/lyms/platform/pojo/ServiceMonitor.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 /**
6 7 * Created by Zhang.Rui on 2016/6/12.
7 8 */
8 9 @Document(collection="lyms_serviceMonitor")
9   -public class ServiceMonitor {
  10 +public class ServiceMonitor extends BaseModel {
10 11 private String id;
11 12 private Integer type; // 1短信 2邮箱
12 13 private String name;
platform-dal/src/main/java/com/lyms/platform/pojo/SieveApplyOrderModel.java View file @ 53db733
1 1 package com.lyms.platform.pojo;
2 2  
  3 +import com.lyms.platform.common.result.BaseModel;
3 4 import org.springframework.data.mongodb.core.mapping.Document;
4 5  
5 6 import java.util.Date;
... ... @@ -10,7 +11,7 @@
10 11 * Created by Administrator on 2016/6/15 0015.
11 12 */
12 13 @Document(collection = "lyms_sieveapplyorder")
13   -public class SieveApplyOrderModel {
  14 +public class SieveApplyOrderModel extends BaseModel {
14 15 private String id;
15 16 //患者id
16 17 private String parentId;
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java View file @ 53db733
... ... @@ -718,7 +718,7 @@
718 718 SmsConfigQuery configQuery = new SmsConfigQuery();
719 719 configQuery.setYn(YnEnums.YES.getId());
720 720 configQuery.setPrefixTypes(new Integer[]{0, 1});
721   -// configQuery.setHospitalId(242 + "");
  721 +// configQuery.setHospitalId(221 + "");
722 722  
723 723 //查询出对应医院配置
724 724 List<SmsConfigModel> configs = smsConfigService.querySmsConfig(configQuery);
725 725  
... ... @@ -2258,22 +2258,12 @@
2258 2258 AntExQuery antExQuery = new AntExQuery();
2259 2259 antExQuery.setParentId(chu.getParentId());
2260 2260 antExQuery.setYn(YnEnums.YES.getId());
2261   -
2262   - PatientsQuery patientQuery = new PatientsQuery();
2263   - patientQuery.setYn(YnEnums.YES.getId());
2264   - patientQuery.setType(1);
2265   - patientQuery.setId(chu.getParentId());
2266   -
2267   - List<Patients> patientses = patientsService.queryPatient(patientQuery);
2268   - if (CollectionUtils.isNotEmpty(patientses))
  2261 + antExQuery.setHospitalId(tempHid);
  2262 + //复诊不存在 才添加
  2263 + List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
  2264 + if (!CollectionUtils.isNotEmpty(list))
2269 2265 {
2270   - //复诊不存在 才添加
2271   - List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
2272   - if (!CollectionUtils.isNotEmpty(list))
2273   - {
2274   - idset.add(chu.getParentId());
2275   - }
2276   -
  2266 + idset.add(chu.getParentId());
2277 2267 }
2278 2268  
2279 2269 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java View file @ 53db733
... ... @@ -9,6 +9,7 @@
9 9 import com.lyms.platform.permission.model.Users;
10 10 import com.lyms.platform.permission.service.UsersService;
11 11 import com.lyms.platform.pojo.Patients;
  12 +import com.lyms.platform.query.AntExChuQuery;
12 13 import com.lyms.platform.query.PatientsQuery;
13 14 import org.springframework.context.ApplicationContext;
14 15 import org.springframework.context.support.ClassPathXmlApplicationContext;
15 16  
16 17  
17 18  
... ... @@ -25,25 +26,37 @@
25 26 public class Test{
26 27  
27 28 public static void main(String[] args){
28   - PatientsQuery patientsQuery1 = new PatientsQuery();
29   - patientsQuery1.setHospitalId("221");
30   - patientsQuery1.setYn(YnEnums.YES.getId());
31   - patientsQuery1.setType(1);
  29 +// PatientsQuery patientsQuery1 = new PatientsQuery();
  30 +// patientsQuery1.setHospitalId("221");
  31 +// patientsQuery1.setYn(YnEnums.YES.getId());
  32 +// patientsQuery1.setType(1);
  33 +//
  34 +// List buildType = new ArrayList();
  35 +// buildType.add(0);
  36 +// buildType.add(2);
  37 +// patientsQuery1.setBuildTypeList(buildType);
  38 +//
  39 +// patientsQuery1.setQueryNo("q");
  40 +//
  41 +//
  42 +//
  43 +// patientsQuery1.setBookbuildingDateStart(DateUtil.parseYMD("1999-11-11"));
  44 +// patientsQuery1.setBookbuildingDateEnd(DateUtil.parseYMD("2016-12-08"));
32 45  
33   - List buildType = new ArrayList();
34   - buildType.add(0);
35   - buildType.add(2);
36   - patientsQuery1.setBuildTypeList(buildType);
37 46  
38   - patientsQuery1.setQueryNo("q");
  47 + Date yuYueDate = DateUtil.addDay(new Date(), 2);
  48 + if (yuYueDate != null)
  49 + {
  50 + //把时间格式化成 yyyy_MM_dd 的日期
  51 + yuYueDate = DateUtil.formatDate(yuYueDate);
  52 + }
  53 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  54 + antExChuQuery.setYn(YnEnums.YES.getId());
  55 + antExChuQuery.setNextCheckTimeStart(yuYueDate);
  56 + antExChuQuery.setNextCheckTimeEnd(yuYueDate);
  57 + antExChuQuery.setHospitalId("242");
39 58  
40   -
41   -
42   - patientsQuery1.setBookbuildingDateStart(DateUtil.parseYMD("1999-11-11"));
43   - patientsQuery1.setBookbuildingDateEnd(DateUtil.parseYMD("2016-12-08"));
44   -
45   -
46   - System.out.println(patientsQuery1.convertToQuery().convertToMongoQuery());
  59 + System.out.println(antExChuQuery.convertToQuery().convertToMongoQuery());
47 60  
48 61 }
49 62 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 53db733
... ... @@ -9,6 +9,7 @@
9 9 import com.lyms.platform.common.enums.YnEnums;
10 10 import com.lyms.platform.common.utils.DateUtil;
11 11 import com.lyms.platform.common.utils.JsonUtil;
  12 +import com.lyms.platform.common.utils.StringUtils;
12 13 import com.lyms.platform.operate.web.service.SyncDataTaskService;
13 14 import com.lyms.platform.permission.service.OrganizationService;
14 15 import com.lyms.platform.pojo.AntExChuModel;
... ... @@ -203,18 +204,6 @@
203 204 return "assayconfiginit";
204 205 }
205 206  
206   - public static void main(String[] a) {
207   - try {
208   - String json = FileUtils.readFileToString(new File("d:/assayconfig.json"));
209   - List<AssayConfig> list = JsonUtil.toList(json, AssayConfig.class);
210   - for (AssayConfig config:list) {
211   - System.out.println(JsonUtil.obj2JsonString(config));
212   - }
213   - } catch (IOException e) {
214   - e.printStackTrace();
215   - }
216   - }
217   -
218 207 @RequestMapping(value = "/updateXY", method = RequestMethod.GET)
219 208 @ResponseBody
220 209 public String updateXY() {
221 210  
222 211  
223 212  
224 213  
225 214  
226 215  
227 216  
228 217  
229 218  
... ... @@ -299,47 +288,109 @@
299 288  
300 289 @RequestMapping(value = "/syncPatNextTime", method = RequestMethod.GET)
301 290 @ResponseBody
302   - public String syncPatNextTime() {
  291 + public String syncPatNextTime(@RequestParam(required = true) String hid) {
303 292 PatientsQuery patientQuery = new PatientsQuery();
304 293 patientQuery.setYn(YnEnums.YES.getId());
305   - patientQuery.setHospitalId("221");
  294 + patientQuery.setHospitalId(hid);
306 295 patientQuery.setType(1);
307 296 List<Patients> patientses = patientsService.queryPatient(patientQuery);
308   - if (CollectionUtils.isNotEmpty(patientses))
309   - {
310   - for (Patients pat : patientses) {
311   - AntExChuQuery antExChuQuery = new AntExChuQuery();
312   - antExChuQuery.setYn(YnEnums.YES.getId());
313   - antExChuQuery.setHospitalId(pat.getHospitalId());
314   - antExChuQuery.setParentId(pat.getId());
315   - List<AntExChuModel> chus = antenatalExaminationService.queryAntExChu(antExChuQuery);
316   - if (CollectionUtils.isNotEmpty(chus)) {
317   - Date nextTime = null;
318   - AntExChuModel chu = chus.get(0);
319   - if (chu != null)
  297 + int batchSize = 1000;
  298 + int end = 0;
  299 + for (int i = 0; i < patientses.size(); i += batchSize) {
  300 + end = (end + batchSize);
  301 + if (end > patientses.size()) {
  302 + end = patientses.size();
  303 + }
  304 + System.out.println("start:" + i + ",end:" + end);
  305 + final List<Patients> tempList = patientses.subList(i, end);
  306 + new Thread(new Runnable() {
  307 + @Override
  308 + public void run() {
  309 + if (CollectionUtils.isNotEmpty(tempList))
320 310 {
321   - nextTime = chu.getNextCheckTime();
  311 + for (Patients pat : tempList) {
  312 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  313 + antExChuQuery.setYn(YnEnums.YES.getId());
  314 + antExChuQuery.setHospitalId(pat.getHospitalId());
  315 + antExChuQuery.setParentId(pat.getId());
  316 + List<AntExChuModel> chus = antenatalExaminationService.queryAntExChu(antExChuQuery);
  317 + if (CollectionUtils.isNotEmpty(chus)) {
  318 + Date nextTime = null;
  319 + AntExChuModel chu = chus.get(0);
  320 + if (chu != null)
  321 + {
  322 + nextTime = chu.getNextCheckTime();
  323 + AntExQuery antExQuery = new AntExQuery();
  324 + antExQuery.setParentId(pat.getId());
  325 + antExQuery.setYn(YnEnums.YES.getId());
  326 + antExQuery.setHospitalId(pat.getHospitalId());
  327 + List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
  328 + if (CollectionUtils.isNotEmpty(list))
  329 + {
  330 + AntenatalExaminationModel ae = list.get(0);
  331 + if (ae != null)
  332 + {
  333 + nextTime = ae.getNextCheckTime();
  334 + }
  335 + }
  336 + patientsService.updatePatientOneCol(pat.getId(), nextTime);
322 337  
323   - AntExQuery antExQuery = new AntExQuery();
324   - antExQuery.setParentId(pat.getId());
325   - antExQuery.setYn(YnEnums.YES.getId());
326   - antExQuery.setHospitalId(pat.getHospitalId());
327   - List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
328   - if (CollectionUtils.isNotEmpty(list))
329   - {
330   - AntenatalExaminationModel ae = list.get(0);
331   - if (ae != null)
332   - {
333   - nextTime = ae.getNextCheckTime();
  338 + }
  339 +
334 340 }
335 341 }
336   - patientsService.updatePatientOneCol(pat.getId(), "nextCheckTime", nextTime);
337 342 }
  343 + }
  344 + });
  345 + }
338 346  
  347 + return "syncPatNextTime finish";
  348 + }
  349 +
  350 + @RequestMapping(value = "/initCardNo", method = RequestMethod.GET)
  351 + @ResponseBody
  352 + public String initCardNo() {
  353 + PatientsQuery query = new PatientsQuery();
  354 + query.setYn(1);
  355 + query.setHospitalId("216");
  356 + List<Patients> list = patientsService.queryPatient(query);
  357 + int a = 0;
  358 + for (Patients patients:list) {
  359 + if (org.apache.commons.lang.StringUtils.isBlank(patients.getCardNo())) {
  360 + Patients db = new Patients();
  361 + db.setId(patients.getId());
  362 + db.setCardNo(patients.getPhone());
  363 + db.setHcertificateTypeId("hcertificateTypeId");
  364 + patientsService.updatePatient(db);
  365 + a++;
  366 + }
  367 + }
  368 + return "initCardNo finish - " + a;
  369 + }
  370 +
  371 + public static void main(String[] a) {
  372 + try {
  373 + List<String> list = FileUtils.readLines(new File("D:\\temp\\qhdfy_lost1.csv"));
  374 + List<String> linenums = new ArrayList<>();
  375 + for (String line:list) {
  376 + String ss[] = line.split(",");
  377 + if (ss.length > 0 && ss[0].trim().length() > 0) {
  378 + linenums.add(ss[0].trim());
339 379 }
340 380 }
  381 + List<String> list1 = FileUtils.readLines(new File("D:\\temp\\qhd-jd.csv"), "utf-8");
  382 + StringBuffer sb = new StringBuffer();
  383 + for (String line:list1) {
  384 + String ss[] = line.split(",");
  385 + if (ss.length > 0 && ss[0].trim().length() > 0 && linenums.contains(ss[0].trim())) {
  386 + sb.append(line);
  387 + sb.append("\r\n");
  388 + }
  389 + }
  390 + FileUtils.writeStringToFile(new File("d:\\temp\\qhdfy_lost_data.csv"), sb.toString());
  391 + } catch (Exception e) {
  392 + e.printStackTrace();
341 393 }
342   - return "syncPatNextTime finish";
343 394 }
344 395  
345 396 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java View file @ 53db733
... ... @@ -136,8 +136,8 @@
136 136 Patients patients = patientsService.findOnePatientById(antExAddRequest.getParentId());
137 137  
138 138 patients.setLastCheckEmployeeId(antExAddRequest.getCheckDoctor());
139   - patientsService.updatePatientOneCol(patients.getId(), "nextCheckTime", com.lyms.platform.common.utils.StringUtils.isEmpty(antExAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(antExAddRequest.getNextCheckTime()));
140 139 patientsService.updatePatient(patients);
  140 + patientsService.updatePatientOneCol(patients.getId(), com.lyms.platform.common.utils.StringUtils.isEmpty(antExAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(antExAddRequest.getNextCheckTime()));
141 141 //修改孕妇高危等级
142 142 updateLastRisk(antExAddRequest.getParentId());
143 143  
144 144  
... ... @@ -160,12 +160,13 @@
160 160 }
161 161 Patients patients = patientsService.findOnePatientById(antExAddRequest.getParentId());
162 162 patients.setLastCheckEmployeeId(antExAddRequest.getCheckDoctor());
163   - patientsService.updatePatientOneCol(patients.getId(), "nextCheckTime", com.lyms.platform.common.utils.StringUtils.isEmpty(antExAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(antExAddRequest.getNextCheckTime()));
  163 +
164 164 model.setPid(patients.getPid());
165 165 if (StringUtils.isNotEmpty(patients.getEnable()) && "0".equals(patients.getEnable())) {
166 166 patients.setEnable("1");
167 167 }
168 168 patientsService.updatePatient(patients);
  169 + patientsService.updatePatientOneCol(patients.getId(), com.lyms.platform.common.utils.StringUtils.isEmpty(antExAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(antExAddRequest.getNextCheckTime()));
169 170 antenatalExaminationService.addOneBabyAnt(model);
170 171  
171 172 //修改最后一次检查时间
172 173  
... ... @@ -248,13 +249,14 @@
248 249  
249 250 Patients patients = patientsService.findOnePatientById(excAddRequest.getParentId());
250 251 patients.setLastCheckEmployeeId(excAddRequest.getProdDoctor());
251   - patientsService.updatePatientOneCol(patients.getId(), "nextCheckTime", com.lyms.platform.common.utils.StringUtils.isEmpty(excAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(excAddRequest.getNextCheckTime()));
  252 +
252 253 if (StringUtils.isNotEmpty(patients.getEnable()) && "0".equals(patients.getEnable())) {
253 254 patients.setEnable("1");
254 255 }
255 256 //修改患者风险等级
256 257 // updatePatientRiskLevel(antExChuModel, patients);
257 258 patientsService.updatePatient(patients);
  259 + patientsService.updatePatientOneCol(patients.getId(), com.lyms.platform.common.utils.StringUtils.isEmpty(excAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(excAddRequest.getNextCheckTime()));
258 260 //修改本系统最后的高危
259 261 updateLastRisk(patients.getId());
260 262 //修改本院最后一次定义高危
261 263  
... ... @@ -292,10 +294,11 @@
292 294 antExChuModel.setHospitalId(autoMatchFacade.getHospitalId(userId));
293 295 antenatalExaminationService.addOneAntEx(antExChuModel);
294 296 //修改患者风险等级
295   - patientsService.updatePatientOneCol(patients.getId(), "nextCheckTime", com.lyms.platform.common.utils.StringUtils.isEmpty(excAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(excAddRequest.getNextCheckTime()));
  297 +
296 298 patients.setLastCheckEmployeeId(excAddRequest.getProdDoctor());
297 299 // updatePatientRiskLevel(antExChuModel, patients);
298 300 patientsService.updatePatient(patients);
  301 + patientsService.updatePatientOneCol(patients.getId(), com.lyms.platform.common.utils.StringUtils.isEmpty(excAddRequest.getNextCheckTime()) == true ? null : DateUtil.parseYMD(excAddRequest.getNextCheckTime()));
299 302 updateLastRisk(patients.getId());
300 303  
301 304 //修改本院最后一次定义高危
... ... @@ -1376,6 +1379,9 @@
1376 1379 * @return
1377 1380 */
1378 1381 public BaseResponse delOneAntEx(AntExQueryRequest antExQueryRequest, Integer userId) {
  1382 +
  1383 + String parentId = "";
  1384 +
1379 1385 if ("1".equals(antExQueryRequest.getType())) {
1380 1386 AntenatalExaminationModel antEx = new AntenatalExaminationModel();
1381 1387 antEx.setYn(YnEnums.NO.getId());
... ... @@ -1384,7 +1390,7 @@
1384 1390  
1385 1391 AntenatalExaminationModel localAntModel = antenatalExaminationService.findOneById(antExQueryRequest.getId());
1386 1392  
1387   - ;
  1393 + parentId =localAntModel.getParentId();
1388 1394  
1389 1395 /*AntExQuery antExQuery = new AntExQuery();
1390 1396 antExQuery.setId(antExQueryRequest.getId());
1391 1397  
... ... @@ -1429,9 +1435,9 @@
1429 1435  
1430 1436 AntExChuModel antExChuModel11 = antenatalExaminationService.findOne(antExQueryRequest.getId());
1431 1437  
  1438 + parentId = antExChuModel11.getParentId();
1432 1439  
1433 1440  
1434   -
1435 1441 /*AntExChuQuery antExQuery = new AntExChuQuery();
1436 1442 antExQuery.setId(antExQueryRequest.getId());
1437 1443 antExQuery.setYn(YnEnums.YES.getId());
... ... @@ -1469,6 +1475,52 @@
1469 1475 return new BaseResponse().setErrorcode(ErrorCodeConstants.BUSINESS_ERROR).setErrormsg("当前产检记录不是本院最新的产检记录,不能删除");
1470 1476 }
1471 1477 }
  1478 +
  1479 +
  1480 + //删除复诊或者出诊的时候更新patient表的下次预约时间为最近的一次预约
  1481 + if (StringUtils.isNotEmpty(parentId))
  1482 + {
  1483 + PatientsQuery patientQuery = new PatientsQuery();
  1484 + patientQuery.setYn(YnEnums.YES.getId());
  1485 + patientQuery.setId(parentId);
  1486 + List<Patients> patientses = patientsService.queryPatient(patientQuery);
  1487 + if (CollectionUtils.isNotEmpty(patientses))
  1488 + {
  1489 + for (Patients pat : patientses) {
  1490 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  1491 + antExChuQuery.setYn(YnEnums.YES.getId());
  1492 + antExChuQuery.setHospitalId(pat.getHospitalId());
  1493 + antExChuQuery.setParentId(pat.getId());
  1494 + List<AntExChuModel> chus = antenatalExaminationService.queryAntExChu(antExChuQuery);
  1495 + if (CollectionUtils.isNotEmpty(chus)) {
  1496 + Date nextTime = null;
  1497 + AntExChuModel chu = chus.get(0);
  1498 + if (chu != null)
  1499 + {
  1500 + nextTime = chu.getNextCheckTime();
  1501 +
  1502 + AntExQuery antExQuery = new AntExQuery();
  1503 + antExQuery.setParentId(pat.getId());
  1504 + antExQuery.setYn(YnEnums.YES.getId());
  1505 + antExQuery.setHospitalId(pat.getHospitalId());
  1506 + List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
  1507 + if (CollectionUtils.isNotEmpty(list))
  1508 + {
  1509 + AntenatalExaminationModel ae = list.get(0);
  1510 + if (ae != null)
  1511 + {
  1512 + nextTime = ae.getNextCheckTime();
  1513 + }
  1514 + }
  1515 + patientsService.updatePatientOneCol(pat.getId(), nextTime);
  1516 +
  1517 + }
  1518 +
  1519 + }
  1520 + }
  1521 + }
  1522 + }
  1523 +
1472 1524  
1473 1525 return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
1474 1526 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java View file @ 53db733
... ... @@ -60,7 +60,15 @@
60 60  
61 61 /**/ //用户角色
62 62 if (UserTypeEnum.NORMAL_USER.getId().equals(list.get(0).getType())||UserTypeEnum.PLATFORM_ADMIN.getId().equals(list.get(0).getType())) {
63   - data.add(list.get(0).getOrgId());
  63 + List<Organization> list2 = accessPermissionFacade.getOrganization(accessPermissionFacade.findAccessPerminssionByUserId(list.get(0).getId()));
  64 + if(CollectionUtils.isNotEmpty(list2)){
  65 + for(Organization organization:list2){
  66 + data.add(organization.getId());
  67 + }
  68 + }
  69 + if (!data.contains(list.get(0).getOrgId())) {
  70 + data.add(list.get(0).getOrgId());
  71 + }
64 72 } else if(UserTypeEnum.SUPPER_ADMIN.getId().equals(list.get(0).getType())) {
65 73 return null;
66 74 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java View file @ 53db733
... ... @@ -479,8 +479,6 @@
479 479 break;
480 480 }
481 481 try {
482   - int tempIndex = line.indexOf(",,,,,,,,,,,,,,,");
483   - line = line.substring(0, tempIndex + 1);
484 482 String ss[] = line.split(",");
485 483 if (!ss[1].startsWith("2016")) {
486 484 continue;
487 485  
... ... @@ -633,17 +631,21 @@
633 631 patients.setPhone(ss[19].trim());
634 632 patients.setHusbandPhone(ss[20].trim());
635 633 // 区县地址21, 22
636   - String areaName = ss[21].trim();
637   - if (org.apache.commons.lang.StringUtils.isNotBlank(areaName)) {
638   - for (String name : areaMap.keySet()) {
639   - if (name.indexOf(areaName) >= 0) {
640   - patients.setProvinceId("1");
641   - patients.setCityId("2");
642   - patients.setAreaId(areaMap.get(name).getId());
643   - if (StringUtils.isNotBlank(ss[22].trim())) {
644   - patients.setAddress(ss[22].trim());
  634 + if (ss.length >=22) {
  635 + String areaName = ss[21].trim();
  636 + if (org.apache.commons.lang.StringUtils.isNotBlank(areaName)) {
  637 + for (String name : areaMap.keySet()) {
  638 + if (name.indexOf(areaName) >= 0) {
  639 + patients.setProvinceId("1");
  640 + patients.setCityId("2");
  641 + patients.setAreaId(areaMap.get(name).getId());
  642 + if (ss.length >=23) {
  643 + if (StringUtils.isNotBlank(ss[22].trim())) {
  644 + patients.setAddress(ss[22].trim());
  645 + }
  646 + }
  647 + break;
645 648 }
646   - break;
647 649 }
648 650 }
649 651 }
... ... @@ -726,6 +728,13 @@
726 728 antExChuModel.setPid(patientsList.get(0).getPid());
727 729 antenatalExaminationService.addOneAntEx(antExChuModel);
728 730 }
  731 + continue;
  732 + }
  733 + if (patientsList.size() == 1) {
  734 + patients.setId(patientsList.get(0).getId());
  735 + personModel.setId(patients.getId());
  736 + personService.updatePerson(personModel, personModel.getId());
  737 + patientsService.updatePatient(patients);
729 738 continue;
730 739 }
731 740 personService.addPerson(personModel);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CommonsHelper.java View file @ 53db733
... ... @@ -48,6 +48,31 @@
48 48 return sb.toString();
49 49 }
50 50  
  51 + public static String getResidence(String provinceId,
  52 + String cityId,
  53 + String areaId,
  54 + String streetId,
  55 + String address, BasicConfigService basicConfigService) {
  56 + StringBuilder sb = new StringBuilder();
  57 + if (StringUtils.isNotEmpty(provinceId)) {
  58 + sb.append(getName1(provinceId,basicConfigService));
  59 + }
  60 + if (StringUtils.isNotEmpty(cityId)) {
  61 + sb.append(getName1(cityId,basicConfigService));
  62 + }
  63 + if (StringUtils.isNotEmpty(areaId)) {
  64 + sb.append(getName1(areaId,basicConfigService));
  65 + }
  66 + if (StringUtils.isNotEmpty(streetId)){
  67 + sb.append(getName1(streetId,basicConfigService));
  68 + }
  69 + if (StringUtils.isNotEmpty(address)) {
  70 + sb.append(address);
  71 + }
  72 + return sb.toString();
  73 + }
  74 +
  75 +
51 76 private static String getName1(String id, BasicConfigService basicConfigService) {
52 77 BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id);
53 78 if (basicConfig != null) {