9a37ee26545eace6dc922fde5673337169390a26.svn-base 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.BisInspWrwxRgstrDto;
  8. import cn.com.goldenwater.dcproj.model.*;
  9. import cn.com.goldenwater.dcproj.param.*;
  10. import cn.com.goldenwater.dcproj.service.*;
  11. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  12. import cn.com.goldenwater.id.util.UuidUtil;
  13. import com.github.pagehelper.PageHelper;
  14. import com.github.pagehelper.PageInfo;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.springframework.beans.BeanUtils;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.transaction.annotation.Transactional;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.Date;
  22. import java.util.List;
  23. /**
  24. * @author lhc
  25. * @date 2020-9-23
  26. */
  27. @Service
  28. @Transactional
  29. public class BisInspWrwxRgstrServiceImpl extends AbstractCrudService<BisInspWrwxRgstr, BisInspWrwxRgstrParam> implements BisInspWrwxRgstrService, BisInspObjStrategy {
  30. @Autowired
  31. private BisInspWrwxRgstrDao bisInspWrwxRgstrDao;
  32. @Autowired
  33. private AttAdBaseDao attAdBaseDao;
  34. @Autowired
  35. private BisInspWrwxRgstrSvwtcService bisInspWrwxRgstrSvwtcService;
  36. @Autowired
  37. private BisInspWrwxRgstrWgService bisInspWrwxRgstrWgService;
  38. @Autowired
  39. private BisInspWrwxRgstrWtupService bisInspWrwxRgstrWtupService;
  40. @Autowired
  41. private BisInspWrwxRgstrWtutService bisInspWrwxRgstrWtutService;
  42. @Autowired
  43. private BisInspPblmDao bisInspPblmDao;
  44. @Autowired
  45. private BisInspAllObjDao bisInspAllObjDao;
  46. public BisInspWrwxRgstrServiceImpl(BisInspWrwxRgstrDao bisInspWrwxRgstrDao) {
  47. super(bisInspWrwxRgstrDao);
  48. this.bisInspWrwxRgstrDao = bisInspWrwxRgstrDao;
  49. }
  50. @Override
  51. public int insert(BisInspWrwxRgstr bisInspWrwxRgstr) {
  52. // 生成uuid
  53. String uuid = UuidUtil.uuid();
  54. bisInspWrwxRgstr.setId(uuid);
  55. bisInspWrwxRgstr.setIntm(new Date());
  56. bisInspWrwxRgstr.setUptm(new Date());
  57. bisInspWrwxRgstr.setDataStat("0");
  58. return this.bisInspWrwxRgstrDao.insert(bisInspWrwxRgstr);
  59. }
  60. @Override
  61. public int update(BisInspWrwxRgstr bisInspWrwxRgstr) {
  62. bisInspWrwxRgstr.setUptm(new Date());
  63. return this.bisInspWrwxRgstrDao.update(bisInspWrwxRgstr);
  64. }
  65. @Override
  66. public int delete(String id) {
  67. return this.bisInspWrwxRgstrDao.delete(id);
  68. }
  69. @Override
  70. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  71. BisInspWrwxRgstr b = new BisInspWrwxRgstr();
  72. AttAdBase base = attAdBaseDao.get(bisInspAllObj.getCode());
  73. BeanUtils.copyProperties(base, b);
  74. // 统一字段 rgstrId, objId
  75. b.setId(UuidUtil.uuid());
  76. b.setObjId(bisInspAllObj.getObjId());
  77. // 日期
  78. Date d = new Date();
  79. b.setIntm(d);
  80. b.setUptm(d);
  81. // 数据状态 默认为 0
  82. b.setDataStat(CommonLabel.INIT_DATA);
  83. // 督查状态(0:未督查;1:督查中;2:已督查)
  84. b.setState(CommonLabel.INIT_DATA);
  85. // 子表状态(0:未督查;1:督查中;2:已督查)
  86. b.setSvwtcState(CommonLabel.INIT_DATA);
  87. b.setWgState(CommonLabel.INIT_DATA);
  88. b.setWtupState(CommonLabel.INIT_DATA);
  89. b.setWtutState(CommonLabel.INIT_DATA);
  90. // 创建人
  91. b.setPersId(persId);
  92. /* 添加 登记表 */
  93. this.bisInspWrwxRgstrDao.insert(b);
  94. /* 添加 子表 */
  95. BisInspWrwxRgstrSvwtc bisInspWrwxRgstrSvwtc = new BisInspWrwxRgstrSvwtc();
  96. bisInspWrwxRgstrSvwtc.setRgstrId(b.getId());
  97. bisInspWrwxRgstrSvwtcService.insert(bisInspWrwxRgstrSvwtc);
  98. BisInspWrwxRgstrWg bisInspWrwxRgstrWg = new BisInspWrwxRgstrWg();
  99. bisInspWrwxRgstrWg.setRgstrId(b.getId());
  100. bisInspWrwxRgstrWgService.insert(bisInspWrwxRgstrWg);
  101. BisInspWrwxRgstrWtup bisInspWrwxRgstrWtup = new BisInspWrwxRgstrWtup();
  102. bisInspWrwxRgstrWtup.setRgstrId(b.getId());
  103. bisInspWrwxRgstrWtupService.insert(bisInspWrwxRgstrWtup);
  104. BisInspWrwxRgstrWtut bisInspWrwxRgstrWtut = new BisInspWrwxRgstrWtut();
  105. bisInspWrwxRgstrWtut.setRgstrId(b.getId());
  106. bisInspWrwxRgstrWtutService.insert(bisInspWrwxRgstrWtut);
  107. }
  108. @Override
  109. public String getType() {
  110. return BisInspEnum.WRWX.getValue();
  111. }
  112. @Override
  113. public void cleanObjData(String objId) {
  114. BisInspWrwxRgstrParam rgstrParam = new BisInspWrwxRgstrParam();
  115. rgstrParam.setObjId(objId);
  116. List<BisInspWrwxRgstr> list = this.bisInspWrwxRgstrDao.findList(rgstrParam);
  117. if (list.size() > 0) {
  118. String id = list.get(0).getId();
  119. // 删除子表
  120. BisInspWrwxRgstrSvwtcParam svwtcParam = new BisInspWrwxRgstrSvwtcParam();
  121. svwtcParam.setRgstrId(id);
  122. bisInspWrwxRgstrSvwtcService.deleteBy(svwtcParam);
  123. BisInspWrwxRgstrWtutParam wtutParam = new BisInspWrwxRgstrWtutParam();
  124. wtutParam.setRgstrId(id);
  125. bisInspWrwxRgstrWtutService.deleteBy(wtutParam);
  126. BisInspWrwxRgstrWgParam wgParam = new BisInspWrwxRgstrWgParam();
  127. wgParam.setRgstrId(id);
  128. bisInspWrwxRgstrWgService.deleteBy(wgParam);
  129. BisInspWrwxRgstrWtupParam wtupParam = new BisInspWrwxRgstrWtupParam();
  130. wtupParam.setRgstrId(id);
  131. bisInspWrwxRgstrWtupService.deleteBy(wtupParam);
  132. // 删除登记表
  133. this.bisInspWrwxRgstrDao.delete(id);
  134. }
  135. // 删除问题
  136. BisInspPblmParam bisInspPblmParam = new BisInspPblmParam();
  137. bisInspPblmParam.setObjId(objId);
  138. bisInspPblmParam.setObjType(getType());
  139. bisInspPblmDao.deleteBy(bisInspPblmParam);
  140. // 删除对象名录表
  141. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  142. bisInspAllObjParam.setObjId(objId);
  143. bisInspAllObjDao.deleteBy(bisInspAllObjParam);
  144. }
  145. @Override
  146. public PageInfo<BisInspWrwxRgstrDto> findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  147. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  148. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  149. }
  150. PageHelper.startPage(typeParam);
  151. List<BisInspWrwxRgstrDto> list = this.bisInspWrwxRgstrDao.findPageList(typeParam);
  152. return (PageInfo<BisInspWrwxRgstrDto>) new PageInfo(list);
  153. }
  154. @Override
  155. public Object findObjListByType(TypeParam typeParam) {
  156. return this.bisInspWrwxRgstrDao.findPageList(typeParam);
  157. }
  158. }