22fd727c3a6b47d21dcff71699884912ed58c4de.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  3. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  4. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  5. import cn.com.goldenwater.dcproj.dao.*;
  6. import cn.com.goldenwater.dcproj.dto.BisInspCdepRgstrDto;
  7. import cn.com.goldenwater.dcproj.model.*;
  8. import cn.com.goldenwater.dcproj.param.*;
  9. import cn.com.goldenwater.dcproj.service.*;
  10. import cn.com.goldenwater.core.service.AbstractCrudService;
  11. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  12. import cn.com.goldenwater.dcproj.utils.Constant;
  13. import com.github.pagehelper.PageHelper;
  14. import com.github.pagehelper.PageInfo;
  15. import org.apache.commons.collections.MapUtils;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.springframework.beans.BeanUtils;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import cn.com.goldenwater.id.util.UuidUtil;
  22. import javax.servlet.http.HttpServletResponse;
  23. import java.util.List;
  24. import java.util.Date;
  25. import java.util.Map;
  26. /**
  27. * @author lhc
  28. * @date 2020-11-19
  29. */
  30. @Service
  31. @Transactional
  32. public class BisInspCdepRgstrServiceImpl extends AbstractCrudService<BisInspCdepRgstr, BisInspCdepRgstrParam> implements BisInspCdepRgstrService , BisInspObjStrategy {
  33. @Autowired
  34. private BisInspCdepRgstrDao bisInspCdepRgstrDao;
  35. @Autowired
  36. private AttCdepBaseDao attCdepBaseDao;
  37. @Autowired
  38. private BisInspCdepQuaService bisInspCdepQuaService;
  39. @Autowired
  40. private BisInspCdepBehService bisInspCdepBehService;
  41. @Autowired
  42. private BisInspCdepCapService bisInspCdepCapService;
  43. @Autowired
  44. private BisInspCdepConService bisInspCdepConService;
  45. @Autowired
  46. private BisInspPblmDao bisInspPblmDao;
  47. @Autowired
  48. private BisInspAllObjDao bisInspAllObjDao;
  49. @Autowired
  50. private AttCdepBaseService attCdepBaseService;
  51. public BisInspCdepRgstrServiceImpl(BisInspCdepRgstrDao bisInspCdepRgstrDao) {
  52. super(bisInspCdepRgstrDao);
  53. this.bisInspCdepRgstrDao = bisInspCdepRgstrDao;
  54. }
  55. @Override
  56. public int insert(BisInspCdepRgstr bisInspCdepRgstr) {
  57. String uuid = UuidUtil.uuid(); // 生成uuid
  58. bisInspCdepRgstr.setId(uuid);
  59. bisInspCdepRgstr.setIntm(new Date());
  60. bisInspCdepRgstr.setUptm(new Date());
  61. bisInspCdepRgstr.setDataStat("0");
  62. return this.bisInspCdepRgstrDao.insert(bisInspCdepRgstr);
  63. }
  64. @Override
  65. public int update(BisInspCdepRgstr bisInspCdepRgstr) {
  66. bisInspCdepRgstr.setUptm(new Date());
  67. int t = this.bisInspCdepRgstrDao.update(bisInspCdepRgstr);
  68. return t;
  69. }
  70. @Override
  71. public int delete(String id) {
  72. return this.bisInspCdepRgstrDao.delete(id);
  73. }
  74. @Override
  75. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  76. BisInspCdepRgstr rgstr = new BisInspCdepRgstr();
  77. AttCdepBase base = attCdepBaseDao.get(bisInspAllObj.getCode());
  78. BeanUtils.copyProperties(base, rgstr);
  79. // 统一字段 rgstrId, objId
  80. rgstr.setId(UuidUtil.uuid());
  81. rgstr.setObjId(bisInspAllObj.getObjId());
  82. rgstr.setGroupId(bisInspAllObj.getId());
  83. rgstr.setProvince(bisInspAllObj.getProvince());
  84. // 日期
  85. Date d = new Date();
  86. rgstr.setIntm(d);
  87. rgstr.setUptm(d);
  88. rgstr.setBChkUnit(base.getDepName());
  89. rgstr.setBDepCode(base.getDepCode());
  90. // 数据状态 默认为 0
  91. rgstr.setDataStat(CommonLabel.INIT_DATA);
  92. // 督查状态(0:未督查;1:督查中;2:已督查)
  93. rgstr.setState(CommonLabel.INIT_DATA);
  94. // 子表状态(0:未督查;1:督查中;2:已督查)
  95. rgstr.setQuaState(CommonLabel.INIT_DATA);
  96. rgstr.setBehState(CommonLabel.INIT_DATA);
  97. rgstr.setCapState(CommonLabel.INIT_DATA);
  98. rgstr.setConState(CommonLabel.INIT_DATA);
  99. // 创建人
  100. rgstr.setPersId(persId);
  101. /* 添加 登记表 */
  102. this.bisInspCdepRgstrDao.insert(rgstr);
  103. /* 添加 子表 */
  104. BisInspCdepQua bisInspCdepQua = new BisInspCdepQua();
  105. bisInspCdepQua.setRgstrId(rgstr.getId());
  106. bisInspCdepQuaService.insert(bisInspCdepQua);
  107. BisInspCdepCap bisInspCdepCap = new BisInspCdepCap();
  108. bisInspCdepCap.setRgstrId(rgstr.getId());
  109. bisInspCdepCapService.insert(bisInspCdepCap);
  110. BisInspCdepCon bisInspCdepCon = new BisInspCdepCon();
  111. bisInspCdepCon.setRgstrId(rgstr.getId());
  112. bisInspCdepConService.insert(bisInspCdepCon);
  113. BisInspCdepBeh bisInspCdepBeh = new BisInspCdepBeh();
  114. bisInspCdepBeh.setRgstrId(rgstr.getId());
  115. bisInspCdepBehService.insert(bisInspCdepBeh);
  116. }
  117. @Override
  118. public String getType() {
  119. return BisInspEnum.CDEP.getValue();
  120. }
  121. @Override
  122. public void cleanObjData(String objId) {
  123. BisInspCdepRgstrParam rgstrParam = new BisInspCdepRgstrParam();
  124. rgstrParam.setObjId(objId);
  125. List<BisInspCdepRgstr> list = this.bisInspCdepRgstrDao.findList(rgstrParam);
  126. if (list.size() > 0) {
  127. String id = list.get(0).getId();
  128. // 删除子表
  129. BisInspCdepQuaParam bisInspCdepQuaParam = new BisInspCdepQuaParam();
  130. bisInspCdepQuaParam.setRgstrId(id);
  131. bisInspCdepQuaService.deleteBy(bisInspCdepQuaParam);
  132. BisInspCdepBehParam bisInspCdepBehParam = new BisInspCdepBehParam();
  133. bisInspCdepBehParam.setRgstrId(id);
  134. bisInspCdepBehService.deleteBy(bisInspCdepBehParam);
  135. BisInspCdepConParam bisInspCdepConParam = new BisInspCdepConParam();
  136. bisInspCdepConParam.setRgstrId(id);
  137. bisInspCdepConService.deleteBy(bisInspCdepConParam);
  138. BisInspCdepCapParam bisInspCdepCapParam = new BisInspCdepCapParam();
  139. bisInspCdepCapParam.setRgstrId(id);
  140. bisInspCdepCapService.deleteBy(bisInspCdepCapParam);
  141. // 删除登记表
  142. this.bisInspCdepRgstrDao.delete(id);
  143. }
  144. // 删除问题
  145. BisInspPblmParam bisInspPblmParam = new BisInspPblmParam();
  146. bisInspPblmParam.setObjId(objId);
  147. bisInspPblmParam.setObjType(BisInspEnum.CDEP.getValue());
  148. bisInspPblmDao.deleteBy(bisInspPblmParam);
  149. // 删除对象名录表
  150. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  151. bisInspAllObjParam.setObjId(objId);
  152. bisInspAllObjDao.deleteBy(bisInspAllObjParam);
  153. }
  154. @Override
  155. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  156. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  157. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  158. }
  159. PageHelper.startPage(typeParam);
  160. List<BisInspCdepRgstrDto> list = this.bisInspCdepRgstrDao.findPageList(typeParam);
  161. return (PageInfo<BisInspCdepRgstrDto>) new PageInfo(list);
  162. }
  163. @Override
  164. public Object findObjListByType(TypeParam typeParam) {
  165. return this.bisInspCdepRgstrDao.findPageList(typeParam);
  166. }
  167. @Override
  168. public BisInspCdepRgstr save(BisInspCdepRgstr bisInspCdepRgstr) {
  169. // 根据有无主键,来新增、更新信息
  170. int ret = 0;
  171. if (StringUtils.isNotBlank(bisInspCdepRgstr.getRgstrId())) {
  172. // rgstrId 不为 空 时,传给ID
  173. bisInspCdepRgstr.setId(bisInspCdepRgstr.getRgstrId());
  174. }
  175. if (StringUtils.isBlank(bisInspCdepRgstr.getId())) {
  176. if (StringUtils.isNotBlank(bisInspCdepRgstr.getObjId())) {
  177. BisInspCdepRgstrParam param = new BisInspCdepRgstrParam();
  178. param.setObjId(bisInspCdepRgstr.getId());
  179. BisInspCdepRgstr rgstr = getBy(param);
  180. // 如果没有注册表,添加
  181. if (null == rgstr) {
  182. ret = insert(bisInspCdepRgstr);
  183. } else {
  184. bisInspCdepRgstr.setId(rgstr.getId());
  185. bisInspCdepRgstr.setUptm(new Date());
  186. update(bisInspCdepRgstr);
  187. // 更新基础表
  188. updateAttCdepBase(bisInspCdepRgstr);
  189. }
  190. }
  191. } else {
  192. if (StringUtils.isBlank(bisInspCdepRgstr.getObjId())) {
  193. BisInspCdepRgstr rgstr = get(bisInspCdepRgstr.getId());
  194. if (null != rgstr) {
  195. bisInspCdepRgstr.setObjId(rgstr.getObjId());
  196. }
  197. }
  198. bisInspCdepRgstr.setUptm(new Date());
  199. update(bisInspCdepRgstr);
  200. // 更新基础表
  201. updateAttCdepBase(bisInspCdepRgstr);
  202. }
  203. return bisInspCdepRgstr;
  204. }
  205. private void updateAttCdepBase(BisInspCdepRgstr bisInspCdepRgstr) {
  206. // 清空特殊数据
  207. if (StringUtils.isNotBlank(bisInspCdepRgstr.getObjId())) {
  208. AttCdepBase attCdepBase = attCdepBaseService.getObjId(bisInspCdepRgstr.getObjId());
  209. // 转换基础表ID
  210. String attCdepBaseId = attCdepBase.getId();
  211. BeanUtils.copyProperties(bisInspCdepRgstr, attCdepBase);
  212. attCdepBase.setId(attCdepBaseId);
  213. attCdepBase.setIntm(null);
  214. attCdepBaseService.update(attCdepBase);
  215. }
  216. }
  217. @Override
  218. public PageInfo<BisInspCdepRgstr> findCdepPageInfo(BisInspCdepRgstrParam bisInspCdepRgstrParam) {
  219. PageHelper.startPage(bisInspCdepRgstrParam.getPageNum(),bisInspCdepRgstrParam.getPageSize());
  220. List<BisInspCdepRgstr> list = bisInspCdepRgstrDao.findCdepPageInfo(bisInspCdepRgstrParam);
  221. return new PageInfo(list);
  222. }
  223. @Override
  224. public void updateState(Map<String, Object> map) {
  225. BisInspCdepRgstr rgstr = get(MapUtils.getString(map, "rgstrId"));
  226. if (!Constant.STRING_TWO.equals(rgstr.getState()) &&
  227. StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  228. rgstr.setUptm(new Date());
  229. rgstr.setState(Constant.STRING_ONE);
  230. switch (MapUtils.getString(map, "param")) {
  231. case "beh":
  232. rgstr.setBehState(MapUtils.getString(map, "state"));
  233. break;
  234. case "cap":
  235. rgstr.setCapState(MapUtils.getString(map, "state"));
  236. break;
  237. case "con":
  238. rgstr.setConState(MapUtils.getString(map, "state"));
  239. break;
  240. case "qua":
  241. rgstr.setQuaState(MapUtils.getString(map, "state"));
  242. break;
  243. default:
  244. }
  245. update(rgstr);
  246. }
  247. }
  248. }