|
@@ -0,0 +1,341 @@
|
|
|
+package com.bofeng.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.toolkit.IdWorker;
|
|
|
+import com.bofeng.dao.MsReportMapper;
|
|
|
+import com.bofeng.dao.MsSuspectedMapper;
|
|
|
+import com.bofeng.dao.UptownHouseMapper;
|
|
|
+import com.bofeng.dao.UptownUnitMapper;
|
|
|
+import com.bofeng.entity.MsReport;
|
|
|
+import com.bofeng.entity.MsSuspected;
|
|
|
+import com.bofeng.entity.UptownHouse;
|
|
|
+import com.bofeng.entity.UptownUnit;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: xielianghe
|
|
|
+ * @Date: 2020/2/4 15:44
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Transactional()
|
|
|
+public class RiBaoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MsSuspectedMapper msSuspectedMapper;
|
|
|
+ @Autowired
|
|
|
+ private MsReportMapper msReportMapper;
|
|
|
+ @Autowired
|
|
|
+ private RiBaoService msReportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UptownHouseMapper uptownHouseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UptownUnitMapper uptownUnitMapper;
|
|
|
+
|
|
|
+ public List<MsSuspected> getByReportId(Long reportId) {
|
|
|
+ return msSuspectedMapper.selectByReportId(reportId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public MsReport selectById(Long reportId) {
|
|
|
+ return msReportMapper.selectById(reportId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取前一天数据
|
|
|
+// public List<MsSuspected> getByReportReportDate(String reportDate, Long userCreate) {
|
|
|
+//
|
|
|
+// List<MsReport> listReport = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
+// List<MsSuspected> listSuspected = null;
|
|
|
+// if (listReport != null && listReport.size() > 0) {
|
|
|
+// listSuspected = msSuspectedMapper.selectByReportId(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+// }
|
|
|
+// return listSuspected;
|
|
|
+// }
|
|
|
+
|
|
|
+ //获取今天数据
|
|
|
+ public MsReport getReportByDateNow(Long userCreate) {
|
|
|
+ //根据昨天的获取今天的
|
|
|
+ msReportService.getNowByYesterday(userCreate);
|
|
|
+ Date t = new Date();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String reportDate = df.format(t);
|
|
|
+ List<MsReport> listReport = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
+ MsReport msReport = new MsReport();
|
|
|
+ if (listReport != null && listReport.size() > 0) {
|
|
|
+ msReport = msReportMapper.selectById(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+ }
|
|
|
+ return msReport;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取今天数据
|
|
|
+ public String getHouseStr(Long houseId) {
|
|
|
+ UptownHouse house = uptownHouseMapper.selectById(houseId);
|
|
|
+ UptownUnit unit = uptownUnitMapper.selectById(house.getUnitId());
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ sb.append(unit.getRidgepole()).append("栋").append(unit.getUnit()).append("单元").append(house.getDoorplate()).append("室");
|
|
|
+ String houseStr = sb.toString();
|
|
|
+ return houseStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //上报
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
+ public Integer addReport(Long userCreate) {
|
|
|
+ Date t = new Date();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String reportDate = df.format(t);
|
|
|
+ List<MsReport> listReport = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
+ if (listReport == null || listReport.size() == 0)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ //判断体温是否填写
|
|
|
+ List<MsSuspected> listSuspected = msSuspectedMapper.selectByReportId(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+ for (MsSuspected msSuspected : listSuspected) {
|
|
|
+ if (msSuspected.getTemperature().compareTo(new BigDecimal(0)) == 0)
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ MsReport msReport = msReportMapper.selectById(Long.parseLong(listReport.get(0).getReportId().toString()));
|
|
|
+ if (msReport != null) {
|
|
|
+ msReport.setReportStatus(1);
|
|
|
+ msReport.setUserUpdate(userCreate);
|
|
|
+ msReport.setTimeUpdate(DateTime.now());
|
|
|
+ msReportMapper.updateById(msReport);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // @Pd(name = "userName") String userName,// 家人姓名
|
|
|
+// @Pd(name = "grender") Integer grender,// 性别:0未设置,1男,2女
|
|
|
+// @Pd(name = "age") Integer age,// 年龄
|
|
|
+// @Pd(name = "familyStatus") Integer familyStatus,// 基本状态:0正常,1心血管疾病(服用ARB),2心血管疾病(未服用ARB),3呼吸系统病史,4肿瘤病史,5糖尿病史,6服用过激素药物,7妊娠期,8其他
|
|
|
+// @Pd(name = "statusDesp") String statusDesp,// 状态描述
|
|
|
+// @Pd(name = "medical") Integer medical,// 是否确诊:0否,1是
|
|
|
+// @Pd(name = "temperature") BigDecimal temperature,// 体温
|
|
|
+// @Pd(name = "cough") Integer cough,// 咳嗽:0无咳嗽,1偶有短暂咳嗽,2咳嗽轻度影响生活,3咳嗽严重影响生活
|
|
|
+// @Pd(name = "muscle") Integer muscle,// 肌肉酸痛:0无,1按压有,2偶尔,3持续有
|
|
|
+// @Pd(name = "dyspnea") Integer dyspnea,// 呼吸困难:0无,1急走或上坡气短,2气短而走路变慢,3走路数分钟后气短,4气短无法离开房间
|
|
|
+// @Pd(name = "fatigue") Integer fatigue,// 乏力:0无,1可体力劳动但觉得累,2轻体力劳动后长时间不能恢复,3不能正常生活
|
|
|
+// @Pd(name = "diarrhea") Integer diarrhea,// 腹泻:0无,1轻度腹泻少于于3次,2中度腹泻4-6次,3重度腹泻超过6次
|
|
|
+// @Pd(name = "singleRoom") Integer singleRoom,// 单间隔离:0否,1是
|
|
|
+// // @Pd(name = "suspectedStatus") String suspectedStatus,// 是否疑似:0否,1是
|
|
|
+// @Pd(name = "others") String others,// 其他
|
|
|
+ //获取前一天数据
|
|
|
+ public List<MsSuspected> queryRibaoDetailList(Long reportId) {
|
|
|
+ List<MsSuspected> listSuspected = msSuspectedMapper.selectByReportId(reportId);
|
|
|
+ if (CollectionUtils.isEmpty(listSuspected)) {
|
|
|
+ listSuspected = new ArrayList<MsSuspected>();
|
|
|
+ } else {
|
|
|
+ for (MsSuspected obj : listSuspected) {
|
|
|
+ if (obj.getGrender().intValue() == 1) {
|
|
|
+ obj.setGrenderStr("男");
|
|
|
+ } else if (obj.getGrender().intValue() == 2) {
|
|
|
+ obj.setGrenderStr("女");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getFamilyStatus().intValue() == 0) {
|
|
|
+ obj.setFamilyStatusStr("正常");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 1) {
|
|
|
+ obj.setFamilyStatusStr("心血管疾病(服用ARB)");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 2) {
|
|
|
+ obj.setFamilyStatusStr("心血管疾病(未服用ARB)");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 3) {
|
|
|
+ obj.setFamilyStatusStr("呼吸系统病史");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 4) {
|
|
|
+ obj.setFamilyStatusStr("肿瘤病史");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 5) {
|
|
|
+ obj.setFamilyStatusStr("糖尿病史");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 6) {
|
|
|
+ obj.setFamilyStatusStr("服用过激素药物");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 7) {
|
|
|
+ obj.setFamilyStatusStr("妊娠期");
|
|
|
+ } else if (obj.getFamilyStatus().intValue() == 8) {
|
|
|
+ obj.setFamilyStatusStr("其他");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getMedical().intValue() == 0) {
|
|
|
+ obj.setMedicalStr("否");
|
|
|
+ } else if (obj.getMedical().intValue() == 1) {
|
|
|
+ obj.setMedicalStr("是");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getCough().intValue() == 0) {
|
|
|
+ obj.setCoughStr("无咳嗽");
|
|
|
+ } else if (obj.getCough().intValue() == 1) {
|
|
|
+ obj.setCoughStr("偶有短暂咳嗽");
|
|
|
+ } else if (obj.getCough().intValue() == 2) {
|
|
|
+ obj.setCoughStr("咳嗽轻度影响生活");
|
|
|
+ } else if (obj.getCough().intValue() == 3) {
|
|
|
+ obj.setCoughStr("咳嗽严重影响生活");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getMuscle().intValue() == 0) {
|
|
|
+ obj.setMuscleStr("无");
|
|
|
+ } else if (obj.getMuscle().intValue() == 1) {
|
|
|
+ obj.setMuscleStr("按压有");
|
|
|
+ } else if (obj.getMuscle().intValue() == 2) {
|
|
|
+ obj.setMuscleStr("偶尔");
|
|
|
+ } else if (obj.getMuscle().intValue() == 3) {
|
|
|
+ obj.setMuscleStr("持续有");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getDyspnea().intValue() == 0) {
|
|
|
+ obj.setDyspneaStr("无");
|
|
|
+ } else if (obj.getDyspnea().intValue() == 1) {
|
|
|
+ obj.setDyspneaStr("急走或上坡气短");
|
|
|
+ } else if (obj.getDyspnea().intValue() == 2) {
|
|
|
+ obj.setDyspneaStr("气短而走路变慢");
|
|
|
+ } else if (obj.getDyspnea().intValue() == 3) {
|
|
|
+ obj.setDyspneaStr("走路数分钟后气短");
|
|
|
+ } else if (obj.getDyspnea().intValue() == 4) {
|
|
|
+ obj.setDyspneaStr("气短无法离开房间");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getFatigue().intValue() == 0) {
|
|
|
+ obj.setFatigueStr("无");
|
|
|
+ } else if (obj.getFatigue().intValue() == 1) {
|
|
|
+ obj.setFatigueStr("可体力劳动但觉得累");
|
|
|
+ } else if (obj.getFatigue().intValue() == 2) {
|
|
|
+ obj.setFatigueStr("轻体力劳动后长时间不能恢复");
|
|
|
+ } else if (obj.getFatigue().intValue() == 3) {
|
|
|
+ obj.setFatigueStr("不能正常生活");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getDiarrhea().intValue() == 0) {
|
|
|
+ obj.setDiarrheaStr("无");
|
|
|
+ } else if (obj.getDiarrhea().intValue() == 1) {
|
|
|
+ obj.setDiarrheaStr("轻度腹泻少于于3次");
|
|
|
+ } else if (obj.getDiarrhea().intValue() == 2) {
|
|
|
+ obj.setDiarrheaStr("中度腹泻4-6次");
|
|
|
+ } else if (obj.getDiarrhea().intValue() == 3) {
|
|
|
+ obj.setDiarrheaStr("重度腹泻超过6次");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getSingleRoom().intValue() == 0) {
|
|
|
+ obj.setSingleRoomStr("否");
|
|
|
+ } else if (obj.getSingleRoom().intValue() == 1) {
|
|
|
+ obj.setSingleRoomStr("是");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getSuspectedStatus().intValue() == 0) {
|
|
|
+ obj.setSuspectedStatusStr("否");
|
|
|
+ } else if (obj.getSuspectedStatus().intValue() == 1) {
|
|
|
+ obj.setSuspectedStatusStr("是");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listSuspected;
|
|
|
+ }
|
|
|
+
|
|
|
+ //通过昨天数据更新今天数据
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
+ public Long getNowByYesterday(Long userCreate) {
|
|
|
+ // 判断今天是否有数据
|
|
|
+ Date today = new Date();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String todayStr = sdf.format(today);
|
|
|
+ List<MsReport> listReportDb = msReportMapper.selectByReportDate(todayStr, userCreate);
|
|
|
+ if (CollectionUtils.isNotEmpty(listReportDb)) {
|
|
|
+ Long reportId = listReportDb.get(0).getReportId();
|
|
|
+ return reportId;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断昨天是否有数据
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(today);
|
|
|
+ calendar.add(Calendar.DATE, -1);
|
|
|
+ String yestodayStr = sdf.format(calendar.getTime());
|
|
|
+ listReportDb = msReportMapper.selectByReportDate(yestodayStr, userCreate);
|
|
|
+ //有数据
|
|
|
+ Long reportId = 0L;
|
|
|
+ DateTime dateTime = new DateTime();
|
|
|
+ if (CollectionUtils.isNotEmpty(listReportDb)) {
|
|
|
+ Long reportIdDb = listReportDb.get(0).getReportId();
|
|
|
+ //添加到今天日报
|
|
|
+ MsReport msReportDb = msReportMapper.selectById(reportIdDb);
|
|
|
+ if (msReportDb != null) {
|
|
|
+ MsReport msReport = new MsReport();
|
|
|
+ BeanUtils.copyProperties(msReportDb, msReport);
|
|
|
+ reportId = IdWorker.getId();
|
|
|
+ msReport.setReportId(reportId);
|
|
|
+ msReport.setReportDate(dateTime.toDate());
|
|
|
+ msReport.setReportStatus(0);//未上报
|
|
|
+ msReport.setUserCreate(userCreate);
|
|
|
+ msReport.setTimeCreate(dateTime);
|
|
|
+ msReport.setUserUpdate(userCreate);
|
|
|
+ msReport.setTimeUpdate(dateTime);
|
|
|
+ msReportMapper.insert(msReport);
|
|
|
+
|
|
|
+ //添加今日家庭
|
|
|
+ List<MsSuspected> suspectedListDb = msSuspectedMapper.selectByReportId(reportIdDb);
|
|
|
+ if (CollectionUtils.isNotEmpty(suspectedListDb)) {
|
|
|
+ for (MsSuspected msSuspectedDb : suspectedListDb) {
|
|
|
+ MsSuspected msSuspected = new MsSuspected();
|
|
|
+ BeanUtils.copyProperties(msSuspectedDb, msSuspected);
|
|
|
+ msSuspected.setSuspectedId(IdWorker.getId());
|
|
|
+ msSuspected.setReportId(reportId);
|
|
|
+ msSuspected.setSuspectedStatus(0);
|
|
|
+ msSuspected.setUserCreate(userCreate);
|
|
|
+ msSuspected.setTimeCreate(dateTime);
|
|
|
+ msSuspected.setUserUpdate(userCreate);
|
|
|
+ msSuspected.setTimeUpdate(dateTime);
|
|
|
+ msSuspectedMapper.insert(msSuspected);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Long houseId = msReportMapper.selectHouseIdByUserId(userCreate);
|
|
|
+ reportId = IdWorker.getId();
|
|
|
+ MsReport msReport = new MsReport();
|
|
|
+ msReport.setReportId(reportId);
|
|
|
+ msReport.setHouseId(houseId);
|
|
|
+ msReport.setSafetyNum(0);
|
|
|
+ msReport.setSureNum(0);
|
|
|
+ msReport.setSuspectedNum(0);
|
|
|
+ msReport.setNormalNum(0);
|
|
|
+ msReport.setSingleNum(0);
|
|
|
+ msReport.setRemarks("");
|
|
|
+ msReport.setReportDate(dateTime.toDate());
|
|
|
+ msReport.setMsStatus(0);
|
|
|
+ msReport.setUserCreate(userCreate);
|
|
|
+ msReport.setTimeCreate(dateTime);
|
|
|
+ msReport.setUserUpdate(userCreate);
|
|
|
+ msReport.setTimeUpdate(dateTime);
|
|
|
+ msReportMapper.insert(msReport);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Long houseId = msReportMapper.selectHouseIdByUserId(userCreate);
|
|
|
+ reportId = IdWorker.getId();
|
|
|
+ MsReport msReport = new MsReport();
|
|
|
+ msReport.setReportId(reportId);
|
|
|
+ msReport.setHouseId(houseId);
|
|
|
+ msReport.setSafetyNum(0);
|
|
|
+ msReport.setSureNum(0);
|
|
|
+ msReport.setSuspectedNum(0);
|
|
|
+ msReport.setNormalNum(0);
|
|
|
+ msReport.setSingleNum(0);
|
|
|
+ msReport.setRemarks("");
|
|
|
+ msReport.setReportDate(dateTime.toDate());
|
|
|
+ msReport.setMsStatus(0);
|
|
|
+ msReport.setUserCreate(userCreate);
|
|
|
+ msReport.setTimeCreate(dateTime);
|
|
|
+ msReport.setUserUpdate(userCreate);
|
|
|
+ msReport.setTimeUpdate(dateTime);
|
|
|
+ msReportMapper.insert(msReport);
|
|
|
+ }
|
|
|
+
|
|
|
+ return reportId;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|