|
@@ -0,0 +1,337 @@
|
|
|
|
+package com.jeeplus.business.useSeal.service;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.jeeplus.business.project.domain.JyProject;
|
|
|
|
+import com.jeeplus.business.project.mapper.JyProjectMapper;
|
|
|
|
+import com.jeeplus.business.project.service.dto.JyProjectDTO;
|
|
|
|
+import com.jeeplus.common.TokenProvider;
|
|
|
|
+import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
|
+import com.jeeplus.pubmodules.oss.domain.WorkAttachment;
|
|
|
|
+import com.jeeplus.pubmodules.oss.service.dto.WorkAttachmentDto;
|
|
|
|
+import com.jeeplus.pubmodules.serialNumTpl.service.SerialnumTplService;
|
|
|
|
+import com.jeeplus.business.useSeal.domain.Signet;
|
|
|
|
+import com.jeeplus.business.useSeal.mapper.SignetMapper;
|
|
|
|
+import com.jeeplus.business.useSeal.service.dto.SignetDTO;
|
|
|
|
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
|
|
|
|
+import com.jeeplus.sys.feign.IUserApi;
|
|
|
|
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
|
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
|
+import com.jeeplus.utils.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@Transactional
|
|
|
|
+public class SignetService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SignetMapper signetMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SerialnumTplService serialnumTplService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private JyProjectMapper jyProjectMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 列表查询
|
|
|
|
+ * @param signetDTOPage
|
|
|
|
+ * @param dto
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public IPage<SignetDTO> findList(Page<SignetDTO> signetDTOPage, SignetDTO dto) throws Exception {
|
|
|
|
+ QueryWrapper<SignetDTO> queryWrapper = QueryWrapperGenerator.buildQueryCondition(dto, SignetDTO.class);
|
|
|
|
+ queryWrapper.eq("a.del_flag",0);
|
|
|
|
+ //关联项目
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getProjectName())){
|
|
|
|
+ queryWrapper.like("a.project_name",dto.getProjectName());
|
|
|
|
+ }
|
|
|
|
+ //用印类型
|
|
|
|
+ if (null != dto.getTypes() && dto.getTypes().size()>0){
|
|
|
|
+ if (dto.getTypes().size() ==1){
|
|
|
|
+ queryWrapper.eq("a.first_type",dto.getTypes().get(0));
|
|
|
|
+ }else {
|
|
|
|
+ queryWrapper.eq("a.type",dto.getTypes().get(1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //申请人
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getCreateById())){
|
|
|
|
+ queryWrapper.eq("a.create_by_id", dto.getCreateById());
|
|
|
|
+ }
|
|
|
|
+ //创建时间
|
|
|
|
+ if (dto.getCreateDates() != null && dto.getCreateDates().length > 0) {
|
|
|
|
+ queryWrapper.between("a.create_time", dto.getCreateDates()[0], dto.getCreateDates()[1]);
|
|
|
|
+ }
|
|
|
|
+ //申请人部门
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getOffice())){
|
|
|
|
+ queryWrapper.eq("so.id",dto.getOffice());
|
|
|
|
+ }
|
|
|
|
+ IPage<SignetDTO> signetList=signetMapper.findPageList(signetDTOPage,queryWrapper);
|
|
|
|
+ signetList.getRecords().stream().forEach(item->{
|
|
|
|
+ if (StringUtils.isNotBlank(item.getProjectName())){
|
|
|
|
+ String project=item.getProjectName().substring(0,item.getProjectName().lastIndexOf(","));
|
|
|
|
+ item.setProjectName(project);
|
|
|
|
+ }
|
|
|
|
+ //用印类型
|
|
|
|
+ if (StringUtils.isNotBlank(item.getType())){
|
|
|
|
+ item.setType("项目-"+item.getType());
|
|
|
|
+ }else {
|
|
|
|
+ item.setType(item.getFirstType());
|
|
|
|
+ }
|
|
|
|
+ //关联项目
|
|
|
|
+ if (StringUtils.isNotBlank(item.getProjectId())){
|
|
|
|
+ String[] split = item.getProjectId().split(",");
|
|
|
|
+ ArrayList<JyProject> jyProjects = new ArrayList<>();
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ JyProject byId = jyProjectMapper.getById(s);
|
|
|
|
+ jyProjects.add(byId);
|
|
|
|
+ }
|
|
|
|
+ item.setProjectList(jyProjects);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return signetList;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String save(SignetDTO dto) throws Exception{
|
|
|
|
+ // 获取当前登录人信息
|
|
|
|
+// UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
|
+ UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken (TokenProvider.getCurrentToken ( ));
|
|
|
|
+ if (StringUtils.isNotEmpty(dto.getId())) {
|
|
|
|
+ return update(dto, userDTO);
|
|
|
|
+ } else {
|
|
|
|
+ return add(dto, userDTO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public synchronized String add(SignetDTO dto, UserDTO userDTO) throws Exception{
|
|
|
|
+ // 生成id
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
+ // 生成编号
|
|
|
|
+ String no = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), dto.BIZ_CODE,TokenProvider.getCurrentToken());
|
|
|
|
+ // 保存基础信息表信息
|
|
|
|
+ Signet signet = new Signet();
|
|
|
|
+ BeanUtils.copyProperties(dto, signet);
|
|
|
|
+ signet.setId(id);
|
|
|
|
+ signet.setNo(no);
|
|
|
|
+ signet.setCreateById(userDTO.getId());
|
|
|
|
+ signet.setCreateTime(new Date());
|
|
|
|
+ signet.setUpdateById(userDTO.getId());
|
|
|
|
+ signet.setUpdateTime(new Date());
|
|
|
|
+ signet.setDelFlag(0);
|
|
|
|
+ //保存关联项目信息
|
|
|
|
+ String projectId="";
|
|
|
|
+ String projectName="";
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getProjectList())){
|
|
|
|
+ for (JyProject jyProject : dto.getProjectList()) {
|
|
|
|
+ projectId+=jyProject.getProjectId()+",";
|
|
|
|
+ projectName+=jyProject.getName()+",";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ signet.setProjectId(projectId);
|
|
|
|
+ signet.setProjectName(projectName);
|
|
|
|
+ //保存用印类型
|
|
|
|
+ if (null != dto.getTypes()&&dto.getTypes().size()>0){
|
|
|
|
+ if (dto.getTypes().size()==1){
|
|
|
|
+ signet.setFirstType(dto.getTypes().get(0));
|
|
|
|
+ }else {
|
|
|
|
+ signet.setFirstType(dto.getTypes().get(0));
|
|
|
|
+ signet.setType(dto.getTypes().get(1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ signet.setRemarks(dto.getRemarks());//说明
|
|
|
|
+ signet.setStatus(dto.getStatus());//状态
|
|
|
|
+ signet.setNumber(dto.getNumber()); //份数
|
|
|
|
+ signetMapper.insert(signet);
|
|
|
|
+ // 保存附件列表信息
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getFiles())) {
|
|
|
|
+ saveFiles(dto.getFiles(), userDTO, id);
|
|
|
|
+ }
|
|
|
|
+ return id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String update(SignetDTO dto, UserDTO userDTO) {
|
|
|
|
+ Signet signet = new Signet();
|
|
|
|
+ BeanUtils.copyProperties(dto, signet);
|
|
|
|
+ signet.setUpdateTime(new Date());
|
|
|
|
+ //保存关联项目信息
|
|
|
|
+ String projectId="";
|
|
|
|
+ String projectName="";
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getProjectList())){
|
|
|
|
+ for (JyProject jyProject : dto.getProjectList()) {
|
|
|
|
+ projectId=jyProject.getId()+",";
|
|
|
|
+ projectName=jyProject.getName()+",";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ signet.setProjectId(projectId);
|
|
|
|
+ signet.setProjectName(projectName);
|
|
|
|
+ //保存用印类型
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getTypes())){
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getTypes().get(1))){
|
|
|
|
+ signet.setType(dto.getTypes().get(1));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getTypes().get(0))){
|
|
|
|
+ signet.setFirstType(dto.getTypes().get(0));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ signet.setRemarks(dto.getRemarks());//说明
|
|
|
|
+ signet.setStatus(dto.getStatus());//状态
|
|
|
|
+ signet.setNumber(dto.getNumber()); //份数
|
|
|
|
+ signetMapper.updateById(signet);
|
|
|
|
+ return dto.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存附件信息
|
|
|
|
+ * @param list 待保存的附件列表
|
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
|
+ * @param id 关联id
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void saveFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
|
|
|
|
+ int j = 1;
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
|
+ //包含了url、size、name
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
|
+ i.setCreateTime(new Date());
|
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
|
+ i.setDelFlag(0);
|
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
|
+ //文件类型处理
|
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
|
+ i.setType(strings.get(1));
|
|
|
|
+ }
|
|
|
|
+ i.setAttachmentId(id);
|
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
|
+ i.setAttachmentFlag("jySeal");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改附件信息
|
|
|
|
+ * @param list 待修改的附件列表
|
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
|
+ * @param id 关联id
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void updateFiles(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
|
|
|
|
+ int j = 1;
|
|
|
|
+ String names = new String();
|
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
|
+ }
|
|
|
|
+ //查询保存的附件信息
|
|
|
|
+ List<WorkAttachmentInfo> infoList = signetMapper.findFileList(id);
|
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(infoList)) {
|
|
|
|
+ for (WorkAttachmentInfo i : infoList) {
|
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
|
+// ossServiceMapper.deleteById(i.getId());
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteById(i.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //保存信息
|
|
|
|
+ for (WorkAttachmentDto dto : list) {
|
|
|
|
+ //判断是否存在
|
|
|
|
+ Integer isExit = signetMapper.findIsExit(id, dto.getName());
|
|
|
|
+ if (isExit == 0) {
|
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
|
+ //包含了url、size、name
|
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
|
+ i.setCreateTime(new Date());
|
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
|
+ i.setDelFlag(0);
|
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
|
+ //文件类型处理
|
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
|
+ i.setType(strings.get(1));
|
|
|
|
+ }
|
|
|
|
+ i.setAttachmentId(id);
|
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
|
+ i.setAttachmentFlag("jySeal");
|
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
|
+ i.setSort(j);
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
|
+ j++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id查询用印
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public SignetDTO findById(String id) {
|
|
|
|
+ SignetDTO signetDTO = new SignetDTO();
|
|
|
|
+ SignetDTO dto = signetMapper.findById(id);
|
|
|
|
+ BeanUtils.copyProperties(dto, signetDTO);
|
|
|
|
+ //查询项目信息
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getProjectId())){
|
|
|
|
+ String[] split = dto.getProjectId().split(",");
|
|
|
|
+ ArrayList<JyProject> signetDTOS = new ArrayList<>();
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ JyProject jyProject=jyProjectMapper.getById(s);
|
|
|
|
+ signetDTOS.add(jyProject);
|
|
|
|
+ }
|
|
|
|
+ signetDTO.setProjectList(signetDTOS);
|
|
|
|
+ }
|
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getType())){
|
|
|
|
+ stringList.add(dto.getFirstType());
|
|
|
|
+ stringList.add(dto.getType());
|
|
|
|
+ }else {
|
|
|
|
+ stringList.add(dto.getFirstType());
|
|
|
|
+ }
|
|
|
|
+ signetDTO.setTypes(stringList);
|
|
|
|
+ signetDTO.setCreateById(dto.getCreateById());
|
|
|
|
+ return signetDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id修改状态
|
|
|
|
+ * @param id
|
|
|
|
+ * @param status
|
|
|
|
+ */
|
|
|
|
+ public void updateStatusById(String id,String status) {
|
|
|
|
+ signetMapper.updateStatusById(id,status);
|
|
|
|
+ }
|
|
|
|
+}
|