CenterdataTRegulationsServiceImpl.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package com.ruoyi.system.service.impl;
  2. import com.ruoyi.common.core.utils.DateUtils;
  3. import com.ruoyi.common.core.utils.SpringUtils;
  4. import com.ruoyi.common.core.utils.StringUtils;
  5. import com.ruoyi.common.core.utils.uuid.IdUtils;
  6. import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
  7. import com.ruoyi.common.security.utils.SecurityUtils;
  8. import com.ruoyi.system.api.RemoteConfigService;
  9. import com.ruoyi.system.domain.CenterdataTAttach;
  10. import com.ruoyi.system.domain.CenterdataTRegulations;
  11. import com.ruoyi.system.mapper.CenterdataTRegulationsMapper;
  12. import com.ruoyi.system.service.ICenterdataTAttachService;
  13. import com.ruoyi.system.service.ICenterdataTRegulationsService;
  14. import com.ruoyi.system.utils.FileUtil;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import java.util.List;
  18. import static com.ruoyi.system.utils.DataConstants.DOWNLOAD_URL;
  19. /**
  20. * 政策法规Service业务层处理
  21. *
  22. * @author ruoyi
  23. * @date 2022-05-05
  24. */
  25. @Service
  26. public class CenterdataTRegulationsServiceImpl extends BaseServiceImpl implements ICenterdataTRegulationsService {
  27. @Autowired
  28. private CenterdataTRegulationsMapper centerdataTRegulationsMapper;
  29. @Autowired
  30. private ICenterdataTAttachService centerdataTAttachService;
  31. /**
  32. * 查询政策法规列表
  33. *
  34. * @param centerdataTRegulations 政策法规
  35. * @return 政策法规
  36. */
  37. @DataScopeMutiDept(deptAlias = "d")
  38. @Override
  39. public List<CenterdataTRegulations> selectCenterdataTRegulationsList(CenterdataTRegulations centerdataTRegulations) {
  40. setSookaDataBase(centerdataTRegulations);
  41. List<CenterdataTRegulations> list = centerdataTRegulationsMapper.selectCenterdataTRegulationsList(centerdataTRegulations);
  42. String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DOWNLOAD_URL).getData();
  43. for (CenterdataTRegulations tFile : list) {
  44. if (tFile.getFileUrl() != null) {
  45. StringBuilder newDiles = new StringBuilder();
  46. String url = tFile.getFileUrl();
  47. newDiles.append(fileurl + "Download?fileName=" + tFile.getFileName() + "&&group=" + url.substring(0, url.indexOf('/')) + "&&path=" + url.substring(url.indexOf('/') + 1));
  48. tFile.setFileUrl(newDiles.toString());
  49. }
  50. }
  51. return list;
  52. }
  53. /**
  54. * 查询政策法规
  55. *
  56. * @param id 政策法规主键
  57. * @return 政策法规
  58. */
  59. @Override
  60. public CenterdataTRegulations selectCenterdataTRegulationsById(String id) {
  61. CenterdataTRegulations centerdataTRegulations = centerdataTRegulationsMapper.selectCenterdataTRegulationsById(id);
  62. if (StringUtils.isNotEmpty(centerdataTRegulations.getFileUrl())) {
  63. String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DOWNLOAD_URL).getData();
  64. String[] files = centerdataTRegulations.getFileUrl().split(",");
  65. StringBuilder diles = new StringBuilder();
  66. for (String s : files) {
  67. String filename = s.substring(s.indexOf('+') + 1);
  68. String url = s.substring(0, s.indexOf('+'));
  69. String group = url.substring(0, url.indexOf('/'));
  70. diles.append(fileurl + "Download?fileName=" + filename + "&&group=" + group + "&&path=" + url.substring(url.indexOf('/') + 1) + "+" + filename + ",");
  71. }
  72. String newDiles = diles.toString().substring(0, diles.toString().length() - 1);
  73. centerdataTRegulations.setFileUrl(newDiles);
  74. }
  75. return centerdataTRegulations;
  76. }
  77. /**
  78. * 新增政策法规
  79. *
  80. * @param centerdataTRegulations 政策法规
  81. * @return 结果
  82. */
  83. @Override
  84. public int insertCenterdataTRegulations(CenterdataTRegulations centerdataTRegulations) {
  85. String bussource = "PC";
  86. String busindx = "zcfg";
  87. if(StringUtils.isNotEmpty(centerdataTRegulations.getFileUrlList())){
  88. String attachId = IdUtils.fastSimpleUUID();
  89. centerdataTRegulations.setAttachId(attachId);
  90. List<CenterdataTAttach> list = FileUtil.documentProcessing(centerdataTRegulations.getId(), attachId, centerdataTRegulations.getFileUrlList(), centerdataTRegulations.getFileNameList(), bussource, busindx);
  91. if (StringUtils.isNotEmpty(list)) {
  92. centerdataTAttachService.insertListCenterdataTAttach(list);
  93. }
  94. }
  95. centerdataTRegulations.setId(IdUtils.simpleUUID());
  96. centerdataTRegulations.setCreateBy(SecurityUtils.getUserId().toString());
  97. centerdataTRegulations.setCreateTime(DateUtils.getNowDate());
  98. centerdataTRegulations.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
  99. return centerdataTRegulationsMapper.insertCenterdataTRegulations(centerdataTRegulations);
  100. }
  101. /**
  102. * 修改政策法规
  103. *
  104. * @param centerdataTRegulations 政策法规
  105. * @return 结果
  106. */
  107. @Override
  108. public int updateCenterdataTRegulations(CenterdataTRegulations centerdataTRegulations) {
  109. centerdataTRegulations.setUpdateBy(SecurityUtils.getUserId());
  110. centerdataTRegulations.setUpdateTime(DateUtils.getNowDate());
  111. centerdataTRegulations.setUpdateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
  112. String bussource = "PC";
  113. String busindx = "zcfg";
  114. if (StringUtils.isNotEmpty(centerdataTRegulations.getFileUrl())) {
  115. centerdataTAttachService.deleteCenterdataTAttachByBusId(centerdataTRegulations.getAttachId());
  116. String attachId = IdUtils.fastSimpleUUID();
  117. centerdataTRegulations.setAttachId(attachId);
  118. List<CenterdataTAttach> list = FileUtil.documentProcessing(centerdataTRegulations.getId(), attachId, centerdataTRegulations.getFileUrlList(), centerdataTRegulations.getFileNameList(), bussource, busindx);
  119. if (StringUtils.isNotEmpty(list)) {
  120. centerdataTAttachService.insertListCenterdataTAttach(list);
  121. }
  122. } else if (StringUtils.isNotEmpty(centerdataTRegulations.getAttachId())) {
  123. centerdataTAttachService.deleteCenterdataTAttachByBusId(centerdataTRegulations.getAttachId());
  124. centerdataTRegulations.setAttachId("");
  125. }
  126. return centerdataTRegulationsMapper.updateCenterdataTRegulations(centerdataTRegulations);
  127. }
  128. /**
  129. * 批量删除政策法规
  130. *
  131. * @param ids 需要删除的政策法规主键
  132. * @return 结果
  133. */
  134. @Override
  135. public int deleteCenterdataTRegulationsByIds(String[] ids) {
  136. return centerdataTRegulationsMapper.deleteCenterdataTRegulationsByIds(ids);
  137. }
  138. @Override
  139. public int handlePublish(CenterdataTRegulations centerdataTRegulations) {
  140. return centerdataTRegulationsMapper.handlePublish(centerdataTRegulations);
  141. }
  142. }