Commit 0c28af75225fbe2fe54f71de2c4c8982d13c7d1c

Authored by hujiaqi

Merge remote-tracking branch 'origin/master'

Showing 6 changed files

platform-dal/src/main/java/com/lyms/platform/pojo/PatientCheckTicket.java View file @ 0c28af7
... ... @@ -17,10 +17,19 @@
17 17 private String id;
18 18 private String patientId;
19 19 private String hospitalId;
  20 + private String pid;
20 21 private String consumeHospitalId;
21 22 private Integer status; // 1:创建未使用, 2:产检使用,3:分娩销毁
22 23 private Date created;
23 24 private Date consumeDate;
  25 +
  26 + public String getPid() {
  27 + return pid;
  28 + }
  29 +
  30 + public void setPid(String pid) {
  31 + this.pid = pid;
  32 + }
24 33  
25 34 public String getId() {
26 35 return id;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UpdateController.java View file @ 0c28af7
... ... @@ -2,9 +2,11 @@
2 2  
3 3 import com.lyms.platform.common.base.BaseController;
4 4 import com.lyms.platform.common.constants.ErrorCodeConstants;
  5 +import com.lyms.platform.common.result.BaseResponse;
5 6 import com.lyms.platform.common.utils.ExceptionUtils;
6 7 import com.lyms.platform.common.utils.StringUtils;
7 8 import com.lyms.platform.operate.web.facade.CorrectDataFacade;
  9 +import com.lyms.platform.operate.web.facade.PatientCheckTicketFacade;
8 10 import org.springframework.beans.factory.annotation.Autowired;
9 11 import org.springframework.stereotype.Controller;
10 12 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -27,6 +29,8 @@
27 29 @Autowired
28 30 private CorrectDataFacade correctDataFacade;
29 31  
  32 + @Autowired
  33 + private PatientCheckTicketFacade patientCheckTicketFacade;
30 34 @RequestMapping(value = "/updateData", method = RequestMethod.GET)
31 35 @ResponseBody
32 36 private Map<String, String> updateCorrectData(@RequestParam("hId") String hId) {
... ... @@ -44,6 +48,18 @@
44 48 ExceptionUtils.catchException(e, "updateCorrectData Error. hospitalId:" + hId);
45 49 }
46 50 return result;
  51 + }
  52 +
  53 + /**
  54 + * 补发指定医院的产检劵
  55 + *
  56 + * @param hId
  57 + * @return
  58 + */
  59 + @RequestMapping(value = "/supplyCheckTicket", method = RequestMethod.GET)
  60 + @ResponseBody
  61 + private BaseResponse supplyCheckTicket(@RequestParam("hId")String hId){
  62 + return patientCheckTicketFacade.supplyCheckTicket(hId);
47 63 }
48 64 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java View file @ 0c28af7
... ... @@ -229,12 +229,23 @@
229 229 antExQuery.setPid(e.getPid());
230 230 antExQuery.setYn(YnEnums.YES.getId());
231 231 antExQuery.setHospitalId(null);
  232 + antExQuery.setStart(e.getCheckTime());
232 233 antExChuQuery.setPid(e.getPid());
233 234 antExChuQuery.setYn(YnEnums.YES.getId());
234 235 antExChuQuery.setHospitalId(null);
  236 + antExChuQuery.setStart(e.getCheckTime());
