f1dbac4731c6e8580093fc60696a3d078345f4b2.svn-base 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  4. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  5. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  6. import cn.com.goldenwater.dcproj.dao.*;
  7. import cn.com.goldenwater.dcproj.dto.AttCountryDto;
  8. import cn.com.goldenwater.dcproj.dto.BisInspVillqhRgstrDto;
  9. import cn.com.goldenwater.dcproj.model.*;
  10. import cn.com.goldenwater.dcproj.param.*;
  11. import cn.com.goldenwater.dcproj.service.*;
  12. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  13. import cn.com.goldenwater.dcproj.utils.Builder;
  14. import cn.com.goldenwater.dcproj.utils.Constant;
  15. import cn.com.goldenwater.id.util.UuidUtil;
  16. import com.github.pagehelper.PageHelper;
  17. import com.github.pagehelper.PageInfo;
  18. import org.apache.commons.collections.MapUtils;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.springframework.beans.BeanUtils;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import org.springframework.transaction.annotation.Transactional;
  24. import javax.servlet.http.HttpServletResponse;
  25. import java.util.*;
  26. /**
  27. * @author lhc
  28. * @date 2021-2-1
  29. */
  30. @Service
  31. @Transactional
  32. public class BisInspVillqhRgstrServiceImpl extends AbstractCrudService<BisInspVillqhRgstr, BisInspVillqhRgstrParam> implements BisInspVillqhRgstrService, BisInspObjStrategy {
  33. @Autowired
  34. private BisInspVillqhRgstrDao bisInspVillqhRgstrDao;
  35. @Autowired
  36. private AttAdXBaseDao attAdXBaseDao;
  37. @Autowired
  38. private BisInspVillqhFeeService feeService;
  39. @Autowired
  40. private BisInspVillqhPoorService poorService;
  41. @Autowired
  42. private BisInspVillqhRgstrRelVillService relVillService;
  43. @Autowired
  44. private BisInspPblmDao bisInspPblmDao;
  45. @Autowired
  46. private BisInspAllObjDao bisInspAllObjDao;
  47. @Autowired
  48. private BisInspAllRlationDao bisInspAllRlationDao;
  49. public BisInspVillqhRgstrServiceImpl(BisInspVillqhRgstrDao bisInspVillqhRgstrDao) {
  50. super(bisInspVillqhRgstrDao);
  51. this.bisInspVillqhRgstrDao = bisInspVillqhRgstrDao;
  52. }
  53. @Override
  54. public int insert(BisInspVillqhRgstr bisInspVillqhRgstr) {
  55. bisInspVillqhRgstr.setId(UuidUtil.uuid());
  56. Date now = new Date();
  57. bisInspVillqhRgstr.setIntm(now);
  58. bisInspVillqhRgstr.setUptm(now);
  59. // 数据状态 默认为 0
  60. // 督查状态(0:未督查;1:督查中;2:已督查)
  61. bisInspVillqhRgstr.setState(CommonLabel.INIT_DATA);
  62. // 子表状态(0:未督查;1:督查中;2:已督查)
  63. bisInspVillqhRgstr.setFeeState(CommonLabel.INIT_DATA);
  64. bisInspVillqhRgstr.setPoorState(CommonLabel.INIT_DATA);
  65. return this.bisInspVillqhRgstrDao.insert(bisInspVillqhRgstr);
  66. }
  67. @Override
  68. public int update(BisInspVillqhRgstr bisInspVillqhRgstr) {
  69. bisInspVillqhRgstr.setUptm(new Date());
  70. return this.bisInspVillqhRgstrDao.update(bisInspVillqhRgstr);
  71. }
  72. @Override
  73. public int delete(String id) {
  74. return this.bisInspVillqhRgstrDao.delete(id);
  75. }
  76. @Override
  77. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  78. BisInspVillqhRgstr b = new BisInspVillqhRgstr();
  79. AttAdXBase base = attAdXBaseDao.get(bisInspAllObj.getCode());
  80. BeanUtils.copyProperties(base, b);
  81. b.setObjId(bisInspAllObj.getObjId());
  82. // 创建人
  83. b.setPersId(persId);
  84. /* 添加 登记表 */
  85. insert(b);
  86. }
  87. @Override
  88. public String getType() {
  89. return BisInspEnum.VILLQH.getValue();
  90. }
  91. @Override
  92. public void cleanObjData(String objId) {
  93. BisInspVillqhRgstrParam rgstrParam = new BisInspVillqhRgstrParam();
  94. rgstrParam.setObjId(objId);
  95. List<BisInspVillqhRgstr> list = this.bisInspVillqhRgstrDao.findList(rgstrParam);
  96. if (list.size() > 0) {
  97. String id = list.get(0).getId();
  98. // 删除子表
  99. BisInspVillqhRgstrRelVillParam relVillParam = new BisInspVillqhRgstrRelVillParam();
  100. relVillParam.setRegstrId(id);
  101. relVillService.deleteBy(relVillParam);
  102. // 删除登记表
  103. this.bisInspVillqhRgstrDao.delete(id);
  104. }
  105. }
  106. @Override
  107. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  108. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  109. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  110. }
  111. PageHelper.startPage(typeParam);
  112. String[] groupIds = bisInspAllRlationDao.getIdByPersid(Builder
  113. .of(BisInspAllRlationParam::new)
  114. .with(BisInspAllRlationParam::setPersid, typeParam.getPresId())
  115. .with(BisInspAllRlationParam::setpType, typeParam.getpType())
  116. .build());
  117. typeParam.setGroupIds(groupIds);
  118. List<BisInspVillqhRgstrDto> list = this.bisInspVillqhRgstrDao.findPageList(typeParam);
  119. return (PageInfo<BisInspVillqhRgstrDto>) new PageInfo(list);
  120. }
  121. @Override
  122. public Object findObjListByType(TypeParam typeParam) {
  123. return this.bisInspVillqhRgstrDao.findPageList(typeParam);
  124. }
  125. @Override
  126. public Map<String, Object> findNode(String adCode, String regstrId) {
  127. Map<String, Object> map = new HashMap<>(2);
  128. adCode = AdLevelUtil.getAddvcd(adCode);
  129. // 获取工程暗访情况
  130. BisInspVillqhFeeParam feeParam = Builder.of(BisInspVillqhFeeParam::new)
  131. .with(BisInspVillqhFeeParam::setRegstrId, regstrId)
  132. .with(BisInspVillqhFeeParam::setAdCode, adCode)
  133. .build();
  134. List<BisInspVillqhFee> feeList = feeService.findList(feeParam);
  135. // 获取农牧民情况
  136. BisInspVillqhPoorParam poorParam = Builder.of(BisInspVillqhPoorParam::new)
  137. .with(BisInspVillqhPoorParam::setRegstrId, regstrId)
  138. .with(BisInspVillqhPoorParam::setAdCode, adCode)
  139. .build();
  140. List<BisInspVillqhPoor> poorList = poorService.findList(poorParam);
  141. map.put("poor", poorList);
  142. map.put("fee", feeList);
  143. return map;
  144. }
  145. @Override
  146. public List<AttCountryDto> findCheckTree(String code, String regstrId) {
  147. // 获取镇信息
  148. List<AttCountryDto> zhenDtoList = attAdXBaseDao.findXZCZhenList(code);
  149. // 获取村信息
  150. List<AttCountryDto> countryDtoList = attAdXBaseDao.findXZCCunList(code, regstrId, BisInspEnum.VILLQH.getValue());
  151. for (AttCountryDto attCountryDto : zhenDtoList) {
  152. String adCode = attCountryDto.getAdCode().replace("000", "");
  153. List<AttCountryDto> childList = new ArrayList<>();
  154. for (AttCountryDto countryDto : countryDtoList) {
  155. if (countryDto.getAdCode().startsWith(adCode)) {
  156. childList.add(countryDto);
  157. }
  158. }
  159. attCountryDto.setAttCountryDtoList(childList);
  160. }
  161. return zhenDtoList;
  162. }
  163. @Override
  164. public void updateState(Map<String, Object> map) {
  165. BisInspVillqhRgstr rgstr = get(MapUtils.getString(map, "rgstrId"));
  166. if (!Constant.STRING_TWO.equals(rgstr.getState()) &&
  167. StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  168. rgstr.setUptm(new Date());
  169. rgstr.setState(Constant.STRING_ONE);
  170. switch (MapUtils.getString(map, "param")) {
  171. case "fee":
  172. rgstr.setFeeState(MapUtils.getString(map, "state"));
  173. break;
  174. case "poor":
  175. rgstr.setPoorState(MapUtils.getString(map, "state"));
  176. break;
  177. default:
  178. }
  179. update(rgstr);
  180. }
  181. }
  182. }