aa48b567d543fd3bd7d7882546ccf091a2a5833c.svn-base 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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.BisInspAllRlationDao;
  7. import cn.com.goldenwater.dcproj.dao.BisInspRsfcoqhRgstrDao;
  8. import cn.com.goldenwater.dcproj.dto.BisInspRsfcoqhRgstrDto;
  9. import cn.com.goldenwater.dcproj.model.AttRsBase;
  10. import cn.com.goldenwater.dcproj.model.BisInspAllObj;
  11. import cn.com.goldenwater.dcproj.model.BisInspRsfcoqhRgstr;
  12. import cn.com.goldenwater.dcproj.param.BisInspAllRlationParam;
  13. import cn.com.goldenwater.dcproj.param.BisInspRsfcoqhRgstrParam;
  14. import cn.com.goldenwater.dcproj.param.TypeParam;
  15. import cn.com.goldenwater.dcproj.service.AttAdXBaseService;
  16. import cn.com.goldenwater.dcproj.service.AttRsBaseService;
  17. import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
  18. import cn.com.goldenwater.dcproj.service.BisInspRsfcoqhRgstrService;
  19. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  20. import cn.com.goldenwater.dcproj.utils.Builder;
  21. import cn.com.goldenwater.dcproj.utils.Constant;
  22. import cn.com.goldenwater.id.util.UuidUtil;
  23. import com.github.pagehelper.PageHelper;
  24. import com.github.pagehelper.PageInfo;
  25. import org.apache.commons.collections.MapUtils;
  26. import org.apache.commons.lang3.StringUtils;
  27. import org.springframework.beans.BeanUtils;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import org.springframework.transaction.annotation.Transactional;
  31. import javax.servlet.http.HttpServletResponse;
  32. import java.util.Date;
  33. import java.util.List;
  34. import java.util.Map;
  35. /**
  36. * @author lhc
  37. * @date 2021-6-10
  38. */
  39. @Service
  40. @Transactional
  41. public class BisInspRsfcoqhRgstrServiceImpl extends AbstractCrudService<BisInspRsfcoqhRgstr, BisInspRsfcoqhRgstrParam> implements BisInspRsfcoqhRgstrService, BisInspObjStrategy {
  42. @Autowired
  43. private BisInspRsfcoqhRgstrDao bisInspRsfcoqhRgstrDao;
  44. @Autowired
  45. private AttAdXBaseService attAdXBaseService;
  46. @Autowired
  47. private AttRsBaseService attRsBaseService;
  48. @Autowired
  49. private BisInspAllRlationDao bisInspAllRlationDao;
  50. public BisInspRsfcoqhRgstrServiceImpl(BisInspRsfcoqhRgstrDao bisInspRsfcoqhRgstrDao) {
  51. super(bisInspRsfcoqhRgstrDao);
  52. this.bisInspRsfcoqhRgstrDao = bisInspRsfcoqhRgstrDao;
  53. }
  54. @Override
  55. public int insert(BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr) {
  56. String uuid = UuidUtil.uuid();
  57. bisInspRsfcoqhRgstr.setId(uuid);
  58. // 日期
  59. Date d = new Date();
  60. bisInspRsfcoqhRgstr.setIntm(d);
  61. bisInspRsfcoqhRgstr.setUptm(d);
  62. // 数据状态 默认为 0
  63. bisInspRsfcoqhRgstr.setDataStat(CommonLabel.INIT_DATA);
  64. // 督查状态(0:未督查;1:督查中;2:已督查)
  65. bisInspRsfcoqhRgstr.setState(CommonLabel.INIT_DATA);
  66. return this.bisInspRsfcoqhRgstrDao.insert(bisInspRsfcoqhRgstr);
  67. }
  68. @Override
  69. public int update(BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr) {
  70. bisInspRsfcoqhRgstr.setUptm(new Date());
  71. return this.bisInspRsfcoqhRgstrDao.update(bisInspRsfcoqhRgstr);
  72. }
  73. @Override
  74. public int delete(String id) {
  75. return this.bisInspRsfcoqhRgstrDao.delete(id);
  76. }
  77. @Override
  78. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  79. BisInspRsfcoqhRgstr b = new BisInspRsfcoqhRgstr();
  80. AttRsBase base = attRsBaseService.get(bisInspAllObj.getCode());
  81. BeanUtils.copyProperties(base, b);
  82. b.setObjId(bisInspAllObj.getObjId());
  83. b.setAdName(base.getAdmDivName());
  84. b.setDamType(base.getDamType());
  85. b.setGdX(StringUtils.isNotBlank(base.getCenterXGd()) ? Double.parseDouble(base.getCenterXGd()) : null);
  86. b.setGdY(StringUtils.isNotBlank(base.getCenterYGd()) ? Double.parseDouble(base.getCenterYGd()) : null);
  87. b.setDamRegCode(base.getRegCode());
  88. b.setHasDamRegCode(StringUtils.isBlank(base.getRegCode()) ? "2" : "1");
  89. b.setAdCode(base.getAdmDiv());
  90. /* 添加 登记表 */
  91. insert(b);
  92. }
  93. @Override
  94. public String getType() {
  95. return BisInspEnum.RSFCOQH.getValue();
  96. }
  97. @Override
  98. public void cleanObjData(String objId) {
  99. BisInspRsfcoqhRgstrParam rgstrParam = new BisInspRsfcoqhRgstrParam();
  100. rgstrParam.setObjId(objId);
  101. List<BisInspRsfcoqhRgstr> list = this.bisInspRsfcoqhRgstrDao.findList(rgstrParam);
  102. if (list.size() > 0) {
  103. String id = list.get(0).getId();
  104. // 删除登记表
  105. this.bisInspRsfcoqhRgstrDao.delete(id);
  106. }
  107. }
  108. @Override
  109. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  110. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  111. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  112. }
  113. PageHelper.startPage(typeParam);
  114. String[] groupIds = bisInspAllRlationDao.getIdByPersid(Builder
  115. .of(BisInspAllRlationParam::new)
  116. .with(BisInspAllRlationParam::setPersid, typeParam.getPresId())
  117. .with(BisInspAllRlationParam::setpType, typeParam.getpType())
  118. .build());
  119. typeParam.setGroupIds(groupIds);
  120. List<BisInspRsfcoqhRgstrDto> list = this.bisInspRsfcoqhRgstrDao.findPageList(typeParam);
  121. return (PageInfo<BisInspRsfcoqhRgstrDto>) new PageInfo(list);
  122. }
  123. @Override
  124. public void updateState(Map<String, Object> map) {
  125. BisInspRsfcoqhRgstr rgstr = get(MapUtils.getString(map, "rgstrId"));
  126. if (!Constant.STRING_TWO.equals(rgstr.getState()) &&
  127. StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  128. rgstr.setUptm(new Date());
  129. rgstr.setState(Constant.STRING_ONE);
  130. if ("pres".equals(MapUtils.getString(map, "param"))) {
  131. rgstr.setPresState(MapUtils.getString(map, "state"));
  132. }
  133. update(rgstr);
  134. }
  135. }
  136. @Override
  137. public Object findObjListByType(TypeParam typeParam) {
  138. return this.bisInspRsfcoqhRgstrDao.findPageList(typeParam);
  139. }
  140. }