235 237  
236 238  
237   - int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery());
  239 +
  240 + AntExRecordQuery antExRecordQuery1=new AntExRecordQuery();
  241 + antExRecordQuery1.setCheckTimeEnd(e.getCheckTime());
  242 + antExRecordQuery1.setPid(e.getPid());
  243 + antExRecordQuery1.setHospitalId(hospital);
  244 +
  245 + //本院低次
  246 + int dichi =recordService.count(antExRecordQuery1);
  247 + antExRecordQuery1.setHospitalId(null);
  248 + /* int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery());
238 249 antExChuQuery.setHospitalId(null);
239 250 int b = antExService.queryAntExChuCount(antExChuQuery.convertToQuery());
240 251 antExQuery.setHospitalId(hospital);
... ... @@ -242,9 +253,9 @@
242 253 int chi = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery());
243 254 antExChuQuery.setHospitalId(hospital);
244 255 //本院的初诊记录
245   - int chb = antExService.queryAntExChuCount(antExChuQuery.convertToQuery());
246   - antExManagerResult.settTimes(i + b);
247   - antExManagerResult.setChTimes(chi + chb);
  256 + int chb = antExService.queryAntExChuCount(antExChuQuery.convertToQuery());*/
  257 + antExManagerResult.settTimes(recordService.count(antExRecordQuery1));
  258 + antExManagerResult.setChTimes(dichi);
248 259 //高危因素
249 260 antExManagerResult.setrLevel(commonService.findRiskLevel(e.gethLevel()));
250 261 antExManagerResult.setRiskFactor(commonService.resloveFactor(e.gethRisk()));
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ 0c28af7
... ... @@ -261,6 +261,7 @@
261 261 ticket.setPatientId(p.getId());
262 262 ticket.setCreated(new Date());
263 263 ticket.setId("0335" + ticketPid + i);
  264 + ticket.setPid(p.getPid());
264 265 patientCheckTicketService.addTicket(ticket);
265 266 }
266 267  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/FolicAcidFacade.java View file @ 0c28af7
... ... @@ -31,8 +31,10 @@
31 31 import org.apache.commons.collections.CollectionUtils;
32 32 import org.apache.commons.lang.StringUtils;
33 33 import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.data.domain.Sort;
34 35 import org.springframework.stereotype.Component;
35 36  
  37 +import javax.jws.Oneway;
36 38 import javax.servlet.http.HttpServletResponse;
37 39 import java.io.OutputStream;
38 40 import java.util.*;
... ... @@ -198,6 +200,7 @@
198 200 }
199 201 }
200 202 }
  203 + List<Map> list = new ArrayList<>();
