Commit 5d7d952e5ea9a1be86620150ef42e136444c1667

Authored by cfl
1 parent 561c9723cd
Exists in master and in 1 other branch dev

目前bug修改内容

Showing 16 changed files with 210 additions and 111 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java View file @ 5d7d952
... ... @@ -130,12 +130,7 @@
130 130 groupnames.add(patient.getPname());
131 131 //患者注册环信
132 132 if (StringUtil.isEmpty(patient.getHxid())) {
133   - JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
134   - JSONArray rArr = json.getJSONArray("entities");
135   - if (rArr.size() > 0) {
136   - patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
137   - lymsPatientService.updateById(patient);
138   - }
  133 + patient = lymsPatientService.addPatientHxId(patient);
139 134 }
140 135 //查询值班医生
141 136 List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>()
... ... @@ -145,12 +140,7 @@
145 140 //科室值班医生注册环信
146 141 for (LymsDoctor lymsDoctor : doctorAminList) {
147 142 if(StringUtil.isEmpty(lymsDoctor.getHxid())) {
148   - JSONObject json = hxService.addUser(lymsDoctor.getDlogin(), Constant.COMMON_PASSWD, lymsDoctor.getDname());
149   - JSONArray rArr = json.getJSONArray("entities");
150   - if (rArr.size() > 0) {
151   - lymsDoctor.setHxid(rArr.getJSONObject(0).getString("uuid"));
152   - lymsDoctorService.updateById(lymsDoctor);
153   - }
  143 + lymsDoctorService.addDoctorHxId(lymsDoctor);
154 144 }
155 145 adminDlogins.add(lymsDoctor.getDlogin());
156 146 groupnames.add(lymsDoctor.getDname());
... ... @@ -158,12 +148,7 @@
158 148 if ( ! adminDlogins.contains(doctor.getDlogin())) {
159 149 //医生注册环信
160 150 if (StringUtil.isEmpty(doctor.getHxid())) {
161   - JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname());
162   - JSONArray rArr = json.getJSONArray("entities");
163   - if (rArr.size() > 0) {
164   - doctor.setHxid(rArr.getJSONObject(0).getString("uuid"));
165   - lymsDoctorService.updateById(doctor);
166   - }
  151 + lymsDoctorService.addDoctorHxId(doctor);
167 152 adminDlogins.add(doctor.getDlogin());
168 153 groupnames.add(doctor.getDname());
169 154 }
170 155  
171 156  
... ... @@ -328,16 +313,16 @@
328 313  
329 314 payload.put("unread_num", row.get("unread_num"));
330 315  
331   - String to = payload.getString("to");
  316 + String hxgroupid = payload.getString("to");
332 317 LymsTkrecord tkrecord = new LymsTkrecord();
333   - tkrecord.setHxgroupid(to);
334   - List<LymsTkrecord> rLst = lymsTkrecordService.list(Wrappers.query(tkrecord));
  318 + tkrecord.setHxgroupid(hxgroupid);
  319 + List<LymsTkrecord> rLst = lymsTkrecordService.list(Wrappers.query(tkrecord).orderByDesc("createdtime"));
335 320 payload.put("stat", 0);
336 321 if (rLst.size() > 0) {
337 322 payload.put("stat", rLst.get(0).getStat());
338 323 }
339 324 LymsChatgroup chatgroup = new LymsChatgroup();
340   - chatgroup.setHxgroupid(to);
  325 + chatgroup.setHxgroupid(hxgroupid);
341 326 List<LymsChatgroup> cLst = lymsChatgroupService.list(Wrappers.query(chatgroup));
342 327  
343 328 if (cLst.size() > 0) {
... ... @@ -370,7 +355,7 @@
370 355 getChatRecord(rs, jsonObject);
371 356  
372 357 } catch (IOException e) {
373   - e.printStackTrace();
  358 + log.error("getSessionListInfo exception",e);
374 359 }
375 360 baseResponse.setObject(rs);
376 361 return baseResponse;
377 362  
... ... @@ -559,12 +544,14 @@
559 544 final boolean b = lymsChatgroupService.updateById(chatgroup);
560 545 if(!b){
561 546 baseResponse.setErrorcode(1);
  547 + log.error("updateGroupStat回滚LymsChatgroup失败,{}",chatgroup);
562 548 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
563 549 }
564 550 final PatientInfo patientInfo = patientInfoService.getOne(new QueryWrapper<PatientInfo>()
565 551 .lambda().eq(PatientInfo::getCid, chatgroup.getPcid()));
566 552 if (null==patientInfo) {
567 553 baseResponse.setErrorcode(1);
  554 + log.error("updateGroupStat回滚查询患者信息失败,{}",chatgroup);
568 555 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
569 556 }
570 557 LymsTkrecord tkrecord=new LymsTkrecord();
571 558  
572 559  
573 560  
... ... @@ -572,27 +559,25 @@
572 559 tcard.setPid(patientInfo.getId());
573 560 tcard.setPcid(patientInfo.getCid());
574 561 // 获取问诊卡按照先从医院购买的问诊卡消费
575   - List<LymsTcard> rLst = lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid"));
576   -
577   -// 小程序购买的问诊卡
578   - tcard.setPcid(null);
579   - tcard.setFid(1);
580   - List<LymsTcard> xLst = lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid"));
581   -
582   - if (rLst.size() > 0 || xLst.size() > 0) {
583   - if (rLst.size() > 0) {
584   - tkrecord.setCid(rLst.get(0).getId());
585   - tkrecord.setFid((byte) 2);
586   - } else {
  562 + List<LymsTcard> rLst = lymsTcardService.queryUnused(tcard);
  563 + if (rLst.size() > 0) {
  564 + tkrecord.setCid(rLst.get(0).getId());
  565 + tkrecord.setFid((byte) 2);
  566 + }else{
  567 + //小程序购买的问诊卡
  568 + tcard.setPcid(null);
  569 + tcard.setFid(1);
  570 + List<LymsTcard> xLst = lymsTcardService.queryUnused(tcard);//lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid"));
  571 + if (xLst.size() > 0) {
587 572 tkrecord.setCid(xLst.get(0).getId());
588 573 tkrecord.setFid((byte) 1);
  574 + }else{
  575 + baseResponse.setErrorcode(1);
  576 + throw new RuntimeException("已经没有咨询卡,请联系客服购买!");
589 577 }
590   -
591   - } else {
592   - baseResponse.setErrorcode(1);
593   - throw new RuntimeException("已经没有咨询卡,请联系客服购买!");
594 578 }
595 579  
  580 +
596 581 tkrecord.setPid(patientInfo.getId());
597 582 tkrecord.setPcid(patientInfo.getCid());
598 583 tkrecord.setDid(patientInfo.getDtid());
... ... @@ -602,6 +587,7 @@
602 587 final boolean save = lymsTkrecordService.save(tkrecord);
603 588 if (!save) {
604 589 baseResponse.setErrorcode(1);
  590 + log.error("updateGroupStat回滚保存tkrecode失败,{}",chatgroup);
605 591 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
606 592 }
607 593 //修改同一群组记录的状态
... ... @@ -619,7 +605,7 @@
619 605 baseResponse.setErrormsg("成功");
620 606 } catch (Exception e) {
621 607 baseResponse.setErrorcode(1);
622   - e.printStackTrace();
  608 + log.error("updateGroupStat异常",e);
623 609 //这里想触发事务回滚需抛运行时异常
624 610 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
625 611 }
626 612  
... ... @@ -691,13 +677,24 @@
691 677 * @param jsonObject 参数集合
692 678 */
693 679 public void getChatRecord(JSONArray rs,JSONObject jsonObject){
694   - JSONArray rsrjson=new JSONArray();
695 680 //环信组id
696 681 JSONArray groupData=jsonObject.getJSONArray("groupData");
697 682 List<String> groupidList=new ArrayList<>();
698 683 for (Object groupDatum : groupData) {
699 684 groupidList.add(((JSONObject) JSON.toJSON(groupDatum)).get("groupid").toString());
700 685 }
  686 +
  687 + //如果结果集中包含了该聊天组,过滤掉
  688 + for (int i=0;i< rs.size(); i++) {
  689 + JSONObject rjson = (JSONObject) JSON.toJSON(rs.get(i));
  690 + if(groupidList.contains(rjson.get("to").toString())){
  691 + groupidList.remove(rjson.get("to").toString());
  692 + }
  693 + }
  694 + if(groupidList.size() == 0){
  695 + return;
  696 + }
  697 +
701 698 LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper=new QueryWrapper().lambda();
702 699 chatgroupQueryWrapper.in(LymsChatgroup::getHxgroupid,groupidList);
703 700 List<LymsChatgroup> chatgroupList=lymsChatgroupService.list(chatgroupQueryWrapper);
704 701  
... ... @@ -735,26 +732,9 @@
735 732 reusltJsonObject.put("to",lymsChatgroup.getHxgroupid());
736 733 reusltJsonObject.put("type","groupchat");
737 734 reusltJsonObject.put("timestamp",lymsMessageList.size()>0?lymsMessageList.get(0).getSendtime().getTime():"");
738   - if (CollectionUtils.isEmpty(rs)) {
739   - rsrjson.add(reusltJsonObject);
740   - }else {
741   - for (int i=0;i<rs.size();i++) {
742   - JSONObject rjson = (JSONObject) JSON.toJSON(rs.get(i));
743   - if (rjson.get("to").toString().equals(lymsChatgroup.getHxgroupid())) {
744   - break;
745   - }
746   - if(i==rs.size()-1){
747   - rsrjson.add(reusltJsonObject);
748   - }
749   - }
750   -
751   - }
752   -
  735 + rs.add(reusltJsonObject);
753 736 }
754   - //结果集中添加
755   - for (Object o : rsrjson) {
756   - rs.add(o);
757   - }
  737 +
758 738 }
759 739 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java View file @ 5d7d952
... ... @@ -130,7 +130,7 @@
130 130 tWrapper.in("pid", pids);
131 131 int sum = lymsTcardService.list(tWrapper).parallelStream().mapToInt(LymsTcard::getCnt).sum();
132 132  
133   - log.error("统计需要改动数据结构:daiCnt:{} sum:{}", daiCnt, sum);
  133 + log.info("统计需要改动数据结构:daiCnt:{} sum:{}", daiCnt, sum);
134 134 baseResponse.setObject(patientPagePage);
135 135  
136 136 return baseResponse;
... ... @@ -1050,7 +1050,7 @@
1050 1050 /**
1051 1051 * 小程序关注患者
1052 1052 *
1053   - * @param patient
  1053 + * @param
1054 1054 * @return
1055 1055 */
1056 1056 @PostMapping("addPatientAttention")
... ... @@ -1077,7 +1077,7 @@
1077 1077 /**
1078 1078 * 查询患者是否关注了公众号
1079 1079 *
1080   - * @param patient
  1080 + * @param gzopengId
1081 1081 * @return
1082 1082 */
1083 1083 @GetMapping("getPatientAttentionYn")
... ... @@ -1105,7 +1105,7 @@
1105 1105 /**
1106 1106 * 小程序取消关注患者
1107 1107 *
1108   - * @param patient
  1108 + * @param patientAttention
1109 1109 * @return
1110 1110 */
1111 1111 @PostMapping("cancelPatientAttention")
... ... @@ -1170,7 +1170,7 @@
1170 1170  
1171 1171 /**
1172 1172 * PC-查看医生回访推送公众号记录
1173   - * @param getPushVisitRecord
  1173 + * @param visitRecord
1174 1174 * @param current
1175 1175 * @param size
1176 1176 * @return
... ... @@ -1258,7 +1258,7 @@
1258 1258 /**
1259 1259 * PC新模块删除患者
1260 1260 *
1261   - * @param patient
  1261 + * @param id
1262 1262 * @return
1263 1263 */
1264 1264 @DeleteMapping("delBookbuildingPatient")
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java View file @ 5d7d952
... ... @@ -103,19 +103,7 @@
103 103  
104 104 //患者注册环信
105 105 if (StringUtil.isEmpty(patient.getHxid())) {
106   - JSONObject hxUserJSON = hxService.getUser(patient.getIdno());
107   - if(hxUserJSON != null && hxUserJSON.getJSONArray("entities") != null && hxUserJSON.getJSONArray("entities").size() > 0){
108   - patient.setHxid(hxUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
109   - lymsPatientService.updateById(patient);
110   - }else{
111   - JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
112   - JSONArray rArr = json.getJSONArray("entities");
113   - if (rArr.size() > 0) {
114   - patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
115   - lymsPatientService.updateById(patient);
116   - }
117   - }
118   -
  106 + patient = lymsPatientService.addPatientHxId(patient);
119 107 }
120 108  
121 109 group.setOwnerk(hxuser);
... ... @@ -131,18 +119,7 @@
131 119 //科室值班医生注册环信
132 120 for (LymsDoctor lymsDoctor : doctorAminList) {
133 121 if (StringUtil.isEmpty(lymsDoctor.getHxid())) {
134   - JSONObject hxDockerUserJSON = hxService.getUser(lymsDoctor.getDlogin());
135   - if (hxDockerUserJSON != null && hxDockerUserJSON.getJSONArray("entities") != null && hxDockerUserJSON.getJSONArray("entities").size() > 0) {
136   - lymsDoctor.setHxid(hxDockerUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
137   - lymsDoctorService.updateById(lymsDoctor);
138   - } else {
139   - JSONObject json = hxService.addUser(lymsDoctor.getDlogin(), Constant.COMMON_PASSWD, lymsDoctor.getDname());
140   - JSONArray rArr = json.getJSONArray("entities");
141   - if (rArr.size() > 0) {
142   - lymsDoctor.setHxid(rArr.getJSONObject(0).getString("uuid"));
143   - lymsDoctorService.updateById(lymsDoctor);
144   - }
145   - }
  122 + lymsDoctor = lymsDoctorService.addDoctorHxId(lymsDoctor);
146 123 adminDlogins.add(lymsDoctor.getDlogin());
147 124 groupnames.add(lymsDoctor.getDname());
148 125 }
... ... @@ -151,18 +128,7 @@
151 128 if ( ! adminDlogins.contains(doctor.getDlogin())) {
152 129 //医生注册环信
153 130 if (StringUtil.isEmpty(doctor.getHxid())) {
154   - JSONObject hxDockerJSON = hxService.getUser(doctor.getDlogin());
155   - if (hxDockerJSON != null && hxDockerJSON.getJSONArray("entities") != null && hxDockerJSON.getJSONArray("entities").size() > 0) {
156   - doctor.setHxid(hxDockerJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
157   - lymsDoctorService.updateById(doctor);
158   - }else {
159   - JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname());
160   - JSONArray rArr = json.getJSONArray("entities");
161   - if (rArr.size() > 0) {
162   - doctor.setHxid(rArr.getJSONObject(0).getString("uuid"));
163   - lymsDoctorService.updateById(doctor);
164   - }
165   - }
  131 + doctor = lymsDoctorService.addDoctorHxId(doctor);
166 132 }
167 133 adminDlogins.add(doctor.getDlogin());
168 134 groupnames.add(doctor.getDname());
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTkrecordMapper.java View file @ 5d7d952
... ... @@ -7,6 +7,9 @@
7 7 * @Entity com.lyms.talkonlineweb.domain.LymsTkrecord
8 8 */
9 9 public interface LymsTkrecordMapper extends BaseMapper<LymsTkrecord> {
10   -
  10 + /**
  11 + * 批量修改未结束的聊天记录为结束
  12 + */
  13 + void batchUpdateStatEnd();
11 14 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsDoctorService.java View file @ 5d7d952
... ... @@ -11,5 +11,7 @@
11 11 public interface LymsDoctorService extends IService<LymsDoctor> {
12 12  
13 13 Map<String, Object> statDoctor(Integer hid,Integer dpid,String dname);
  14 +
  15 + LymsDoctor addDoctorHxId(LymsDoctor doctor);
14 16 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientService.java View file @ 5d7d952
... ... @@ -18,5 +18,7 @@
18 18 List<Map> getPatient(QueryWrapper queryWrapper);
19 19  
20 20 List<Map<String,Object>> getPcInfoList();
  21 +
  22 + LymsPatient addPatientHxId(LymsPatient patient);
21 23 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTkrecordService.java View file @ 5d7d952
... ... @@ -7,6 +7,10 @@
7 7 *
8 8 */
9 9 public interface LymsTkrecordService extends IService<LymsTkrecord> {
  10 + /**
  11 + * 批量修改未结束的聊天记录为结束
  12 + */
  13 + void batchUpdateStatEnd();
10 14  
11 15 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsDoctorServiceImpl.java View file @ 5d7d952
1 1 package com.lyms.talkonlineweb.service.impl;
2 2  
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.alibaba.fastjson.JSONObject;
3 5 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 6 import com.lyms.talkonlineweb.domain.LymsDoctor;
5 7 import com.lyms.talkonlineweb.service.LymsDoctorService;
6 8 import com.lyms.talkonlineweb.mapper.LymsDoctorMapper;
  9 +import com.lyms.talkonlineweb.util.Constant;
  10 +import com.lyms.talkonlineweb.util.HXService;
7 11 import org.springframework.beans.factory.annotation.Autowired;
8 12 import org.springframework.stereotype.Service;
9 13  
  14 +import javax.annotation.Resource;
10 15 import java.util.Map;
11 16  
12 17 /**
13 18  
14 19  
... ... @@ -16,12 +21,32 @@
16 21 public class LymsDoctorServiceImpl extends ServiceImpl<LymsDoctorMapper, LymsDoctor>
17 22 implements LymsDoctorService{
18 23  
19   - @Autowired
  24 + @Resource
20 25 private LymsDoctorMapper lymsDoctorMapper;
21 26  
  27 + @Autowired
  28 + private HXService hxService;
  29 +
22 30 @Override
23 31 public Map<String, Object> statDoctor(Integer hid,Integer dpid,String dname) {
24 32 return lymsDoctorMapper.statDoctor(hid,dpid,dname);
  33 + }
  34 +
  35 + @Override
  36 + public LymsDoctor addDoctorHxId(LymsDoctor lymsDoctor) {
  37 + JSONObject hxDockerUserJSON = hxService.getUser(lymsDoctor.getDlogin());
  38 + if (hxDockerUserJSON != null && hxDockerUserJSON.getJSONArray("entities") != null && hxDockerUserJSON.getJSONArray("entities").size() > 0) {
  39 + lymsDoctor.setHxid(hxDockerUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
  40 + updateById(lymsDoctor);
  41 + } else {
  42 + JSONObject json = hxService.addUser(lymsDoctor.getDlogin(), Constant.COMMON_PASSWD, lymsDoctor.getDname());
  43 + JSONArray rArr = json.getJSONArray("entities");
  44 + if (rArr.size() > 0) {
  45 + lymsDoctor.setHxid(rArr.getJSONObject(0).getString("uuid"));
  46 + updateById(lymsDoctor);
  47 + }
  48 + }
  49 + return lymsDoctor;
25 50 }
26 51 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientServiceImpl.java View file @ 5d7d952
1 1 package com.lyms.talkonlineweb.service.impl;
2 2  
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.alibaba.fastjson.JSONObject;
3 5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 6 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 7 import com.lyms.talkonlineweb.domain.LymsPatient;
6 8 import com.lyms.talkonlineweb.service.LymsPatientService;
7 9 import com.lyms.talkonlineweb.mapper.LymsPatientMapper;
  10 +import com.lyms.talkonlineweb.util.Constant;
  11 +import com.lyms.talkonlineweb.util.HXService;
8 12 import org.springframework.beans.factory.annotation.Autowired;
9 13 import org.springframework.stereotype.Service;
10 14  
... ... @@ -20,6 +24,10 @@
20 24  
21 25 @Autowired
22 26 private LymsPatientMapper lymsPatientMapper;
  27 +
  28 + @Autowired
  29 + private HXService hxService;
  30 +
23 31 @Override
24 32 public List<Map<String,String>> getAppPatientHospital(Integer patientId) {
25 33 return lymsPatientMapper.getAppPatientHospital(patientId);
... ... @@ -33,6 +41,25 @@
33 41 @Override
34 42 public List<Map<String,Object>> getPcInfoList() {
35 43 return lymsPatientMapper.getPcInfoList();
  44 + }
  45 +
  46 + @Override
  47 + public LymsPatient addPatientHxId(LymsPatient patient) {
  48 +
  49 + JSONObject hxUserJSON = hxService.getUser(patient.getIdno());
  50 + if(hxUserJSON != null && hxUserJSON.getJSONArray("entities") != null && hxUserJSON.getJSONArray("entities").size() > 0){
  51 + patient.setHxid(hxUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid"));
  52 + updateById(patient);
  53 + }else{
  54 + JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname());
  55 + JSONArray rArr = json.getJSONArray("entities");
  56 + if (rArr.size() > 0) {
  57 + patient.setHxid(rArr.getJSONObject(0).getString("uuid"));
  58 + updateById(patient);
  59 + }
  60 + }
  61 +
  62 + return patient;
36 63 }
37 64 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTkrecordServiceImpl.java View file @ 5d7d952
... ... @@ -13,5 +13,9 @@
13 13 public class LymsTkrecordServiceImpl extends ServiceImpl<LymsTkrecordMapper, LymsTkrecord>
14 14 implements LymsTkrecordService{
15 15  
  16 + @Override
  17 + public void batchUpdateStatEnd() {
  18 +
  19 + }
16 20 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AutoEndChatTask.java View file @ 5d7d952
  1 +package com.lyms.talkonlineweb.task;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5 +import com.lyms.talkonlineweb.domain.LymsChatgroup;
  6 +import com.lyms.talkonlineweb.domain.LymsTkrecord;
  7 +import com.lyms.talkonlineweb.service.LymsChatgroupService;
  8 +import com.lyms.talkonlineweb.service.LymsTkrecordService;
  9 +import lombok.extern.log4j.Log4j2;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.scheduling.annotation.Scheduled;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.Date;
  15 +import java.util.List;
  16 +import java.util.stream.Collectors;
  17 +
  18 +/**
  19 + * 每天12点,自动结束患者聊天
  20 + * cfl
  21 + */
  22 +@Component
  23 +@Log4j2
  24 +public class AutoEndChatTask {
  25 +
  26 + @Autowired
  27 + private LymsTkrecordService lymsTkrecordService;
  28 + @Autowired
  29 + private LymsChatgroupService lymsChatgroupService;
  30 +
  31 + @Scheduled(cron = "0 59 23 * * ?")
  32 + public void PushIllnessTypeData(){
  33 +
  34 + log.info("自动结束聊天任务开始>>>>>>>>>>auto end chart");
  35 + LymsTkrecord tkrecord = new LymsTkrecord();
  36 + tkrecord.setStat(0);
  37 + List<LymsTkrecord> recordList = lymsTkrecordService.list(Wrappers.query(tkrecord));
  38 + int size = recordList.size();
  39 +
  40 + log.info("自动结束聊天任务开始>>>>>>>>>>size = {}",size);
  41 +
  42 + if(size == 0){
  43 + return;
  44 + }
  45 +
  46 + for(int i = 0; i < size ; i++ ){
  47 + LymsTkrecord lymsTkrecord = recordList.get(i);
  48 + lymsTkrecord.setStat(1);
  49 + lymsTkrecord.setUpdatedby(1);
  50 + lymsTkrecord.setUpdatedtime(new Date());
  51 + try{
  52 + boolean b = lymsTkrecordService.updateById(lymsTkrecord);
  53 + }catch (Exception e){
  54 + log.error("自动结束聊天记录异常",e);
  55 + }
  56 + }
  57 +
  58 + List<String> hxGroupIds = recordList.stream().map(LymsTkrecord::getHxgroupid).distinct().collect(Collectors.toList());
  59 +
  60 + log.info("自动结束聊天任务需更新聊天组>>>>>>>>>>size = {}",hxGroupIds.size());
  61 +
  62 + List<LymsChatgroup> hxGroupList = lymsChatgroupService.list(new QueryWrapper<LymsChatgroup>()
  63 + .lambda().in(LymsChatgroup::getHxgroupid, hxGroupIds));
  64 +
  65 + for(int i = 0;i < hxGroupList.size(); i++){
  66 + LymsChatgroup lymsChatgroup = hxGroupList.get(i);
  67 + lymsChatgroup.setStat(1);
  68 + try{
  69 + lymsChatgroupService.updateById(lymsChatgroup);
  70 + }catch (Exception e){
  71 + log.error("自动结束聊天组异常",e);
  72 + }
  73 +
  74 + }
  75 +
  76 + }
  77 +
  78 +
  79 +
  80 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/GetPatientInfoTask.java View file @ 5d7d952
... ... @@ -64,7 +64,7 @@
64 64 * 获取医院患者信息。添加到问诊平台患者信息
65 65 * 10分钟执行一次
66 66 */
67   - @Scheduled(cron = "0 */10 * * * ?")
  67 + // @Scheduled(cron = "0 */10 * * * ?")
68 68 // @Scheduled(cron = "0 */5 * * * ?")//测试用
69 69 public void getPatientInfo() throws Exception {
70 70 if(!on_off){
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HXTask.java View file @ 5d7d952
... ... @@ -30,7 +30,7 @@
30 30 @Autowired
31 31 private LymsDictService lymsDictService;
32 32  
33   -// @Scheduled(initialDelay=10000, fixedRate=60000)
  33 + @Scheduled(initialDelay=10000, fixedRate=60000)
34 34 public void checkDoctorStat(){
35 35 Map<String,Object> param=new HashMap<>();
36 36  
talkonlineweb/src/main/resources/application.yml View file @ 5d7d952
... ... @@ -11,7 +11,7 @@
11 11 resources:
12 12 add-mappings: false
13 13 profiles:
14   - active: prod
  14 + active: dev
15 15 logging:
16 16 config: classpath:logback-spring.xml
17 17  
talkonlineweb/src/main/resources/mapper/LymsTcardMapper.xml View file @ 5d7d952
... ... @@ -25,8 +25,8 @@
25 25 <select id="queryUnused" parameterType="com.lyms.talkonlineweb.domain.LymsTcard" resultMap="BaseResultMap">
26 26  
27 27 select
28   - <include refid="Base_Column_List"></include>
29   - from lyms_tcard card
  28 + <include refid="Base_Column_List"></include>
  29 + from lyms_tcard card
30 30 where 1 = 1
31 31 <if test="pid != null">
32 32 and card.pid = #{pid}
... ... @@ -39,7 +39,7 @@
39 39 </if>
40 40 and not EXISTS ( SELECT r.cid FROM lyms_tkrecord r where r.cid = card.id )
41 41 order by
42   - card.fid desc,card.createdtime ASC
  42 + card.fid desc,card.createdtime ASC
43 43  
44 44 </select>
45 45 </mapper>
talkonlineweb/src/main/resources/mapper/LymsTkrecordMapper.xml View file @ 5d7d952
... ... @@ -24,5 +24,11 @@
24 24 stat,createdby,createdtime,
25 25 updatedby,updatedtime
26 26 </sql>
  27 +
  28 + <update id="batchUpdateStatEnd">
  29 + update lyms_tkrecode
  30 + set stat = 1
  31 + where stat = 0
  32 + </update>
27 33 </mapper>