对比新文件 |
| | |
| | | package com.gk.firework.Service.ServiceImpl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gk.firework.Domain.EnterpriseDocument; |
| | | import com.gk.firework.Domain.EnterpriseResource; |
| | | import com.gk.firework.Domain.Enum.DocumentType; |
| | | import com.gk.firework.Domain.Exception.BusinessException; |
| | | import com.gk.firework.Domain.UserInfo; |
| | | import com.gk.firework.Domain.Utils.Constants; |
| | | import com.gk.firework.Domain.Utils.Properties; |
| | | import com.gk.firework.Domain.Utils.StringUtils; |
| | | import com.gk.firework.Domain.Utils.UploadUtil; |
| | | import com.gk.firework.Domain.Vo.EnterpriseDocumentVo; |
| | | import com.gk.firework.Mapper.EnterpriseDocumentMapper; |
| | | import com.gk.firework.Mapper.EnterpriseResourceMapper; |
| | | import com.gk.firework.Service.EnterpriseDocumentService; |
| | | import com.gk.firework.Service.EnterpriseResourceService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Service("enterpriseDocumentService") |
| | | public class EnterpriseDocumentServiceImpl extends ServiceImpl<EnterpriseDocumentMapper, EnterpriseDocument> implements EnterpriseDocumentService { |
| | | |
| | | @Autowired |
| | | private EnterpriseDocumentMapper enterpriseDocumentMapper; |
| | | @Autowired |
| | | private EnterpriseResourceService enterpriseResourceService; |
| | | |
| | | |
| | | /** |
| | | * @Description: 分页查询 |
| | | * @date 2021/3/26 19:41 |
| | | */ |
| | | @Override |
| | | public IPage selectPage(Page<EnterpriseDocument> page, Long id, DocumentType type) { |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("id", id); |
| | | params.put("type", type); |
| | | params.put("tabletype", Constants.DOCUMENT); |
| | | List<EnterpriseDocument> list = enterpriseDocumentMapper.selectPages(page, params); |
| | | return page.setRecords(list); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 新增 |
| | | * @date 2021/3/26 19:41 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void addDocument(EnterpriseDocumentVo enterpriseDocumentVo, UserInfo user) throws Exception { |
| | | |
| | | //新增信息 |
| | | EnterpriseDocument document = new EnterpriseDocument(); |
| | | document.setName(enterpriseDocumentVo.getName()); |
| | | document.setSettime(enterpriseDocumentVo.getSettime()); |
| | | document.setCreateby(user.getId()); |
| | | document.setCreatebyname(user.getUsername()); |
| | | document.setCreatetime(new Date()); |
| | | document.setValidflag(true); |
| | | document.setMemo(enterpriseDocumentVo.getMemo()); |
| | | document.setType(enterpriseDocumentVo.getType()); |
| | | document.setEnterpriseid(enterpriseDocumentVo.getEnterpriseid()); |
| | | this.save(document); |
| | | |
| | | //新建资源 |
| | | List<EnterpriseResource> adds = null; |
| | | if (enterpriseDocumentVo.getFile() != null && enterpriseDocumentVo.getFile().length > 0) { |
| | | adds = new ArrayList<>(); |
| | | Date now = new Date(); |
| | | for (MultipartFile file : enterpriseDocumentVo.getFile()) { |
| | | String name = UploadUtil.uploadFile(file, Properties.enterprisePath); |
| | | EnterpriseResource er = new EnterpriseResource(); |
| | | er.setTabletype(Constants.DOCUMENT); |
| | | er.setFilename(file.getOriginalFilename()); |
| | | er.setUrl(Properties.enterprise + name); |
| | | er.setCreatetime(now); |
| | | er.setCreateby(user.getId()); |
| | | er.setCreatebyname(user.getUsername()); |
| | | er.setBelongid(document.getId()); |
| | | er.setValidflag(true); |
| | | adds.add(er); |
| | | } |
| | | //执行 |
| | | enterpriseResourceService.saveBatch(adds); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @Description: 修改 |
| | | * @date 2021/3/26 19:51 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void modDocument(EnterpriseDocumentVo enterpriseDocumentVo, UserInfo user) throws Exception { |
| | | |
| | | //修改信息 |
| | | EnterpriseDocument document = new EnterpriseDocument(); |
| | | document.setId(enterpriseDocumentVo.getId()); |
| | | document.setName(enterpriseDocumentVo.getName()); |
| | | document.setSettime(enterpriseDocumentVo.getSettime()); |
| | | document.setUpdateby(user.getId()); |
| | | document.setUpdatebyname(user.getUsername()); |
| | | document.setUpdatetime(new Date()); |
| | | document.setValidflag(true); |
| | | document.setMemo(enterpriseDocumentVo.getMemo()); |
| | | document.setType(enterpriseDocumentVo.getType()); |
| | | document.setEnterpriseid(enterpriseDocumentVo.getEnterpriseid()); |
| | | this.updateById(document); |
| | | |
| | | //删除资源 |
| | | List<Long> ids = enterpriseDocumentVo.getIds(); |
| | | |
| | | List<EnterpriseResource> dels = null; |
| | | if (ids != null && ids.size() > 0) { |
| | | dels = new ArrayList<>(); |
| | | Date now = new Date(); |
| | | for (Long id:ids) { |
| | | EnterpriseResource er = new EnterpriseResource(); |
| | | er.setId(id); |
| | | er.setValidflag(false); |
| | | er.setUpdateby(user.getId()); |
| | | er.setUpdatebyname(user.getUsername()); |
| | | er.setUpdatetime(now); |
| | | dels.add(er); |
| | | } |
| | | //删除 |
| | | enterpriseResourceService.updateBatchById(dels); |
| | | } |
| | | |
| | | //2.新增 |
| | | List<EnterpriseResource> adds = null; |
| | | if (enterpriseDocumentVo.getFile() !=null && enterpriseDocumentVo.getFile().length > 0) { |
| | | adds = new ArrayList<>(); |
| | | Date now = new Date(); |
| | | for (MultipartFile file : enterpriseDocumentVo.getFile()) { |
| | | String name = UploadUtil.uploadFile(file, Properties.enterprisePath); |
| | | EnterpriseResource er = new EnterpriseResource(); |
| | | er.setTabletype(Constants.DOCUMENT); |
| | | er.setFilename(file.getOriginalFilename()); |
| | | er.setUrl(Properties.enterprise + name); |
| | | er.setCreatetime(now); |
| | | er.setCreateby(user.getId()); |
| | | er.setCreatebyname(user.getUsername()); |
| | | er.setBelongid(enterpriseDocumentVo.getId()); |
| | | er.setValidflag(true); |
| | | adds.add(er); |
| | | } |
| | | //执行 |
| | | enterpriseResourceService.saveBatch(adds); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void delDocument(Long id, UserInfo user) { |
| | | EnterpriseDocument document = new EnterpriseDocument(); |
| | | document.setId(id); |
| | | document.setUpdatetime(new Date()); |
| | | document.setCreateby(user.getId()); |
| | | document.setCreatebyname(user.getUsername()); |
| | | document.setValidflag(false); |
| | | this.updateById(document); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 救援|流向信息管理 校验 |
| | | * @date 2021/4/6 15:58 |
| | | */ |
| | | @Override |
| | | public void checkDocument(EnterpriseDocumentVo enterpriseDocumentVo,boolean flag) { |
| | | |
| | | if (StringUtils.isBlank(enterpriseDocumentVo.getName())) { |
| | | throw new BusinessException("制度名称不能为空"); |
| | | } |
| | | |
| | | if (enterpriseDocumentVo.getSettime() == null) { |
| | | throw new BusinessException("制订日期不能为空"); |
| | | } |
| | | |
| | | if (enterpriseDocumentVo.getMemo() == null) { |
| | | throw new BusinessException("内容不能为空"); |
| | | } |
| | | //新增必须上传文件 |
| | | if (flag && enterpriseDocumentVo.getFile() == null) { |
| | | throw new BusinessException("上传文件不能为空"); |
| | | } |
| | | } |
| | | } |