201 204  
202 205 if (archiveModel!=null){
203 206 //妇女信息
... ... @@ -206,7 +209,7 @@
206 209 archiveMap.put("certificateTypeId", archiveModel.getCertificateTypeId());
207 210 archiveMap.put("username", archiveModel.getUsername());
208 211 archiveMap.put("birthday",archiveModel.getBirthday() != null ? DateUtil.getyyyy_MM_dd(archiveModel.getBirthday()) : null);
209   - archiveMap.put("age", archiveModel.getBirthday() != null ? "" : DateUtil.getAge(archiveModel.getBirthday()));
  212 + archiveMap.put("age", archiveModel.getBirthday() == null ? "" : DateUtil.getAge(archiveModel.getBirthday()));
210 213 archiveMap.put("phone", archiveModel.getPhone());
211 214 archiveMap.put("id", archiveModel.getId());
212 215 if (StringUtils.isEmpty(archiveModel.getSex()) || archiveModel.getSex().equals(SystemConfig.WOMAN_ID )){
213 216  
214 217  
215 218  
... ... @@ -220,15 +223,94 @@
220 223 archiveMap.put("workUnit",archiveModel.getWorkUnit());
221 224 archiveMap.put("buildDay",archiveModel.getBuildDay());
222 225  
  226 + //获取历史发放记录
  227 + FolicAcidQuery folicAcidQuery = new FolicAcidQuery();
  228 + folicAcidQuery.setYn(YnEnums.YES.getId());
  229 + folicAcidQuery.setParentId(archiveModel.getId());
  230 +
  231 + List<String> hospitalList = null;
  232 + //判断当前用户是否有区域权限
  233 + if (userId!=null){
  234 + hospitalList = new ArrayList<>();
  235 + String hospital = autoMatchFacade.getHospitalId(userId);
  236 + if(null!=hospital){
  237 + //本院
  238 + hospitalList.add(hospital);
  239 + }
  240 + //查询用户是否有区域权限
  241 + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery();
  242 + dataPermissionsModelQuery.setUserId(userId);
  243 + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery);
  244 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  245 + Set<String> set = permissionsModels.get(0).getData().keySet();
  246 + Iterator<String> it = set.iterator();
  247 + while (it.hasNext()) {
  248 + String id = it.next();
  249 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) {
  250 + hospitalList.add(id);
  251 + }
  252 + }
  253 + }
  254 + folicAcidQuery.setHospitalList(hospitalList);
  255 + }
  256 + List<FolicAcid> folicAcidList = folicAcidService.queryFolicAcidWithSort(folicAcidQuery, "drawTime", Sort.Direction.DESC);
  257 + if (CollectionUtils.isNotEmpty(folicAcidList)){
  258 +
  259 + //返回第一条数据
  260 + folicAcid = folicAcidList.get(0);
  261 +
  262 + for (FolicAcid data: folicAcidList){
  263 + Map<String,Object> acidMap = new HashMap<>();
  264 + if (data.getPregnancyType()!=null){
  265 + if (data.getPregnancyType()==1){
  266 + acidMap.put("pregnancyType","孕前");
  267 + }else if (data.getPregnancyType()==2){
  268 + acidMap.put("pregnancyType",data.getPregnancyWeeks());
  269 + }
  270 + }
  271 + acidMap.put("drawCount",data.getDrawCount());
  272 + acidMap.put("drawTime",DateUtil.getyyyy_MM_dd(data.getDrawTime()));
  273 + if (StringUtils.isNotEmpty(data.getHospitalId())){
  274 + if (data.getHospitalId().equals(hospitalId)){
  275 + acidMap.put("other",1);
  276 + }else {
  277 + acidMap.put("other",2);
  278 + }
  279 + }
  280 + list.add(acidMap);
  281 + }
  282 + }
223 283 }
224   - resultMap.put("folicAcidResult",folicAcid);
  284 + resultMap.put("folicAcidResult",getFolic(folicAcid));
225 285 resultMap.put("archiveResult",archiveMap);
  286 + resultMap.put("folicAcidHistory",list);
226 287 BaseObjectResponse response = new BaseObjectResponse();
227 288 response.setData(resultMap);
228 289 response.setErrorcode(ErrorCodeConstants.SUCCESS);
229 290 response.setErrormsg("成功");
230 291 return response;
231 292 }
  293 +
  294 + public Map<String,Object> getFolic(FolicAcid folicAcid){
  295 + if (folicAcid==null){
  296 + return null;
  297 + }
  298 + Map<String,Object> map= new HashMap<>();
  299 + map.put("id",folicAcid.getId());
  300 + map.put("created",DateUtil.getyyyy_MM_dd(folicAcid.getCreated()));
  301 + map.put("drawTime",DateUtil.getyyyy_MM_dd(folicAcid.getDrawTime()));
  302 + map.put("drawCount",folicAcid.getDrawCount());
  303 + map.put("highRisk",folicAcid.getHighRisk());
  304 + map.put("hospitalId",folicAcid.getHospitalId());
  305 + map.put("hospitalName",folicAcid.getHospitalName());
  306 + map.put("operator",folicAcid.getOperator());
  307 + map.put("operatorId",folicAcid.getOperatorId());
  308 + map.put("parentId",folicAcid.getParentId());
  309 + map.put("pregnancyType",folicAcid.getPregnancyType());
  310 + map.put("pregnancyWeeks",folicAcid.getPregnancyWeeks());
  311 + return map;
  312 + }
  313 +
