|
@@ -0,0 +1,220 @@
|
|
|
+package com.bofeng.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.toolkit.IdWorker;
|
|
|
+import com.bofeng.dao.MsReportMapper;
|
|
|
+import com.bofeng.dao.MsSuspectedMapper;
|
|
|
+import com.bofeng.dao.MsTripMapper;
|
|
|
+import com.bofeng.entity.MsReport;
|
|
|
+import com.bofeng.entity.MsSuspected;
|
|
|
+import com.bofeng.entity.MsTrip;
|
|
|
+import com.yvan.platform.Conv;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+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.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: xielianghe
|
|
|
+ * @Date: 2020/2/22 13:33
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Transactional(readOnly = true)
|
|
|
+public class MsTripService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MsSuspectedMapper msSuspectedMapper;
|
|
|
+ @Autowired
|
|
|
+ private MsReportMapper msReportMapper;
|
|
|
+ @Autowired
|
|
|
+ private MsTripMapper msTripMapper;
|
|
|
+ @Autowired
|
|
|
+ private MsSuspectedService msSuspectedService;
|
|
|
+
|
|
|
+
|
|
|
+ //添加家人
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
+ public Long addSuspectedTrip(Long suspectedId, String userName, Integer grender, Integer age, String familyStatus,
|
|
|
+ String statusDesp, Integer medical, BigDecimal temperature, Integer cough, Integer muscle,
|
|
|
+ Integer dyspnea, Integer fatigue, Integer diarrhea, Integer singleRoom, String others, Long userCreate, Integer scoreRezult, Integer temperatureScore, Integer scoreHistroy, Integer score
|
|
|
+ , Integer workLocal, String workLocalOther, Integer todayLocal, String todayLocalOther, Integer isTrip, String tripDet) {
|
|
|
+ Long reportId = 0L;
|
|
|
+ //如果是当前日期 已经添加
|
|
|
+ Date t = new Date();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String reportDate = df.format(t);
|
|
|
+ List<MsReport> listReport = msReportMapper.selectByReportDate(reportDate, userCreate);
|
|
|
+ Long houseId = msReportMapper.selectHouseIdByUserId(userCreate);
|
|
|
+ //首次进入。没有今日报告
|
|
|
+ if (listReport == null || listReport.size() == 0) {
|
|
|
+ MsReport msReport = new MsReport();
|
|
|
+ msReport.setReportId(IdWorker.getId());
|
|
|
+ msReport.setHouseId(houseId);
|
|
|
+ msReport.setSafetyNum(0);
|
|
|
+ msReport.setSureNum(0);
|
|
|
+ msReport.setSuspectedNum(0);
|
|
|
+ msReport.setNormalNum(0);
|
|
|
+ msReport.setSingleNum(0);
|
|
|
+ msReport.setRemarks("");
|
|
|
+ msReport.setReportDate(DateTime.now().toDate());
|
|
|
+ msReport.setMsStatus(0);
|
|
|
+ msReport.setUserCreate(userCreate);
|
|
|
+ msReport.setTimeCreate(DateTime.now());
|
|
|
+ msReport.setUserUpdate(userCreate);
|
|
|
+ msReport.setTimeUpdate(DateTime.now());
|
|
|
+ msReportMapper.insert(msReport);
|
|
|
+ reportId = msReport.getReportId();
|
|
|
+ } else {
|
|
|
+ reportId = listReport.get(0).getReportId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否疑似
|
|
|
+ Integer suspectedStatus = 0;
|
|
|
+ //确诊
|
|
|
+ if (medical == 1)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //隔离
|
|
|
+ if (singleRoom == 1)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //体温
|
|
|
+ if (Conv.NFloat(temperature) < Conv.NFloat(35) || Conv.NFloat(temperature) > Conv.NFloat(37.3))
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //咳嗽
|
|
|
+ if (cough > 0)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //肌肉酸痛
|
|
|
+ if (muscle > 0)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //呼吸困难
|
|
|
+ if (dyspnea > 0)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //乏力
|
|
|
+ if (fatigue > 0)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ //腹泻
|
|
|
+ if (diarrhea > 0)
|
|
|
+ suspectedStatus = 1;
|
|
|
+ if (suspectedId == 0L) {
|
|
|
+ //判断家人是否同名
|
|
|
+ List<MsSuspected> list = msSuspectedMapper.selectUserNameNum(reportId, userName, reportDate);
|
|
|
+ if (list != null && list.size() > 0)
|
|
|
+ return 2L;
|
|
|
+ //判断是否评估
|
|
|
+ if (scoreRezult == 0) {
|
|
|
+ MsSuspected msSuspected1 = msSuspectedService.getScore(0L, userName, medical, temperature, cough, muscle, dyspnea, fatigue, diarrhea, userCreate);
|
|
|
+ if (msSuspected1 != null) {
|
|
|
+ scoreRezult = msSuspected1.getScoreRezult();
|
|
|
+ score = msSuspected1.getScore();
|
|
|
+ temperatureScore = msSuspected1.getTemperatureScore();
|
|
|
+ scoreHistroy = msSuspected1.getScoreHistroy();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MsSuspected msSuspected = new MsSuspected();
|
|
|
+ msSuspected.setSuspectedId(IdWorker.getId());
|
|
|
+ msSuspected.setReportId(reportId);
|
|
|
+ msSuspected.setUserName(userName);
|
|
|
+ msSuspected.setGrender(grender);//默认为家人
|
|
|
+ msSuspected.setAge(age);
|
|
|
+ msSuspected.setFamilyStatus(familyStatus);
|
|
|
+ msSuspected.setStatusDesp(statusDesp);
|
|
|
+ msSuspected.setMedical(medical);
|
|
|
+ msSuspected.setTemperature(temperature);
|
|
|
+ msSuspected.setCough(cough);
|
|
|
+ msSuspected.setMuscle(muscle);
|
|
|
+ msSuspected.setDiarrhea(dyspnea);
|
|
|
+ msSuspected.setFatigue(fatigue);
|
|
|
+ msSuspected.setDiarrhea(diarrhea);
|
|
|
+ msSuspected.setSingleRoom(singleRoom);
|
|
|
+ msSuspected.setOthers(others);
|
|
|
+ msSuspected.setSuspectedStatus(suspectedStatus);
|
|
|
+ msSuspected.setScoreRezult(scoreRezult);
|
|
|
+ msSuspected.setScore(score);
|
|
|
+ msSuspected.setScoreHistroy(scoreHistroy);
|
|
|
+ msSuspected.setTemperatureScore(temperatureScore);
|
|
|
+ msSuspected.setUserCreate(userCreate);
|
|
|
+ msSuspected.setTimeCreate(DateTime.now());
|
|
|
+ msSuspected.setUserUpdate(userCreate);
|
|
|
+ msSuspected.setTimeUpdate(DateTime.now());
|
|
|
+ msSuspectedMapper.insert(msSuspected);
|
|
|
+
|
|
|
+ //添加出行
|
|
|
+ MsTrip msTrip = new MsTrip();
|
|
|
+ msTrip.setTripId(msSuspected.getReportId());
|
|
|
+ msTrip.setIsTrip(isTrip);
|
|
|
+ msTrip.setTodayLocal(todayLocal);
|
|
|
+ msTrip.setTodayLocalOther(todayLocalOther);
|
|
|
+ msTrip.setWorkLocal(workLocal);
|
|
|
+ msTrip.setWorkLocalOther(workLocalOther);
|
|
|
+ msTripMapper.insert(msTrip);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //判断家人是否同名
|
|
|
+ List<MsSuspected> list = msSuspectedMapper.selectUserNameNum(reportId, userName, reportDate);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ if (list.size() > 1)
|
|
|
+ return 2L;
|
|
|
+ else {
|
|
|
+ if (list.get(0).getSuspectedId().longValue() != suspectedId.longValue())
|
|
|
+ return 2L;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MsSuspected msSuspected2 = msSuspectedService.getScore(suspectedId, userName, medical, temperature, cough, muscle, dyspnea, fatigue, diarrhea, userCreate);
|
|
|
+ if (msSuspected2 != null) {
|
|
|
+ scoreRezult = msSuspected2.getScoreRezult();
|
|
|
+ score = msSuspected2.getScore();
|
|
|
+ temperatureScore = msSuspected2.getTemperatureScore();
|
|
|
+ scoreHistroy = msSuspected2.getScoreHistroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ MsSuspected msSuspected1 = msSuspectedMapper.selectById(suspectedId);
|
|
|
+ if (msSuspected1 != null) {
|
|
|
+ msSuspected1.setUserName(userName);
|
|
|
+ msSuspected1.setGrender(grender);//默认为家人
|
|
|
+ msSuspected1.setAge(age);
|
|
|
+ msSuspected1.setFamilyStatus(familyStatus);
|
|
|
+ msSuspected1.setStatusDesp(statusDesp);
|
|
|
+ msSuspected1.setMedical(medical);
|
|
|
+ msSuspected1.setTemperature(temperature);
|
|
|
+ msSuspected1.setCough(cough);
|
|
|
+ msSuspected1.setMuscle(muscle);
|
|
|
+ msSuspected1.setDiarrhea(dyspnea);
|
|
|
+ msSuspected1.setFatigue(fatigue);
|
|
|
+ msSuspected1.setDiarrhea(diarrhea);
|
|
|
+ msSuspected1.setSingleRoom(singleRoom);
|
|
|
+ msSuspected1.setOthers(others);
|
|
|
+ msSuspected1.setScoreRezult(scoreRezult);
|
|
|
+ msSuspected1.setScore(score);
|
|
|
+ msSuspected1.setScoreHistroy(scoreHistroy);
|
|
|
+ msSuspected1.setTemperatureScore(temperatureScore);
|
|
|
+ msSuspected1.setSuspectedStatus(suspectedStatus);
|
|
|
+ msSuspectedMapper.updateById(msSuspected1);
|
|
|
+ }
|
|
|
+ MsTrip msTrip = msTripMapper.selectById(suspectedId);
|
|
|
+ if (msTrip != null) {
|
|
|
+ msTrip.setWorkLocalOther(workLocalOther);
|
|
|
+ msTrip.setWorkLocal(workLocal);
|
|
|
+ msTrip.setTodayLocalOther(todayLocalOther);
|
|
|
+ msTrip.setTodayLocal(todayLocal);
|
|
|
+ msTrip.setIsTrip(isTrip);
|
|
|
+ msTripMapper.updateById(msTrip);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新今日日报
|
|
|
+ msSuspectedService.updateReport(reportId, medical, singleRoom, temperature);
|
|
|
+ return reportId;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
+ public Integer deleteTripdet(Long tripDetId) {
|
|
|
+ return msSuspectedMapper.deleteById(tripDetId);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|