3f3f2ec200f582895f5d8d573d09aed45ea981dc.svn-base 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. package cn.com.goldenwater.dcproj.service.impl.vill;
  2. import cn.com.goldenwater.dcproj.dao.AttCwsBaseDao;
  3. import cn.com.goldenwater.dcproj.dao.BisInspVillRgstrDao;
  4. import cn.com.goldenwater.dcproj.dao.BisInspVlgdrinkProjManageDao;
  5. import cn.com.goldenwater.dcproj.dto.BisInspVlgdrinkProjManageDcdxDto;
  6. import cn.com.goldenwater.dcproj.dto.VillRgstrDto;
  7. import cn.com.goldenwater.dcproj.model.AttCwsBase;
  8. import cn.com.goldenwater.dcproj.model.BisInspVillRgstr;
  9. import cn.com.goldenwater.dcproj.model.BisInspVlgdrinkProjManage;
  10. import cn.com.goldenwater.dcproj.param.AttCwsBaseParam;
  11. import cn.com.goldenwater.dcproj.param.BisInspVlgdrinkProjManageParam;
  12. import cn.com.goldenwater.dcproj.param.GetPageByNodeIdParam;
  13. import cn.com.goldenwater.dcproj.param.GetVillPageByNodeIdParam;
  14. import cn.com.goldenwater.dcproj.service.BisInspVlgdrinkProjManageService;
  15. import cn.com.goldenwater.core.service.AbstractCrudService;
  16. import com.github.pagehelper.PageHelper;
  17. import org.apache.commons.lang3.StringUtils;
  18. import org.apache.commons.lang3.math.NumberUtils;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Service;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import com.github.pagehelper.PageInfo;
  23. import java.util.List;
  24. import cn.com.goldenwater.id.util.UuidUtil;
  25. import java.util.Date;
  26. import cn.com.goldenwater.dcproj.utils.DateUtils;
  27. /**
  28. * @author zhengdafei
  29. * @date 2019-2-21
  30. */
  31. @Service
  32. @Transactional
  33. public class BisInspVlgdrinkProjManageServiceImpl extends AbstractCrudService<BisInspVlgdrinkProjManage, BisInspVlgdrinkProjManageParam> implements BisInspVlgdrinkProjManageService {
  34. @Autowired
  35. private BisInspVlgdrinkProjManageDao bisInspVlgdrinkProjManageDao;
  36. @Autowired
  37. private AttCwsBaseDao attCwsBaseDao;
  38. @Autowired
  39. private BisInspVillRgstrDao bisInspVillRgstrDao;
  40. public BisInspVlgdrinkProjManageServiceImpl(BisInspVlgdrinkProjManageDao bisInspVlgdrinkProjManageDao) {
  41. super(bisInspVlgdrinkProjManageDao);
  42. this.bisInspVlgdrinkProjManageDao = bisInspVlgdrinkProjManageDao;
  43. }
  44. @Override
  45. public String add(BisInspVlgdrinkProjManage p) throws Exception {
  46. String uuid = UuidUtil.uuid();
  47. String now = DateUtils.getTodayYMDHMS();
  48. p.setCreateTime(now);
  49. p.setUpdateTime(now);
  50. p.setRunId(uuid);
  51. AttCwsBaseParam cwsp = new AttCwsBaseParam();
  52. cwsp.setCwsCode(p.getCwsCode());
  53. if (StringUtils.isNotBlank(p.getCwsCode())) {
  54. AttCwsBase cws = attCwsBaseDao.getBy(cwsp);
  55. if (cws != null) {
  56. if (StringUtils.isBlank(p.getPjnm())) {
  57. p.setPjnm(cws.getCwsName());
  58. }
  59. if (StringUtils.isBlank(p.getVillageNm())) {
  60. p.setVillageNm(cws.getCwsLoc());
  61. }
  62. if (p.getBuildYear() == null || p.getBuildYear() == 0) {
  63. if (StringUtils.isNotBlank(cws.getCompDate())) {
  64. p.setBuildYear(NumberUtils.toLong(cws.getCompDate().split("-")[0]));
  65. }
  66. }
  67. if (p.getPlanSupplyScale() == null || p.getPlanSupplyScale() == 0) {
  68. if (cws.getDesWasuScal() != null) {
  69. p.setPlanSupplyScale(cws.getDesWasuScal().doubleValue());
  70. }
  71. }
  72. if (p.getPersonNum() == null || p.getPersonNum() == 0) {
  73. if (cws.getDesWasuPop() != null) {
  74. p.setPersonNum(NumberUtils.toLong(cws.getDesWasuPop() * 10000 + ""));
  75. }
  76. }
  77. }
  78. }
  79. bisInspVlgdrinkProjManageDao.insert(p);
  80. BisInspVillRgstr rp = new BisInspVillRgstr();
  81. rp.setEngId(p.getEngId());
  82. rp.setState("1");
  83. bisInspVillRgstrDao.update(rp);
  84. return uuid;
  85. }
  86. @Override
  87. public int modify(BisInspVlgdrinkProjManage p) throws Exception {
  88. String now = DateUtils.getTodayYMDHMS();
  89. p.setUpdateTime(now);
  90. AttCwsBase attCwsBase = attCwsBaseDao.get(p.getCwsCode());
  91. if (attCwsBase != null) {
  92. if (StringUtils.isBlank(p.getPjnm())) {
  93. p.setPjnm(attCwsBase.getCwsName());
  94. }
  95. if (StringUtils.isBlank(p.getVillageNm())) {
  96. p.setVillageNm(attCwsBase.getCwsLoc());
  97. }
  98. if (p.getBuildYear() == null || p.getBuildYear() == 0) {
  99. if (StringUtils.isNotBlank(attCwsBase.getCompDate())) {
  100. p.setBuildYear(NumberUtils.toLong(attCwsBase.getCompDate().split("-")[0]));
  101. }
  102. }
  103. if (p.getPlanSupplyScale() == null || p.getPlanSupplyScale() == 0) {
  104. if (attCwsBase.getDesWasuScal() != null) {
  105. p.setPlanSupplyScale(attCwsBase.getDesWasuScal().doubleValue());
  106. }
  107. }
  108. if (p.getPersonNum() == null || p.getPersonNum() == 0) {
  109. if (attCwsBase.getDesWasuPop() != null) {
  110. p.setPersonNum(NumberUtils.toLong(attCwsBase.getDesWasuPop() * 10000 + ""));
  111. }
  112. }
  113. }
  114. int ret = bisInspVlgdrinkProjManageDao.update(p);
  115. return ret;
  116. }
  117. @Override
  118. public PageInfo<BisInspVlgdrinkProjManage> queryListByPage(BisInspVlgdrinkProjManageParam p) throws Exception {
  119. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  120. List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.findList(p);
  121. return new PageInfo<BisInspVlgdrinkProjManage>(list);
  122. }
  123. @Override
  124. public List<BisInspVlgdrinkProjManage> queryList(BisInspVlgdrinkProjManageParam p) throws Exception {
  125. List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.findList(p);
  126. return list;
  127. }
  128. @Override
  129. public List<BisInspVlgdrinkProjManage> queryListByObjId(String objId, String name) throws Exception {
  130. List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.queryListByObjId(objId, name);
  131. return list;
  132. }
  133. @Override
  134. public List<BisInspVlgdrinkProjManage> getListByCodeAndPerId(VillRgstrDto villRgstrDto) {
  135. return this.bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto);
  136. }
  137. @Override
  138. public PageInfo<BisInspVlgdrinkProjManage> getPageByCodeAndPerId(VillRgstrDto villRgstrDto) {
  139. PageHelper.startPage(villRgstrDto.getPageNum(), villRgstrDto.getPageSize());
  140. List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto);
  141. return new PageInfo<BisInspVlgdrinkProjManage>(list);
  142. }
  143. @Override
  144. public PageInfo<BisInspVlgdrinkProjManageDcdxDto> getPageByNodeId(GetVillPageByNodeIdParam p) throws Exception {
  145. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  146. List<BisInspVlgdrinkProjManageDcdxDto> list = bisInspVlgdrinkProjManageDao.getPageByNodeId(p);
  147. return new PageInfo<BisInspVlgdrinkProjManageDcdxDto>(list);
  148. }
  149. }