232 314  
233 315 public BaseListResponse queryFolicAcid(FolicAcidQueryRequest queryRequest,Integer userId){
234 316  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCheckTicketFacade.java View file @ 0c28af7
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.AutoIncermentService;
  4 +import com.lyms.platform.biz.service.PatientCheckTicketService;
  5 +import com.lyms.platform.biz.service.PatientsService;
  6 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  7 +import com.lyms.platform.common.enums.YnEnums;
  8 +import com.lyms.platform.common.result.BaseResponse;
  9 +import com.lyms.platform.common.utils.ExceptionUtils;
  10 +import com.lyms.platform.operate.web.worker.WorkHR;
  11 +import com.lyms.platform.pojo.PatientCheckTicket;
  12 +import com.lyms.platform.pojo.Patients;
  13 +import com.lyms.platform.query.PatientCheckTicketQuery;
  14 +import com.lyms.platform.query.PatientsQuery;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import java.util.ArrayList;
  19 +import java.util.Date;
  20 +import java.util.List;
  21 +import java.util.concurrent.Future;
  22 +
  23 +/**
  24 + * 产检劵补发
  25 + * <p/>
  26 + * Created by Administrator on 2017/1/5 0005.
  27 + */
  28 +@Component
  29 +public class PatientCheckTicketFacade {
  30 +
  31 + @Autowired
  32 + private PatientCheckTicketService checkTicketServicel;
  33 + @Autowired
  34 + private PatientsService patientsService;
  35 + @Autowired
  36 + private AutoMatchFacade autoMatchFacade;
  37 +
  38 + @Autowired
  39 + private AutoIncermentService autoIncermentService;
  40 +
  41 + /**
  42 + * 补发以前建档的产检劵
  43 + *
  44 + * @return
  45 + */
  46 + public BaseResponse supplyCheckTicket(String hId) {
  47 + PatientsQuery patientsQuery1 = new PatientsQuery();
  48 + patientsQuery1.setHospitalId(hId);
  49 + patientsQuery1.setYn(YnEnums.YES.getId());
  50 + patientsQuery1.setType(1);
  51 + List buildType = new ArrayList();
  52 + buildType.add(0);
  53 + buildType.add(2);
  54 + patientsQuery1.setBuildTypeList(buildType);
  55 +
  56 + List<Patients> patientses = patientsService.queryPatient(patientsQuery1);
  57 +
  58 + int batchSize = 400;
  59 + int end = 0;
  60 + for (int i = 0; i < patientses.size(); i += batchSize) {
  61 + end = (end + batchSize);
  62 + if (end > patientses.size()) {
  63 + end = patientses.size();
  64 + }
  65 + new SupplyCheckTicketThread(patientses.subList(i, end)).start();
  66 + }
  67 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  68 + }
  69 +
  70 + private class SupplyCheckTicketThread extends Thread {
  71 + private List<Patients> patientses;
  72 +
  73 + public SupplyCheckTicketThread(List<Patients> patientses) {
  74 + this.patientses = patientses;
  75 + }
  76 +
  77 + @Override
  78 + public void run() {
  79 + PatientCheckTicketQuery checkTicketQuery = new PatientCheckTicketQuery();
  80 + for (Patients p : patientses) {
  81 + try {
  82 + checkTicketQuery.setPatientId(p.getId());
  83 + if (0 == checkTicketServicel.queryTicketCount(checkTicketQuery)) {
  84 + //建档成功后,给孕妇造五个条形码
  85 + String ticketPid = autoIncermentService.nextPatientTicketId();
  86 + for (Integer i = 1; i <= 5; i++) {
  87 + PatientCheckTicket ticket = new PatientCheckTicket();
  88 + ticket.setStatus(1);
  89 + ticket.setHospitalId(p.getHospitalId());
  90 + ticket.setPatientId(p.getId());
  91 + ticket.setCreated(new Date());
  92 + ticket.setId("0335" + ticketPid + i);
  93 + checkTicketServicel.addTicket(ticket);
  94 + }
  95 + }
  96 + } catch (Exception e) {
  97 + ExceptionUtils.catchException(e, "SupplyCheckTicketThread Error.");
  98 + }
  99 + }
  100 + }
  101 + }
  102 +}