123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package com.ruoyi.system.service.impl;
- import com.ruoyi.common.core.utils.DateUtils;
- import com.ruoyi.common.core.utils.SpringUtils;
- import com.ruoyi.common.core.utils.StringUtils;
- import com.ruoyi.common.core.utils.uuid.IdUtils;
- import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
- import com.ruoyi.common.security.utils.SecurityUtils;
- import com.ruoyi.system.api.RemoteConfigService;
- import com.ruoyi.system.domain.CenterdataTAttach;
- import com.ruoyi.system.domain.CenterdataTRegulations;
- import com.ruoyi.system.mapper.CenterdataTRegulationsMapper;
- import com.ruoyi.system.service.ICenterdataTAttachService;
- import com.ruoyi.system.service.ICenterdataTRegulationsService;
- import com.ruoyi.system.utils.FileUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.List;
- import static com.ruoyi.system.utils.DataConstants.DOWNLOAD_URL;
- /**
- * 政策法规Service业务层处理
- *
- * @author ruoyi
- * @date 2022-05-05
- */
- @Service
- public class CenterdataTRegulationsServiceImpl extends BaseServiceImpl implements ICenterdataTRegulationsService {
- @Autowired
- private CenterdataTRegulationsMapper centerdataTRegulationsMapper;
- @Autowired
- private ICenterdataTAttachService centerdataTAttachService;
- /**
- * 查询政策法规列表
- *
- * @param centerdataTRegulations 政策法规
- * @return 政策法规
- */
- @DataScopeMutiDept(deptAlias = "d")
- @Override
- public List<CenterdataTRegulations> selectCenterdataTRegulationsList(CenterdataTRegulations centerdataTRegulations) {
- setSookaDataBase(centerdataTRegulations);
- List<CenterdataTRegulations> list = centerdataTRegulationsMapper.selectCenterdataTRegulationsList(centerdataTRegulations);
- String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DOWNLOAD_URL).getData();
- for (CenterdataTRegulations tFile : list) {
- if (tFile.getFileUrl() != null) {
- StringBuilder newDiles = new StringBuilder();
- String url = tFile.getFileUrl();
- newDiles.append(fileurl + "Download?fileName=" + tFile.getFileName() + "&&group=" + url.substring(0, url.indexOf('/')) + "&&path=" + url.substring(url.indexOf('/') + 1));
- tFile.setFileUrl(newDiles.toString());
- }
- }
- return list;
- }
- /**
- * 查询政策法规
- *
- * @param id 政策法规主键
- * @return 政策法规
- */
- @Override
- public CenterdataTRegulations selectCenterdataTRegulationsById(String id) {
- CenterdataTRegulations centerdataTRegulations = centerdataTRegulationsMapper.selectCenterdataTRegulationsById(id);
- if (StringUtils.isNotEmpty(centerdataTRegulations.getFileUrl())) {
- String fileurl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(DOWNLOAD_URL).getData();
- String[] files = centerdataTRegulations.getFileUrl().split(",");
- StringBuilder diles = new StringBuilder();
- for (String s : files) {
- String filename = s.substring(s.indexOf('+') + 1);
- String url = s.substring(0, s.indexOf('+'));
- String group = url.substring(0, url.indexOf('/'));
- diles.append(fileurl + "Download?fileName=" + filename + "&&group=" + group + "&&path=" + url.substring(url.indexOf('/') + 1) + "+" + filename + ",");
- }
- String newDiles = diles.toString().substring(0, diles.toString().length() - 1);
- centerdataTRegulations.setFileUrl(newDiles);
- }
- return centerdataTRegulations;
- }
- /**
- * 新增政策法规
- *
- * @param centerdataTRegulations 政策法规
- * @return 结果
- */
- @Override
- public int insertCenterdataTRegulations(CenterdataTRegulations centerdataTRegulations) {
- String bussource = "PC";
- String busindx = "zcfg";
- if(StringUtils.isNotEmpty(centerdataTRegulations.getFileUrlList())){
- String attachId = IdUtils.fastSimpleUUID();
- centerdataTRegulations.setAttachId(attachId);
- List<CenterdataTAttach> list = FileUtil.documentProcessing(centerdataTRegulations.getId(), attachId, centerdataTRegulations.getFileUrlList(), centerdataTRegulations.getFileNameList(), bussource, busindx);
- if (StringUtils.isNotEmpty(list)) {
- centerdataTAttachService.insertListCenterdataTAttach(list);
- }
- }
- centerdataTRegulations.setId(IdUtils.simpleUUID());
- centerdataTRegulations.setCreateBy(SecurityUtils.getUserId().toString());
- centerdataTRegulations.setCreateTime(DateUtils.getNowDate());
- centerdataTRegulations.setCreateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
- return centerdataTRegulationsMapper.insertCenterdataTRegulations(centerdataTRegulations);
- }
- /**
- * 修改政策法规
- *
- * @param centerdataTRegulations 政策法规
- * @return 结果
- */
- @Override
- public int updateCenterdataTRegulations(CenterdataTRegulations centerdataTRegulations) {
- centerdataTRegulations.setUpdateBy(SecurityUtils.getUserId());
- centerdataTRegulations.setUpdateTime(DateUtils.getNowDate());
- centerdataTRegulations.setUpdateName(SecurityUtils.getLoginUser().getSysUser().getNickName());
- String bussource = "PC";
- String busindx = "zcfg";
- if (StringUtils.isNotEmpty(centerdataTRegulations.getFileUrl())) {
- centerdataTAttachService.deleteCenterdataTAttachByBusId(centerdataTRegulations.getAttachId());
- String attachId = IdUtils.fastSimpleUUID();
- centerdataTRegulations.setAttachId(attachId);
- List<CenterdataTAttach> list = FileUtil.documentProcessing(centerdataTRegulations.getId(), attachId, centerdataTRegulations.getFileUrlList(), centerdataTRegulations.getFileNameList(), bussource, busindx);
- if (StringUtils.isNotEmpty(list)) {
- centerdataTAttachService.insertListCenterdataTAttach(list);
- }
- } else if (StringUtils.isNotEmpty(centerdataTRegulations.getAttachId())) {
- centerdataTAttachService.deleteCenterdataTAttachByBusId(centerdataTRegulations.getAttachId());
- centerdataTRegulations.setAttachId("");
- }
- return centerdataTRegulationsMapper.updateCenterdataTRegulations(centerdataTRegulations);
- }
- /**
- * 批量删除政策法规
- *
- * @param ids 需要删除的政策法规主键
- * @return 结果
- */
- @Override
- public int deleteCenterdataTRegulationsByIds(String[] ids) {
- return centerdataTRegulationsMapper.deleteCenterdataTRegulationsByIds(ids);
- }
- @Override
- public int handlePublish(CenterdataTRegulations centerdataTRegulations) {
- return centerdataTRegulationsMapper.handlePublish(centerdataTRegulations);
- }
- }
|