5c9ebd56f4b2b837741fbb70837ccea4eca8fe5a.svn-base 7.3 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.SplitValue;
  4. import cn.com.goldenwater.dcproj.dao.AttAdBaseDao;
  5. import cn.com.goldenwater.dcproj.dao.BisInspAllObjDao;
  6. import cn.com.goldenwater.dcproj.dao.BisInspQymtenDao;
  7. import cn.com.goldenwater.dcproj.dto.BisInspQymtenDto;
  8. import cn.com.goldenwater.dcproj.model.AttAdBase;
  9. import cn.com.goldenwater.dcproj.model.BisInspAllObj;
  10. import cn.com.goldenwater.dcproj.model.BisInspQymten;
  11. import cn.com.goldenwater.dcproj.param.*;
  12. import cn.com.goldenwater.dcproj.service.*;
  13. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  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.CollectionUtils;
  19. import org.apache.commons.collections.MapUtils;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.springframework.beans.BeanUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Service;
  24. import org.springframework.transaction.annotation.Transactional;
  25. import javax.servlet.http.HttpServletResponse;
  26. import java.util.Date;
  27. import java.util.List;
  28. import java.util.Map;
  29. import java.util.Optional;
  30. /**
  31. * @author lhc
  32. * @date 2021-7-19
  33. */
  34. @Service
  35. @Transactional
  36. public class BisInspQymtenServiceImpl extends AbstractCrudService<BisInspQymten, BisInspQymtenParam> implements BisInspQymtenService, BisInspObjStrategy {
  37. @Autowired
  38. private BisInspQymtenDao bisInspQymtenDao;
  39. @Autowired
  40. private AttAdBaseDao attAdBaseDao;
  41. @Autowired
  42. private BisInspAllObjDao bisInspAllObjDao;
  43. @Autowired
  44. private BisInspQymtenEffcService bisInspQymtenEffcService;
  45. @Autowired
  46. private BisInspQymtenMsrService bisInspQymtenMsrService;
  47. @Autowired
  48. private AttAdBaseService attAdBaseService;
  49. public BisInspQymtenServiceImpl(BisInspQymtenDao bisInspQymtenDao) {
  50. super(bisInspQymtenDao);
  51. this.bisInspQymtenDao = bisInspQymtenDao;
  52. }
  53. @Override
  54. public int insert(BisInspQymten bisInspQymten) {
  55. String uuid = UuidUtil.uuid(); // 生成uuid
  56. bisInspQymten.setId(uuid);
  57. bisInspQymten.setNm(bisInspQymten.getAdName());
  58. bisInspQymten.setIntm(new Date());
  59. bisInspQymten.setUptm(new Date());
  60. bisInspQymten.setDataStat("0");
  61. bisInspQymten.setState("0");
  62. int ret = this.bisInspQymtenDao.insert(bisInspQymten);
  63. //子表
  64. BisInspQymtenMsrParam msrParam = new BisInspQymtenMsrParam();
  65. msrParam.setRgstrId(uuid);
  66. msrParam.setPersId(bisInspQymten.getPersId());
  67. bisInspQymtenMsrService.insert(msrParam);
  68. return ret;
  69. }
  70. @Override
  71. public int update(BisInspQymten bisInspQymten) {
  72. bisInspQymten.setUptm(new Date());
  73. return this.bisInspQymtenDao.update(bisInspQymten);
  74. }
  75. @Override
  76. public int delete(String id) {
  77. return this.bisInspQymtenDao.delete(id);
  78. }
  79. @Override
  80. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  81. AttAdBase base = attAdBaseDao.get(bisInspAllObj.getCode());
  82. BisInspQymten rgstr = new BisInspQymten();
  83. BeanUtils.copyProperties(base, rgstr);
  84. rgstr.setNm(base.getAdName());
  85. rgstr.setObjId(bisInspAllObj.getObjId());
  86. rgstr.setPersId(persId);
  87. rgstr.setMsrState("0");
  88. insert(rgstr);
  89. }
  90. @Override
  91. public String getType() {
  92. return "105";
  93. }
  94. @Override
  95. public void cleanObjData(String objId) {
  96. BisInspQymtenParam param = new BisInspQymtenParam();
  97. param.setObjId(objId);
  98. List<BisInspQymten> list = bisInspQymtenDao.findList(param);
  99. if (CollectionUtils.isNotEmpty(list)) {
  100. String rgstrId = list.get(0).getId();
  101. //删除名录表
  102. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  103. bisInspAllObjParam.setObjId(objId);
  104. this.bisInspAllObjDao.deleteBy(bisInspAllObjParam);
  105. //登记表
  106. bisInspQymtenDao.delete(rgstrId);
  107. //子表
  108. BisInspQymtenMsrParam msrParam = new BisInspQymtenMsrParam();
  109. msrParam.setRgstrId(rgstrId);
  110. bisInspQymtenMsrService.deleteBy(msrParam);
  111. BisInspQymtenEffcParam effcParam = new BisInspQymtenEffcParam();
  112. effcParam.setRgstrId(rgstrId);
  113. bisInspQymtenEffcService.deleteBy(effcParam);
  114. }
  115. }
  116. @Override
  117. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  118. return this.findQymtenPage(typeParam);
  119. }
  120. @Override
  121. public Object findObjListByType(TypeParam typeParam) {
  122. List<BisInspQymtenDto> list = bisInspQymtenDao.findQymtenPage(typeParam);
  123. if (list.size() > 0) {
  124. for (BisInspQymtenDto rgstrDto : list) {
  125. String adFullName = rgstrDto.getAdFullName();
  126. if (StringUtils.isBlank(adFullName)) {
  127. continue;
  128. }
  129. if (adFullName.contains(SplitValue.HENG_SPLIT)) {
  130. String[] split = adFullName.split(SplitValue.HENG_SPLIT);
  131. if (split.length == 2) {
  132. rgstrDto.setProvince(split[0]);
  133. rgstrDto.setCity(split[1]);
  134. }
  135. if (split.length == 1) {
  136. rgstrDto.setProvince(split[0]);
  137. rgstrDto.setCity("");
  138. }
  139. } else {
  140. rgstrDto.setProvince(adFullName);
  141. }
  142. }
  143. }
  144. return list;
  145. }
  146. @Override
  147. public PageInfo<BisInspQymtenDto> findQymtenPage(TypeParam param) {
  148. if (StringUtils.isNotBlank(param.getAdCode())) {
  149. param.setAdCode(String.valueOf(AdLevelUtil.SubAd(param.getAdCode()).get(SplitValue.SUBAD)));
  150. }
  151. if (StringUtils.isNotBlank(param.getAdCodes())) {
  152. param.setAdCodes(AdLevelUtil.getListAddvcd(param.getAdCodes()));
  153. }
  154. PageHelper.startPage(param);
  155. List<BisInspQymtenDto> list = bisInspQymtenDao.findQymtenPage(param);
  156. return new PageInfo<>(list);
  157. }
  158. @Override
  159. public void updateState(Map<String, Object> map) {
  160. BisInspQymten qymten = get(MapUtils.getString(map, "rgstrId"));
  161. if (Constant.STRING_TWO.equals(qymten.getState())) {
  162. return;
  163. }
  164. String param = MapUtils.getString(map, "param");
  165. if ("msr".equals(param)) {
  166. if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
  167. qymten.setMsrState(MapUtils.getString(map, "state"));
  168. }
  169. qymten.setMsrScore(MapUtils.getDouble(map, "score"));
  170. qymten.setUptm(new Date());
  171. qymten.setState(Constant.STRING_ONE);
  172. update(qymten);
  173. }
  174. }
  175. @Override
  176. public BisInspQymten get(String key) {
  177. BisInspQymten qymten = super.get(key);
  178. Optional.ofNullable(qymten).map(BisInspQymten::getAdCode).ifPresent(adCode -> {
  179. AttAdBase attAdBase = attAdBaseService.get(adCode);
  180. Optional.ofNullable(attAdBase).ifPresent(base -> {
  181. qymten.setAdFullName(base.getAdFullName());
  182. });
  183. });
  184. return qymten;
  185. }
  186. }