5a1fa298ae03f0af09c60ae3a4b59186692cd10c.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. package cn.com.goldenwater.dcproj.service.impl.vill;
  2. import cn.com.goldenwater.core.exception.BaseException;
  3. import cn.com.goldenwater.dcproj.dao.*;
  4. import cn.com.goldenwater.dcproj.dto.BisInspSecsurveyVlgDcdxDto;
  5. import cn.com.goldenwater.dcproj.dto.BisInspSecsurveyVlgDto;
  6. import cn.com.goldenwater.dcproj.dto.VillRgstrDto;
  7. import cn.com.goldenwater.dcproj.model.*;
  8. import cn.com.goldenwater.dcproj.param.*;
  9. import cn.com.goldenwater.dcproj.service.BisInspSecsurveyVlgService;
  10. import cn.com.goldenwater.core.service.AbstractCrudService;
  11. import com.github.pagehelper.PageHelper;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import org.springframework.transaction.annotation.Transactional;
  16. import com.github.pagehelper.PageInfo;
  17. import java.util.List;
  18. import cn.com.goldenwater.id.util.UuidUtil;
  19. import java.util.Date;
  20. import cn.com.goldenwater.dcproj.utils.DateUtils;
  21. /**
  22. * @author zhengdafei
  23. * @date 2019-2-19
  24. */
  25. @Service
  26. @Transactional
  27. public class BisInspSecsurveyVlgServiceImpl extends AbstractCrudService<BisInspSecsurveyVlg, BisInspSecsurveyVlgParam> implements BisInspSecsurveyVlgService {
  28. @Autowired
  29. private BisInspSecsurveyVlgDao bisInspSecsurveyVlgDao;
  30. @Autowired
  31. private BisInspVlgdrinkFacOperDao bisInspVlgdrinkFacOperDao;
  32. @Autowired
  33. private BisInspWateruserInfoDao bisInspWateruserInfoDao;
  34. @Autowired
  35. private BisInspVillRgstrDao bisInspVillRgstrDao;
  36. public BisInspSecsurveyVlgServiceImpl(BisInspSecsurveyVlgDao bisInspSecsurveyVlgDao) {
  37. super(bisInspSecsurveyVlgDao);
  38. this.bisInspSecsurveyVlgDao = bisInspSecsurveyVlgDao;
  39. }
  40. @Override
  41. public String add(BisInspSecsurveyVlg p) throws Exception {
  42. String uuid = UuidUtil.uuid();
  43. String now = DateUtils.getTodayYMDHMS();
  44. p.setCreateTime(now);
  45. p.setUpdateTime(now);
  46. p.setVillId(uuid);
  47. BisInspSecsurveyVlgParam bp = new BisInspSecsurveyVlgParam();
  48. bp.setEngId(p.getEngId());
  49. bp.setVillageCode(p.getVillageCode());
  50. BisInspSecsurveyVlg vlg = bisInspSecsurveyVlgDao.getBy(bp);
  51. if (vlg != null) {
  52. throw new Exception("520");
  53. }
  54. bisInspSecsurveyVlgDao.insert(p);
  55. BisInspVillRgstr rp = new BisInspVillRgstr();
  56. rp.setEngId(p.getEngId());
  57. rp.setState("1");
  58. bisInspVillRgstrDao.update(rp);
  59. return uuid;
  60. }
  61. @Override
  62. public int modify(BisInspSecsurveyVlg p) throws Exception {
  63. String now = DateUtils.getTodayYMDHMS();
  64. p.setUpdateTime(now);
  65. int ret = bisInspSecsurveyVlgDao.update(p);
  66. return ret;
  67. }
  68. @Override
  69. public PageInfo<BisInspSecsurveyVlg> queryListByPage(BisInspSecsurveyVlgParam p) throws Exception {
  70. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  71. List<BisInspSecsurveyVlg> list = bisInspSecsurveyVlgDao.findList(p);
  72. return new PageInfo<BisInspSecsurveyVlg>(list);
  73. }
  74. @Override
  75. public List<BisInspSecsurveyVlg> queryList(BisInspSecsurveyVlgParam p) throws Exception {
  76. List<BisInspSecsurveyVlg> list = bisInspSecsurveyVlgDao.findList(p);
  77. return list;
  78. }
  79. @Override
  80. public BisInspSecsurveyVlgDto getOne(BisInspSecsurveyVlgParam p) throws Exception {
  81. BisInspSecsurveyVlgDto dto = new BisInspSecsurveyVlgDto();
  82. BisInspSecsurveyVlg vlg = bisInspSecsurveyVlgDao.getBy(p);
  83. if (vlg != null) {
  84. dto.setAdNm(vlg.getAdNm());
  85. dto.setCreateTime(vlg.getCreateTime());
  86. dto.setCwsStatus(vlg.getStatus());
  87. dto.setEngId(vlg.getEngId());
  88. dto.setIsCenwtSupply(vlg.getIsCenwtSupply());
  89. dto.setIsFluexc(vlg.getIsFluexc());
  90. dto.setIsMtarea(vlg.getIsMtarea());
  91. dto.setRecPers2(vlg.getRecPers2());
  92. dto.setIsPoverty(vlg.getIsPoverty());
  93. dto.setUpdateTime(vlg.getUpdateTime());
  94. dto.setVillId(vlg.getVillId());
  95. dto.setRecPersId(vlg.getRecPersId());
  96. dto.setRecPersTel(vlg.getRecPersTel());
  97. dto.setVillageCode(vlg.getVillageCode());
  98. dto.setVisitDate(vlg.getVisitDate());
  99. dto.setWatersupplyPer(vlg.getWatersupplyPer());
  100. dto.setWasPoverty(vlg.getWasPoverty());
  101. BisInspVlgdrinkFacOperParam op = new BisInspVlgdrinkFacOperParam();
  102. op.setEngId(vlg.getEngId());
  103. op.setAdCode(p.getVillageCode());
  104. BisInspVlgdrinkFacOper fac = bisInspVlgdrinkFacOperDao.getBy(op);
  105. if (fac != null) {
  106. dto.setCwsStatus("1");
  107. } else {
  108. dto.setCwsStatus("0");
  109. }
  110. BisInspWateruserInfoParam ip = new BisInspWateruserInfoParam();
  111. ip.setEngId(vlg.getEngId());
  112. ip.setVillageCode(p.getVillageCode());
  113. List<BisInspWateruserInfo> infoList = bisInspWateruserInfoDao.findList(ip);
  114. if (infoList != null && infoList.size() > 0) {
  115. dto.setUserStatus("1");
  116. } else {
  117. dto.setUserStatus("0");
  118. }
  119. }
  120. return dto;
  121. }
  122. /**
  123. * 获取最新数据
  124. */
  125. @Override
  126. public BisInspSecsurveyVlgDto getNearOne(BisInspSecsurveyVlgParam p) throws Exception {
  127. BisInspSecsurveyVlgDto dto = new BisInspSecsurveyVlgDto();
  128. BisInspSecsurveyVlg vlg = new BisInspSecsurveyVlg();
  129. List<BisInspSecsurveyVlg> vlgDaoList = bisInspSecsurveyVlgDao.findList(p);//取最新数据
  130. if (vlgDaoList != null && !vlgDaoList.isEmpty()) {
  131. vlg = vlgDaoList.get(0);
  132. if (vlg != null) {
  133. dto.setAdNm(vlg.getAdNm());
  134. dto.setCreateTime(vlg.getCreateTime());
  135. dto.setCwsStatus(vlg.getStatus());
  136. dto.setEngId(vlg.getEngId());
  137. dto.setIsCenwtSupply(vlg.getIsCenwtSupply());
  138. dto.setIsFluexc(vlg.getIsFluexc());
  139. dto.setIsMtarea(vlg.getIsMtarea());
  140. dto.setRecPers2(vlg.getRecPers2());
  141. dto.setIsPoverty(vlg.getIsPoverty());
  142. dto.setUpdateTime(vlg.getUpdateTime());
  143. dto.setVillId(vlg.getVillId());
  144. dto.setRecPersId(vlg.getRecPersId());
  145. dto.setRecPersTel(vlg.getRecPersTel());
  146. dto.setVillageCode(vlg.getVillageCode());
  147. dto.setVisitDate(vlg.getVisitDate());
  148. dto.setWatersupplyPer(vlg.getWatersupplyPer());
  149. dto.setWasPoverty(vlg.getWasPoverty());
  150. BisInspVlgdrinkFacOperParam op = new BisInspVlgdrinkFacOperParam();
  151. op.setEngId(vlg.getEngId());
  152. op.setAdCode(p.getVillageCode());
  153. List<BisInspVlgdrinkFacOper> fac = bisInspVlgdrinkFacOperDao.findList(op);
  154. if (fac != null && !fac.isEmpty()) {
  155. dto.setCwsStatus("1");
  156. } else {
  157. dto.setCwsStatus("0");
  158. }
  159. BisInspWateruserInfoParam ip = new BisInspWateruserInfoParam();
  160. ip.setEngId(vlg.getEngId());
  161. ip.setVillageCode(p.getVillageCode());
  162. List<BisInspWateruserInfo> info = bisInspWateruserInfoDao.findList(ip);
  163. if (info != null && !info.isEmpty()) {
  164. dto.setUserStatus("1");
  165. } else {
  166. dto.setUserStatus("0");
  167. }
  168. }
  169. }
  170. dto = dto;
  171. return dto;
  172. }
  173. @Override
  174. public List<BisInspSecsurveyVlg> getListByCodeAndPerId(VillRgstrDto villRgstrDto) {
  175. return this.bisInspSecsurveyVlgDao.getListByCodeAndPerId(villRgstrDto);
  176. }
  177. @Override
  178. public PageInfo<BisInspSecsurveyVlg> getPageByCodeAndPerId(VillRgstrDto villRgstrDto) {
  179. PageHelper.startPage(villRgstrDto.getPageNum(), villRgstrDto.getPageSize());
  180. List<BisInspSecsurveyVlg> list = bisInspSecsurveyVlgDao.getListByCodeAndPerId(villRgstrDto);
  181. return new PageInfo<BisInspSecsurveyVlg>(list);
  182. }
  183. @Override
  184. public PageInfo<BisInspSecsurveyVlgDcdxDto> getPageByNodeId(GetVillPageByNodeIdParam p) throws Exception {
  185. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  186. List<BisInspSecsurveyVlgDcdxDto> list = bisInspSecsurveyVlgDao.getPageByNodeId(p);
  187. return new PageInfo<BisInspSecsurveyVlgDcdxDto>(list);
  188. }
  189. }