RiBaoService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. package com.bofeng.service;
  2. import com.baomidou.mybatisplus.toolkit.IdWorker;
  3. import com.bofeng.dao.*;
  4. import com.bofeng.entity.*;
  5. import org.apache.commons.collections.CollectionUtils;
  6. import org.joda.time.DateTime;
  7. import org.springframework.beans.BeanUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Service;
  10. import org.springframework.transaction.annotation.Propagation;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import java.math.BigDecimal;
  13. import java.text.SimpleDateFormat;
  14. import java.util.ArrayList;
  15. import java.util.Calendar;
  16. import java.util.Date;
  17. import java.util.List;
  18. /**
  19. * @Author: songjiaqing
  20. * @Date: 2020/2/4 15:44
  21. */
  22. @Service
  23. @Transactional()
  24. public class RiBaoService {
  25. @Autowired
  26. private MsSuspectedMapper msSuspectedMapper;
  27. @Autowired
  28. private MsReportMapper msReportMapper;
  29. @Autowired
  30. private UptownHouseMapper uptownHouseMapper;
  31. @Autowired
  32. private UptownUnitMapper uptownUnitMapper;
  33. @Autowired
  34. private UserRoleMapper userRoleMapper;
  35. @Autowired
  36. private OwnerMapper ownerMapper;
  37. @Autowired
  38. private UptownMapper uptownMapper;
  39. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  40. public MsReport editRibao(Long reportId) {
  41. DateTime dateTime = new DateTime();
  42. MsReport msReport = msReportMapper.selectById(reportId);
  43. if (msReport != null) {
  44. msReport.setReportStatus(1);
  45. msReport.setTimeUpdate(dateTime);
  46. msReportMapper.updateById(msReport);
  47. }
  48. return msReport;
  49. }
  50. // 删除家人
  51. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  52. public int delRibaoDetail(Long suspectedId) {
  53. MsSuspected msSuspectedDb = msSuspectedMapper.selectById(suspectedId);
  54. int num = msSuspectedMapper.deleteById(suspectedId);
  55. //更新今日日报
  56. updateRibao(msSuspectedDb.getReportId());
  57. return num;
  58. }
  59. // 添加修改家人
  60. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  61. public MsSuspected addOrEditRibaoDetail(MsSuspected ribaoDetail) {
  62. DateTime dateTime = new DateTime();
  63. //判断是否疑似
  64. Integer suspectedStatus = 0;
  65. if (ribaoDetail.getMuscle().intValue() == 1 ||
  66. ribaoDetail.getSingleRoom().intValue() == 1 ||
  67. ribaoDetail.getTemperature().compareTo(new BigDecimal(36)) == -1 ||
  68. ribaoDetail.getTemperature().compareTo(new BigDecimal(37.3)) == 1 ||
  69. ribaoDetail.getCough() > 0 ||
  70. ribaoDetail.getMuscle() > 0 ||
  71. ribaoDetail.getDyspnea() > 0 ||
  72. ribaoDetail.getFatigue() > 0 ||
  73. ribaoDetail.getDiarrhea() > 0) {
  74. suspectedStatus = 1;
  75. }
  76. ribaoDetail.setSuspectedStatus(suspectedStatus);
  77. if (ribaoDetail.getSuspectedId() != null && ribaoDetail.getSuspectedId().longValue() > 0L) {
  78. ribaoDetail.setTimeUpdate(dateTime);
  79. msSuspectedMapper.updateById(ribaoDetail);
  80. } else {
  81. ribaoDetail.setSuspectedId(IdWorker.getId());
  82. ribaoDetail.setTimeCreate(dateTime);
  83. ribaoDetail.setTimeUpdate(dateTime);
  84. msSuspectedMapper.insert(ribaoDetail);
  85. }
  86. //更新今日日报
  87. updateRibao(ribaoDetail.getReportId());
  88. return ribaoDetail;
  89. }
  90. // 更新今日日报
  91. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  92. public void updateRibao(Long reportId) {
  93. //更新今日日报
  94. Integer trueNum = 0, singleNum = 0, isSuspected = 0, isNoSuspected = 0, isFamliy = 0;
  95. //确诊
  96. trueNum = msReportMapper.selectSuspectedNum(reportId);
  97. //疑似
  98. isNoSuspected = msReportMapper.selectisNoSuspectedNum(reportId);
  99. //居家隔离
  100. singleNum = msReportMapper.selectSingleRoomNum(reportId);
  101. //正常
  102. isSuspected = msReportMapper.selectisSuspectedNum(reportId);
  103. //今日居家
  104. List<MsSuspected> list = msSuspectedMapper.selectByReportId(reportId);
  105. if (list != null && list.size() > 0)
  106. isFamliy = list.size();
  107. MsReport msReport = msReportMapper.selectById(reportId);
  108. if (msReport != null) {
  109. msReport.setSureNum(trueNum);
  110. msReport.setSuspectedNum(isNoSuspected);
  111. msReport.setNormalNum(isSuspected);
  112. msReport.setSingleNum(singleNum);
  113. msReport.setSafetyNum(isFamliy);
  114. if (trueNum > 0 || isNoSuspected > 0 || singleNum > 0) {
  115. msReport.setMsStatus(2);// 健康状态:1正常,2异常
  116. } else {
  117. msReport.setMsStatus(1);
  118. }
  119. msReportMapper.updateById(msReport);
  120. }
  121. }
  122. public MsReport getRibao(Long reportId) {
  123. MsReport msReport = msReportMapper.selectById(reportId);
  124. String houseStr = this.getHouseStr(msReport.getHouseId());
  125. msReport.setHouseIdStr(houseStr);
  126. return msReport;
  127. }
  128. //获取今天数据
  129. public String getHouseStr(Long houseId) {
  130. UptownHouse house = uptownHouseMapper.selectById(houseId);
  131. if (null == house) {
  132. return "";
  133. }
  134. UptownUnit unit = uptownUnitMapper.selectById(house.getUnitId());
  135. StringBuffer sb = new StringBuffer();
  136. if (null == unit) {
  137. sb.append(house.getDoorplate()).append("室");
  138. String houseStr = sb.toString();
  139. return houseStr;
  140. }
  141. sb.append(unit.getRidgepole()).append("栋").append(unit.getUnit()).append("单元").append(house.getDoorplate()).append("室");
  142. String houseStr = sb.toString();
  143. return houseStr;
  144. }
  145. public MsSuspected getRibaoDetail(Long suspectedId) {
  146. MsSuspected obj = msSuspectedMapper.selectById(suspectedId);
  147. if (obj.getGrender().intValue() == 1) {
  148. obj.setGrenderStr("男");
  149. } else if (obj.getGrender().intValue() == 2) {
  150. obj.setGrenderStr("女");
  151. }
  152. if (obj.getFamilyStatus().intValue() == 0) {
  153. obj.setFamilyStatusStr("正常");
  154. } else if (obj.getFamilyStatus().intValue() == 1) {
  155. obj.setFamilyStatusStr("心血管疾病(服用ARB)");
  156. } else if (obj.getFamilyStatus().intValue() == 2) {
  157. obj.setFamilyStatusStr("心血管疾病(未服用ARB)");
  158. } else if (obj.getFamilyStatus().intValue() == 3) {
  159. obj.setFamilyStatusStr("呼吸系统病史");
  160. } else if (obj.getFamilyStatus().intValue() == 4) {
  161. obj.setFamilyStatusStr("肿瘤病史");
  162. } else if (obj.getFamilyStatus().intValue() == 5) {
  163. obj.setFamilyStatusStr("糖尿病史");
  164. } else if (obj.getFamilyStatus().intValue() == 6) {
  165. obj.setFamilyStatusStr("服用过激素药物");
  166. } else if (obj.getFamilyStatus().intValue() == 7) {
  167. obj.setFamilyStatusStr("妊娠期");
  168. } else if (obj.getFamilyStatus().intValue() == 8) {
  169. obj.setFamilyStatusStr("其他");
  170. }
  171. if (obj.getMedical().intValue() == 0) {
  172. obj.setMedicalStr("否");
  173. } else if (obj.getMedical().intValue() == 1) {
  174. obj.setMedicalStr("是");
  175. }
  176. if (obj.getCough().intValue() == 0) {
  177. obj.setCoughStr("无咳嗽");
  178. } else if (obj.getCough().intValue() == 1) {
  179. obj.setCoughStr("偶有短暂咳嗽");
  180. } else if (obj.getCough().intValue() == 2) {
  181. obj.setCoughStr("咳嗽轻度影响生活");
  182. } else if (obj.getCough().intValue() == 3) {
  183. obj.setCoughStr("咳嗽严重影响生活");
  184. }
  185. if (obj.getMuscle().intValue() == 0) {
  186. obj.setMuscleStr("无");
  187. } else if (obj.getMuscle().intValue() == 1) {
  188. obj.setMuscleStr("按压有");
  189. } else if (obj.getMuscle().intValue() == 2) {
  190. obj.setMuscleStr("偶尔");
  191. } else if (obj.getMuscle().intValue() == 3) {
  192. obj.setMuscleStr("持续有");
  193. }
  194. if (obj.getDyspnea().intValue() == 0) {
  195. obj.setDyspneaStr("无");
  196. } else if (obj.getDyspnea().intValue() == 1) {
  197. obj.setDyspneaStr("急走或上坡气短");
  198. } else if (obj.getDyspnea().intValue() == 2) {
  199. obj.setDyspneaStr("气短而走路变慢");
  200. } else if (obj.getDyspnea().intValue() == 3) {
  201. obj.setDyspneaStr("走路数分钟后气短");
  202. } else if (obj.getDyspnea().intValue() == 4) {
  203. obj.setDyspneaStr("气短无法离开房间");
  204. }
  205. if (obj.getFatigue().intValue() == 0) {
  206. obj.setFatigueStr("无");
  207. } else if (obj.getFatigue().intValue() == 1) {
  208. obj.setFatigueStr("可体力劳动但觉得累");
  209. } else if (obj.getFatigue().intValue() == 2) {
  210. obj.setFatigueStr("轻体力劳动后长时间不能恢复");
  211. } else if (obj.getFatigue().intValue() == 3) {
  212. obj.setFatigueStr("不能正常生活");
  213. }
  214. if (obj.getDiarrhea().intValue() == 0) {
  215. obj.setDiarrheaStr("无");
  216. } else if (obj.getDiarrhea().intValue() == 1) {
  217. obj.setDiarrheaStr("轻度腹泻少于于3次");
  218. } else if (obj.getDiarrhea().intValue() == 2) {
  219. obj.setDiarrheaStr("中度腹泻4-6次");
  220. } else if (obj.getDiarrhea().intValue() == 3) {
  221. obj.setDiarrheaStr("重度腹泻超过6次");
  222. }
  223. if (obj.getSingleRoom().intValue() == 0) {
  224. obj.setSingleRoomStr("否");
  225. } else if (obj.getSingleRoom().intValue() == 1) {
  226. obj.setSingleRoomStr("是");
  227. }
  228. if (obj.getSuspectedStatus().intValue() == 0) {
  229. obj.setSuspectedStatusStr("否");
  230. } else if (obj.getSuspectedStatus().intValue() == 1) {
  231. obj.setSuspectedStatusStr("是");
  232. }
  233. return obj;
  234. }
  235. // @Pd(name = "userName") String userName,// 家人姓名
  236. // @Pd(name = "grender") Integer grender,// 性别:0未设置,1男,2女
  237. // @Pd(name = "age") Integer age,// 年龄
  238. // @Pd(name = "familyStatus") Integer familyStatus,// 基本状态:0正常,1心血管疾病(服用ARB),2心血管疾病(未服用ARB),3呼吸系统病史,4肿瘤病史,5糖尿病史,6服用过激素药物,7妊娠期,8其他
  239. // @Pd(name = "statusDesp") String statusDesp,// 状态描述
  240. // @Pd(name = "medical") Integer medical,// 是否确诊:0否,1是
  241. // @Pd(name = "temperature") BigDecimal temperature,// 体温
  242. // @Pd(name = "cough") Integer cough,// 咳嗽:0无咳嗽,1偶有短暂咳嗽,2咳嗽轻度影响生活,3咳嗽严重影响生活
  243. // @Pd(name = "muscle") Integer muscle,// 肌肉酸痛:0无,1按压有,2偶尔,3持续有
  244. // @Pd(name = "dyspnea") Integer dyspnea,// 呼吸困难:0无,1急走或上坡气短,2气短而走路变慢,3走路数分钟后气短,4气短无法离开房间
  245. // @Pd(name = "fatigue") Integer fatigue,// 乏力:0无,1可体力劳动但觉得累,2轻体力劳动后长时间不能恢复,3不能正常生活
  246. // @Pd(name = "diarrhea") Integer diarrhea,// 腹泻:0无,1轻度腹泻少于于3次,2中度腹泻4-6次,3重度腹泻超过6次
  247. // @Pd(name = "singleRoom") Integer singleRoom,// 单间隔离:0否,1是
  248. // // @Pd(name = "suspectedStatus") String suspectedStatus,// 是否疑似:0否,1是
  249. // @Pd(name = "others") String others,// 其他
  250. //获取前一天数据
  251. public List<MsSuspected> queryRibaoDetailList(Long reportId) {
  252. List<MsSuspected> listSuspected = msSuspectedMapper.selectByReportId(reportId);
  253. if (CollectionUtils.isEmpty(listSuspected)) {
  254. listSuspected = new ArrayList<MsSuspected>();
  255. } else {
  256. for (MsSuspected obj : listSuspected) {
  257. if (obj.getGrender().intValue() == 1) {
  258. obj.setGrenderStr("男");
  259. } else if (obj.getGrender().intValue() == 2) {
  260. obj.setGrenderStr("女");
  261. }
  262. if (obj.getFamilyStatus().intValue() == 0) {
  263. obj.setFamilyStatusStr("正常");
  264. } else if (obj.getFamilyStatus().intValue() == 1) {
  265. obj.setFamilyStatusStr("心血管疾病(服用ARB)");
  266. } else if (obj.getFamilyStatus().intValue() == 2) {
  267. obj.setFamilyStatusStr("心血管疾病(未服用ARB)");
  268. } else if (obj.getFamilyStatus().intValue() == 3) {
  269. obj.setFamilyStatusStr("呼吸系统病史");
  270. } else if (obj.getFamilyStatus().intValue() == 4) {
  271. obj.setFamilyStatusStr("肿瘤病史");
  272. } else if (obj.getFamilyStatus().intValue() == 5) {
  273. obj.setFamilyStatusStr("糖尿病史");
  274. } else if (obj.getFamilyStatus().intValue() == 6) {
  275. obj.setFamilyStatusStr("服用过激素药物");
  276. } else if (obj.getFamilyStatus().intValue() == 7) {
  277. obj.setFamilyStatusStr("妊娠期");
  278. } else if (obj.getFamilyStatus().intValue() == 8) {
  279. obj.setFamilyStatusStr("其他");
  280. }
  281. if (obj.getMedical().intValue() == 0) {
  282. obj.setMedicalStr("否");
  283. } else if (obj.getMedical().intValue() == 1) {
  284. obj.setMedicalStr("是");
  285. }
  286. if (obj.getCough().intValue() == 0) {
  287. obj.setCoughStr("无咳嗽");
  288. } else if (obj.getCough().intValue() == 1) {
  289. obj.setCoughStr("偶有短暂咳嗽");
  290. } else if (obj.getCough().intValue() == 2) {
  291. obj.setCoughStr("咳嗽轻度影响生活");
  292. } else if (obj.getCough().intValue() == 3) {
  293. obj.setCoughStr("咳嗽严重影响生活");
  294. }
  295. if (obj.getMuscle().intValue() == 0) {
  296. obj.setMuscleStr("无");
  297. } else if (obj.getMuscle().intValue() == 1) {
  298. obj.setMuscleStr("按压有");
  299. } else if (obj.getMuscle().intValue() == 2) {
  300. obj.setMuscleStr("偶尔");
  301. } else if (obj.getMuscle().intValue() == 3) {
  302. obj.setMuscleStr("持续有");
  303. }
  304. if (obj.getDyspnea().intValue() == 0) {
  305. obj.setDyspneaStr("无");
  306. } else if (obj.getDyspnea().intValue() == 1) {
  307. obj.setDyspneaStr("急走或上坡气短");
  308. } else if (obj.getDyspnea().intValue() == 2) {
  309. obj.setDyspneaStr("气短而走路变慢");
  310. } else if (obj.getDyspnea().intValue() == 3) {
  311. obj.setDyspneaStr("走路数分钟后气短");
  312. } else if (obj.getDyspnea().intValue() == 4) {
  313. obj.setDyspneaStr("气短无法离开房间");
  314. }
  315. if (obj.getFatigue().intValue() == 0) {
  316. obj.setFatigueStr("无");
  317. } else if (obj.getFatigue().intValue() == 1) {
  318. obj.setFatigueStr("可体力劳动但觉得累");
  319. } else if (obj.getFatigue().intValue() == 2) {
  320. obj.setFatigueStr("轻体力劳动后长时间不能恢复");
  321. } else if (obj.getFatigue().intValue() == 3) {
  322. obj.setFatigueStr("不能正常生活");
  323. }
  324. if (obj.getDiarrhea().intValue() == 0) {
  325. obj.setDiarrheaStr("无");
  326. } else if (obj.getDiarrhea().intValue() == 1) {
  327. obj.setDiarrheaStr("轻度腹泻少于于3次");
  328. } else if (obj.getDiarrhea().intValue() == 2) {
  329. obj.setDiarrheaStr("中度腹泻4-6次");
  330. } else if (obj.getDiarrhea().intValue() == 3) {
  331. obj.setDiarrheaStr("重度腹泻超过6次");
  332. }
  333. if (obj.getSingleRoom().intValue() == 0) {
  334. obj.setSingleRoomStr("否");
  335. } else if (obj.getSingleRoom().intValue() == 1) {
  336. obj.setSingleRoomStr("是");
  337. }
  338. if (obj.getSuspectedStatus().intValue() == 0) {
  339. obj.setSuspectedStatusStr("否");
  340. } else if (obj.getSuspectedStatus().intValue() == 1) {
  341. obj.setSuspectedStatusStr("是");
  342. }
  343. }
  344. }
  345. return listSuspected;
  346. }
  347. //通过昨天数据更新今天数据
  348. @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  349. public Long getNowByYesterday(Long userCreate) {
  350. // 判断今天是否有数据
  351. Date today = new Date();
  352. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  353. String todayStr = sdf.format(today);
  354. List<MsReport> listReportDb = msReportMapper.selectByReportDate(todayStr, userCreate);
  355. if (CollectionUtils.isNotEmpty(listReportDb)) {
  356. Long reportId = listReportDb.get(0).getReportId();
  357. return reportId;
  358. }
  359. // 判断昨天是否有数据
  360. Calendar calendar = Calendar.getInstance();
  361. calendar.setTime(today);
  362. calendar.add(Calendar.DATE, -1);
  363. String yestodayStr = sdf.format(calendar.getTime());
  364. listReportDb = msReportMapper.selectByReportDate(yestodayStr, userCreate);
  365. //有数据
  366. Long reportId = 0L;
  367. DateTime dateTime = new DateTime();
  368. if (CollectionUtils.isNotEmpty(listReportDb)) {
  369. Long reportIdDb = listReportDb.get(0).getReportId();
  370. //添加到今天日报
  371. MsReport msReportDb = msReportMapper.selectById(reportIdDb);
  372. if (msReportDb != null) {
  373. MsReport msReport = new MsReport();
  374. BeanUtils.copyProperties(msReportDb, msReport);
  375. reportId = IdWorker.getId();
  376. msReport.setReportId(reportId);
  377. msReport.setReportDate(dateTime.toDate());
  378. msReport.setReportStatus(0);//未上报
  379. msReport.setUserCreate(userCreate);
  380. msReport.setTimeCreate(dateTime);
  381. msReport.setUserUpdate(userCreate);
  382. msReport.setTimeUpdate(dateTime);
  383. msReportMapper.insert(msReport);
  384. //添加今日家庭
  385. List<MsSuspected> suspectedListDb = msSuspectedMapper.selectByReportId(reportIdDb);
  386. if (CollectionUtils.isNotEmpty(suspectedListDb)) {
  387. for (MsSuspected msSuspectedDb : suspectedListDb) {
  388. MsSuspected msSuspected = new MsSuspected();
  389. BeanUtils.copyProperties(msSuspectedDb, msSuspected);
  390. msSuspected.setSuspectedId(IdWorker.getId());
  391. msSuspected.setReportId(reportId);
  392. msSuspected.setSuspectedStatus(0);
  393. msSuspected.setUserCreate(userCreate);
  394. msSuspected.setTimeCreate(dateTime);
  395. msSuspected.setUserUpdate(userCreate);
  396. msSuspected.setTimeUpdate(dateTime);
  397. msSuspectedMapper.insert(msSuspected);
  398. }
  399. }
  400. } else {
  401. Long houseId = msReportMapper.selectHouseIdByUserId(userCreate);
  402. reportId = IdWorker.getId();
  403. MsReport msReport = new MsReport();
  404. msReport.setReportId(reportId);
  405. msReport.setHouseId(houseId);
  406. msReport.setSafetyNum(0);
  407. msReport.setSureNum(0);
  408. msReport.setSuspectedNum(0);
  409. msReport.setNormalNum(0);
  410. msReport.setSingleNum(0);
  411. msReport.setRemarks("");
  412. msReport.setReportDate(dateTime.toDate());
  413. msReport.setMsStatus(0);
  414. msReport.setUserCreate(userCreate);
  415. msReport.setTimeCreate(dateTime);
  416. msReport.setUserUpdate(userCreate);
  417. msReport.setTimeUpdate(dateTime);
  418. msReportMapper.insert(msReport);
  419. }
  420. } else {
  421. List<Long> houseIds = msReportMapper.selectHouseIdsByUserId(userCreate);
  422. reportId = IdWorker.getId();
  423. MsReport msReport = new MsReport();
  424. msReport.setReportId(reportId);
  425. msReport.setHouseId(houseIds.get(0).longValue());
  426. msReport.setSafetyNum(0);
  427. msReport.setSureNum(0);
  428. msReport.setSuspectedNum(0);
  429. msReport.setNormalNum(0);
  430. msReport.setSingleNum(0);
  431. msReport.setRemarks("");
  432. msReport.setReportDate(dateTime.toDate());
  433. msReport.setMsStatus(0);
  434. msReport.setUserCreate(userCreate);
  435. msReport.setTimeCreate(dateTime);
  436. msReport.setUserUpdate(userCreate);
  437. msReport.setTimeUpdate(dateTime);
  438. msReportMapper.insert(msReport);
  439. }
  440. return reportId;
  441. }
  442. //-----------------------------------------------------------------
  443. public UptownUnit getRibaoYwh(Long userId) {
  444. DateTime dateTime = new DateTime();
  445. UptownUnit uptownUnitVo = new UptownUnit();
  446. uptownUnitVo.setUptownId(0L);
  447. uptownUnitVo.setUptownName("");
  448. uptownUnitVo.setReportDate(dateTime.toDate());
  449. uptownUnitVo.setDoorplateNum(0);
  450. uptownUnitVo.setYiBaoNum(0);
  451. uptownUnitVo.setWeiBaoNum(0);
  452. uptownUnitVo.setYiChangNum(0);
  453. uptownUnitVo.setYiChangAddNum(0);
  454. uptownUnitVo.setYiChangSubNum(0);
  455. List<UserRole> userRoles = userRoleMapper.getUserRoleYwhsByUserId(userId);
  456. Long ownerId = userRoles.get(0).getPropertyId();
  457. Owner owner = ownerMapper.selectById(ownerId);
  458. Uptown uptown = uptownMapper.selectById(owner.getUptownId());
  459. Long uptownId = uptown.getUptownId();
  460. List<UptownUnit> dongList = uptownUnitMapper.queryDongList(uptownId);
  461. if (CollectionUtils.isNotEmpty(dongList)) {
  462. List<UptownUnit> xiaoQuList = uptownUnitMapper.queryXiaoQuList(uptownId);
  463. if (null == xiaoQuList) {
  464. xiaoQuList = new ArrayList<UptownUnit>();
  465. }
  466. int doorplateNum = xiaoQuList.size();
  467. Date today = new Date();
  468. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  469. String todayStr = sdf.format(today);
  470. List<UptownUnit> yiBaoList = uptownUnitMapper.queryYiBaoList(uptownId, todayStr);
  471. if (null == yiBaoList) {
  472. yiBaoList = new ArrayList<UptownUnit>();
  473. }
  474. int yiBaoNum = yiBaoList.size();
  475. List<UptownUnit> yiChangList = uptownUnitMapper.queryYiChangList(uptownId, todayStr);
  476. if (null == yiChangList) {
  477. yiChangList = new ArrayList<UptownUnit>();
  478. }
  479. int yiChangNum = yiChangList.size();
  480. // System.out.println("yiChangNum================>>" + yiChangNum);
  481. Calendar calendar = Calendar.getInstance();
  482. calendar.setTime(today);
  483. calendar.add(Calendar.DATE, -1);
  484. String yestodayStr = sdf.format(calendar.getTime());
  485. List<UptownUnit> yiChangYestodayList = uptownUnitMapper.queryYiChangList(uptownId, yestodayStr);
  486. if (null == yiChangList) {
  487. yiChangYestodayList = new ArrayList<UptownUnit>();
  488. }
  489. int yiChangYestodayNum = yiChangYestodayList.size();
  490. // System.out.println("yiChangYestodayNum================>>" + yiChangYestodayNum);
  491. UptownUnit uptownUnitDb = dongList.get(0);
  492. uptownUnitVo.setUptownId(uptownUnitDb.getUptownId());// 小区id
  493. uptownUnitVo.setUptownName(uptownUnitDb.getUptownName());// 小区名称
  494. uptownUnitVo.setReportDate(dateTime.toDate());// 日报日期
  495. uptownUnitVo.setDoorplateNum(doorplateNum);// 户数
  496. uptownUnitVo.setYiBaoNum(yiBaoNum);// 已报数
  497. uptownUnitVo.setWeiBaoNum(doorplateNum - yiBaoNum);// 未报数
  498. uptownUnitVo.setYiChangNum(yiChangNum);// 异常数
  499. if (yiChangNum - yiChangYestodayNum > 0) {
  500. uptownUnitVo.setYiChangAddNum(yiChangNum - yiChangYestodayNum);// 异常新增数
  501. }
  502. if (yiBaoNum > 0 && yiChangYestodayNum - yiChangNum > 0) {
  503. uptownUnitVo.setYiChangSubNum(yiChangYestodayNum - yiChangNum);// 异常减少数
  504. }
  505. }
  506. return uptownUnitVo;
  507. }
  508. public List<UptownUnit> queryRibaoYwhDongList(Long uptownId) {
  509. List<UptownUnit> dongList = uptownUnitMapper.queryDongList(uptownId);
  510. return dongList;
  511. }
  512. }