06a3e8af50b696b67184f7342fdc9c1601e3bc73.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. package cn.com.goldenwater.dcproj.service.impl.ducha;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  4. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  5. import cn.com.goldenwater.dcproj.dao.BisInspHystpDao;
  6. import cn.com.goldenwater.dcproj.dto.BisInspHystpDto;
  7. import cn.com.goldenwater.dcproj.model.AttHystpBase;
  8. import cn.com.goldenwater.dcproj.model.BisInspAllObj;
  9. import cn.com.goldenwater.dcproj.model.BisInspHystp;
  10. import cn.com.goldenwater.dcproj.model.BisInspHystpBldflt;
  11. import cn.com.goldenwater.dcproj.model.BisInspHystpDuty;
  12. import cn.com.goldenwater.dcproj.model.BisInspHystpDvc;
  13. import cn.com.goldenwater.dcproj.model.BisInspHystpOthr;
  14. import cn.com.goldenwater.dcproj.model.BisInspHystpRun;
  15. import cn.com.goldenwater.dcproj.model.BisInspHystpSaf;
  16. import cn.com.goldenwater.dcproj.param.BisInspHystpBldfltParam;
  17. import cn.com.goldenwater.dcproj.param.BisInspHystpDutyParam;
  18. import cn.com.goldenwater.dcproj.param.BisInspHystpDvcParam;
  19. import cn.com.goldenwater.dcproj.param.BisInspHystpOthrParam;
  20. import cn.com.goldenwater.dcproj.param.BisInspHystpParam;
  21. import cn.com.goldenwater.dcproj.param.BisInspHystpRunParam;
  22. import cn.com.goldenwater.dcproj.param.BisInspHystpSafParam;
  23. import cn.com.goldenwater.dcproj.param.TypeParam;
  24. import cn.com.goldenwater.dcproj.service.AttHystpBaseService;
  25. import cn.com.goldenwater.dcproj.service.BisInspHystpBldfltService;
  26. import cn.com.goldenwater.dcproj.service.BisInspHystpDutyService;
  27. import cn.com.goldenwater.dcproj.service.BisInspHystpDvcService;
  28. import cn.com.goldenwater.dcproj.service.BisInspHystpOthrService;
  29. import cn.com.goldenwater.dcproj.service.BisInspHystpRunService;
  30. import cn.com.goldenwater.dcproj.service.BisInspHystpSafService;
  31. import cn.com.goldenwater.dcproj.service.BisInspHystpService;
  32. import cn.com.goldenwater.dcproj.service.BisInspPblmService;
  33. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  34. import cn.com.goldenwater.dcproj.utils.Builder;
  35. import cn.com.goldenwater.dcproj.utils.Constant;
  36. import cn.com.goldenwater.id.util.UuidUtil;
  37. import com.github.pagehelper.PageHelper;
  38. import com.github.pagehelper.PageInfo;
  39. import org.apache.commons.collections.MapUtils;
  40. import org.apache.commons.lang.StringUtils;
  41. import org.slf4j.Logger;
  42. import org.slf4j.LoggerFactory;
  43. import org.springframework.beans.BeanUtils;
  44. import org.springframework.beans.factory.annotation.Autowired;
  45. import org.springframework.stereotype.Service;
  46. import org.springframework.transaction.annotation.Transactional;
  47. import javax.servlet.http.HttpServletResponse;
  48. import java.util.Date;
  49. import java.util.List;
  50. import java.util.Map;
  51. import java.util.Optional;
  52. /**
  53. * @author lhc
  54. * @date 2022-3-23
  55. */
  56. @Service
  57. @Transactional
  58. public class BisInspHystpServiceImpl extends AbstractCrudService<BisInspHystp, BisInspHystpParam> implements BisInspHystpService {
  59. private Logger logger = LoggerFactory.getLogger(getClass());
  60. @Autowired
  61. private BisInspHystpDao bisInspHystpDao;
  62. @Autowired
  63. private AttHystpBaseService attHystpBaseService;
  64. @Autowired
  65. private BisInspHystpBldfltService bisInspHystpBldfltService;
  66. @Autowired
  67. private BisInspHystpDvcService bisInspHystpDvcService;
  68. @Autowired
  69. private BisInspHystpSafService bisInspHystpSafService;
  70. @Autowired
  71. private BisInspHystpRunService bisInspHystpRunService;
  72. @Autowired
  73. private BisInspHystpOthrService bisInspHystpOthrService;
  74. @Autowired
  75. private BisInspHystpDutyService bisInspHystpDutyService;
  76. @Autowired
  77. private BisInspPblmService bisInspPblmService;
  78. public BisInspHystpServiceImpl(BisInspHystpDao bisInspHystpDao) {
  79. super(bisInspHystpDao);
  80. this.bisInspHystpDao = bisInspHystpDao;
  81. }
  82. @Override
  83. public int insert(BisInspHystp bisInspHystp) {
  84. String uuid = UuidUtil.uuid(); // 生成uuid
  85. bisInspHystp.setId(uuid);
  86. bisInspHystp.setIntm(new Date());
  87. bisInspHystp.setUptm(new Date());
  88. bisInspHystp.setDataStat("0");
  89. bisInspHystp.setState("0");
  90. bisInspHystp.setBldfltState("0");
  91. bisInspHystp.setDvcState("0");
  92. bisInspHystp.setDutyState("0");
  93. bisInspHystp.setSafState("0");
  94. bisInspHystp.setOthrState("0");
  95. bisInspHystp.setRunState("0");
  96. this.bisInspHystpBldfltService.insert(Builder.of(BisInspHystpBldflt::new)
  97. .with(BisInspHystpBldflt::setRgstrId, uuid)
  98. .build());
  99. this.bisInspHystpDvcService.insert(Builder.of(BisInspHystpDvc::new)
  100. .with(BisInspHystpDvc::setRgstrId, uuid)
  101. .build());
  102. this.bisInspHystpSafService.insert(Builder.of(BisInspHystpSaf::new)
  103. .with(BisInspHystpSaf::setRgstrId, uuid)
  104. .build());
  105. this.bisInspHystpRunService.insert(Builder.of(BisInspHystpRun::new)
  106. .with(BisInspHystpRun::setRgstrId, uuid)
  107. .build());
  108. this.bisInspHystpDutyService.insert(Builder.of(BisInspHystpDuty::new)
  109. .with(BisInspHystpDuty::setRgstrId, uuid)
  110. .build());
  111. this.bisInspHystpOthrService.insert(Builder.of(BisInspHystpOthr::new)
  112. .with(BisInspHystpOthr::setRgstrId, uuid)
  113. .build());
  114. return this.bisInspHystpDao.insert(bisInspHystp);
  115. }
  116. @Override
  117. public int update(BisInspHystp bisInspHystp) {
  118. if(StringUtils.isNotBlank(bisInspHystp.getObjId())){
  119. updateBase(bisInspHystp);
  120. }
  121. bisInspHystp.setUptm(new Date());
  122. // 更新登记表状态
  123. int rows = this.bisInspHystpDao.update(bisInspHystp);
  124. // 更新问题状态
  125. updatePblmState(bisInspHystp);
  126. return rows;
  127. }
  128. private void updatePblmState(BisInspHystp rgstr) {
  129. BisInspHystp r = get(rgstr.getId());
  130. if (r == null) {
  131. return;
  132. }
  133. logger.info("BisInspHystp:" + r.toString());
  134. bisInspPblmService.updateStateByObjId(r.getObjId(), rgstr.getState());
  135. }
  136. /**
  137. * 更新基础表
  138. */
  139. void updateBase(BisInspHystp bisInspHystp) {
  140. AttHystpBase base = attHystpBaseService.getObjId(bisInspHystp.getObjId());
  141. Optional.ofNullable(base).ifPresent(b -> {
  142. String id = b.getId();
  143. BeanUtils.copyProperties(bisInspHystp, b);
  144. b.setId(id);
  145. b.setIntm(null);
  146. attHystpBaseService.update(b);
  147. });
  148. }
  149. @Override
  150. public int delete(String id) {
  151. return this.bisInspHystpDao.delete(id);
  152. }
  153. @Override
  154. public void updateState(Map<String, Object> map) {
  155. BisInspHystp rgstr = get(MapUtils.getString(map, "rgstrId"));
  156. if (!Constant.STRING_TWO.equals(rgstr.getState())) {
  157. rgstr.setUptm(new Date());
  158. rgstr.setState(Constant.STRING_ONE);
  159. if ("bldflt".equals(MapUtils.getString(map, "param"))) {
  160. if (StringUtils.isBlank(rgstr.getBldfltState()) &&
  161. !"2".equals(MapUtils.getString(map, "state"))) {
  162. map.put("state", "1");
  163. }
  164. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  165. rgstr.setBldfltState(MapUtils.getString(map, "state"));
  166. }
  167. }
  168. if ("duty".equals(MapUtils.getString(map, "param"))) {
  169. if (StringUtils.isBlank(rgstr.getDutyState()) &&
  170. !"2".equals(MapUtils.getString(map, "state"))) {
  171. map.put("state", "1");
  172. }
  173. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  174. rgstr.setDutyState(MapUtils.getString(map, "state"));
  175. }
  176. }
  177. if ("dvc".equals(MapUtils.getString(map, "param"))) {
  178. if (StringUtils.isBlank(rgstr.getDvcState()) &&
  179. !"2".equals(MapUtils.getString(map, "state"))) {
  180. map.put("state", "1");
  181. }
  182. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  183. rgstr.setDvcState(MapUtils.getString(map, "state"));
  184. }
  185. }
  186. if ("run".equals(MapUtils.getString(map, "param"))) {
  187. if (StringUtils.isBlank(rgstr.getRunState()) &&
  188. !"2".equals(MapUtils.getString(map, "state"))) {
  189. map.put("state", "1");
  190. }
  191. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  192. rgstr.setRunState(MapUtils.getString(map, "state"));
  193. }
  194. }
  195. if ("saf".equals(MapUtils.getString(map, "param"))) {
  196. if (StringUtils.isBlank(rgstr.getSafState()) &&
  197. !"2".equals(MapUtils.getString(map, "state"))) {
  198. map.put("state", "1");
  199. }
  200. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  201. rgstr.setSafState(MapUtils.getString(map, "state"));
  202. }
  203. }
  204. if ("othr".equals(MapUtils.getString(map, "param"))) {
  205. if (StringUtils.isBlank(rgstr.getOthrState()) &&
  206. !"2".equals(MapUtils.getString(map, "state"))) {
  207. map.put("state", "1");
  208. }
  209. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  210. rgstr.setOthrState(MapUtils.getString(map, "state"));
  211. }
  212. }
  213. update(rgstr);
  214. }
  215. }
  216. @Override
  217. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  218. BisInspHystp b = new BisInspHystp();
  219. AttHystpBase base = attHystpBaseService.get(bisInspAllObj.getCode());
  220. BeanUtils.copyProperties(base, b);
  221. b.setObjId(bisInspAllObj.getObjId());
  222. // b.setPersId(bisInspAllObj.getPersId());
  223. // 添加 登记表
  224. insert(b);
  225. }
  226. @Override
  227. public String getType() {
  228. return BisInspEnum.HYSTP.getValue();
  229. }
  230. @Override
  231. public void cleanObjData(String objId) {
  232. BisInspHystpParam rgstrParam = new BisInspHystpParam();
  233. rgstrParam.setObjId(objId);
  234. List<BisInspHystp> list = this.bisInspHystpDao.findList(rgstrParam);
  235. if (list.size() > 0) {
  236. String id = list.get(0).getId();
  237. // 删除子表
  238. this.bisInspHystpBldfltService.deleteBy(Builder.of(BisInspHystpBldfltParam::new).with(BisInspHystpBldfltParam::setRgstrId, id).build());
  239. this.bisInspHystpDvcService.deleteBy(Builder.of(BisInspHystpDvcParam::new).with(BisInspHystpDvcParam::setRgstrId, id).build());
  240. this.bisInspHystpSafService.deleteBy(Builder.of(BisInspHystpSafParam::new).with(BisInspHystpSafParam::setRgstrId, id).build());
  241. this.bisInspHystpRunService.deleteBy(Builder.of(BisInspHystpRunParam::new).with(BisInspHystpRunParam::setRgstrId, id).build());
  242. this.bisInspHystpOthrService.deleteBy(Builder.of(BisInspHystpOthrParam::new).with(BisInspHystpOthrParam::setRgstrId, id).build());
  243. this.bisInspHystpDutyService.deleteBy(Builder.of(BisInspHystpDutyParam::new).with(BisInspHystpDutyParam::setRgstrId, id).build());
  244. // 删除登记表
  245. this.bisInspHystpDao.delete(id);
  246. }
  247. }
  248. @Override
  249. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  250. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  251. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  252. }
  253. PageHelper.startPage(typeParam);
  254. List<BisInspHystpDto> list = this.bisInspHystpDao.findPageList(typeParam);
  255. if (list != null && list.size() > 0) {
  256. list.forEach(rgstrDto -> {
  257. if (StringUtils.isNotBlank(rgstrDto.getAdFullName())) {
  258. String[] adFullNames = rgstrDto.getAdFullName().split("-");
  259. rgstrDto.setProName(adFullNames[0]);
  260. if (adFullNames.length > 1) {
  261. rgstrDto.setCityName(adFullNames[1]);
  262. }
  263. if (adFullNames.length > 2) {
  264. rgstrDto.setCountyName(adFullNames[2]);
  265. }
  266. }
  267. });
  268. }
  269. return new PageInfo<>(list);
  270. }
  271. @Override
  272. public Object findObjListByType(TypeParam typeParam) {
  273. return null;
  274. }
  275. }