| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.DocInfoMapper; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | |
| | | |
| | | import org.jeecg.modules.dnc.request.DocInfoQueryRequest; |
| | | import org.jeecg.modules.dnc.request.DocInfoUploadRequest; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.response.*; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.CamelToSnakeRegex; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.service.IDispatchFileService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class DocInfoServiceImpl extends ServiceImpl<DocInfoMapper, DocInfo> implements IDocInfoService { |
| | |
| | | @Autowired |
| | | private IDeviceGroupService deviceGroupService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | private IDispatchFileService dispatchFileService; |
| | | |
| | | /*备份处理*/ |
| | | @Override |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("导入"+docClass.getClassificationName()+",文档名称:"+(docFile.getFileName()+"."+docFile.getFileSuffix())); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean saveBool = super.save(docInfo); |
| | | if (uploadRequest.getIsApprove()&&saveBool){ |
| | | //触发审签 |
| | | DispatchFile dispatchFile = new DispatchFile(); |
| | | dispatchFile.setDocId(docInfo.getDocId()); |
| | | dispatchFile.setFileId(docFile.getFileId()); |
| | | dispatchFile.setAttributionId(uploadRequest.getAttributionId()); |
| | | dispatchFile.setAttributionType(String.valueOf(uploadRequest.getAttributionType())); |
| | | dispatchFile.setDocClassCode(uploadRequest.getDocClassCode()); |
| | | dispatchFileService.saveDispatchFile(dispatchFile); |
| | | } |
| | | return saveBool; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | } |
| | | String recF = pathFile.substring(0,recNum);//将返回def}ab |
| | | Integer equipmentId = recF.lastIndexOf("\\"); |
| | | String deviceNo = recF.substring(equipmentId+1,recF.length()); |
| | | String deviceNo = recF.substring(equipmentId+1); |
| | | if (StringUtils.isEmpty(deviceNo)) { |
| | | return false; |
| | | } |
| | |
| | | docInfo.setClassificationId(null); |
| | | docInfo.setPublishFileId(null); |
| | | docInfo.setPublishVersion(null); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(3); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("文档名称:"+docInfo.getDocName()); |
| | | //修改保存备注 |
| | | ncLogInfo.setRemark(JSONObject.toJSONString(en)); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.updateById(docInfo); |
| | | } |
| | | |
| | |
| | | b = docRelativeService.deleteByDocId(id); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(4); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("文档名称:"+en.getDocName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.removeById(id); |
| | | } |
| | | |
| | |
| | | DocInfo en = super.getById(id); |
| | | if(en == null) |
| | | ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); |
| | | List<DeviceInfo> deviceList = docRelativeService.findDeviceByDocId(en.getDocId()); |
| | | List<MdcEquipment> deviceList = docRelativeService.findDeviceByDocId(en.getDocId()); |
| | | if(deviceList != null && !deviceList.isEmpty()) |
| | | ExceptionCast.cast(DocumentCode.DOC_DEVICE_EXIST); |
| | | String suffix = FileUtilS.getFileSuffix(file.getOriginalFilename()); |
| | |
| | | docFile.setFilePath(fileUploadResult.getFilePath()); |
| | | docFile.setFileSize(fileUploadResult.getFileSize()); |
| | | docFile.setFileSuffix(fileUploadResult.getFileSuffix()); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("入库"+docFile.getFileSuffix()+"格式文档,文档名称:"+docFile.getFileName()); |
| | | ncLogInfo.setRemark(JSONObject.toJSONString(en)); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean b = fileOperateService.deleteByDocId(id); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | |
| | | DocFile old = docFileService.getDocFileNearest(en.getDocId()); |
| | | if(old == null) |
| | | ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("发布"+en.getDocSuffix()+"格式文档,文档名称:"+en.getDocName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | if(old.getDocVersion().contains(".")) { |
| | | DocFile docFile = new DocFile(); |
| | | BeanUtils.copyProperties(pubFile, docFile); |
| | |
| | | ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); |
| | | if(en.getDocStatus() != 2) |
| | | ExceptionCast.cast(DocumentCode.DOC_REPUBLISH_ERROR); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("重新发布"+en.getDocSuffix()+"格式文档,文档名称:"+en.getDocName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 1).update(); |
| | | } |
| | | |
| | |
| | | FileOperate operate = fileOperateService.getByDocId(id); |
| | | if(operate != null) |
| | | ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("归档"+en.getDocSuffix()+"格式文档,文档名称:"+en.getDocName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 3).update(); |
| | | } |
| | | |
| | |
| | | DocInfo en = super.getById(id); |
| | | if(en == null) |
| | | ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("取消出库"+en.getDocSuffix()+"格式文档,文档名称:"+en.getDocName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return fileOperateService.deleteByDocId(id); |
| | | } |
| | | |
| | |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]); |
| | | } |
| | | } |
| | | queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime()); |
| | | queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime()); |
| | | queryWrapper.orderByDesc("u.create_time"); |
| | | getDocQuery(docQuery, queryWrapper); |
| | | IPage<DocInfo> docInfoIPage = super.getBaseMapper().findDocExtList(pageData, queryWrapper); |
| | | return Result.ok(docInfoIPage); |
| | | } |
| | | |
| | | private void getDocQuery(DocInfoQueryRequest docQuery, QueryWrapper<DocInfo> queryWrapper) { |
| | | if (docQuery.getDocStatus() != null && docQuery.getDocStatus().contains(",")) { |
| | | String[] docStatusArray = docQuery.getDocStatus().split(","); |
| | | List<Integer> docStatusList = Arrays.stream(docStatusArray).map(Integer::parseInt).collect(Collectors.toList()); |
| | | queryWrapper.in("u.doc_status",docStatusList); |
| | | }else { |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocStatus()),"u.doc_status",docQuery.getDocStatus()); |
| | | } |
| | | if (docQuery.getDocDispatchStatus() != null && docQuery.getDocDispatchStatus().contains(",")) { |
| | | String[] docDispatchStatusArray = docQuery.getDocDispatchStatus().split(","); |
| | | List<Integer> docDispatchStatusList = Arrays.stream(docDispatchStatusArray).map(Integer::parseInt).collect(Collectors.toList()); |
| | | queryWrapper.in("u.doc_dispatch_status",docDispatchStatusList); |
| | | }else { |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocDispatchStatus()),"u.doc_dispatch_status",docQuery.getDocDispatchStatus()); |
| | | } |
| | | if (StrUtil.isNotEmpty(docQuery.getPullStatus())){ |
| | | if (("1").equals(docQuery.getPullStatus())){ |
| | | queryWrapper.isNull("o.doc_id"); |
| | | }else if (("2").equals(docQuery.getPullStatus())){ |
| | | queryWrapper.isNotNull("o.doc_id"); |
| | | } |
| | | } |
| | | queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"u.create_time",docQuery.getStartTime()+" 00:00:00"); |
| | | queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"u.create_time",docQuery.getEndTime()+" 23:59:59"); |
| | | if (StrUtil.isNotEmpty(docQuery.getColumn())){ |
| | | if (("desc").equals(docQuery.getOrder())){ |
| | | queryWrapper.orderByDesc("u."+ CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); |
| | | }else { |
| | | queryWrapper.orderByAsc("u."+CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | public boolean deleteByProcessId(String processId) { |
| | | if(!ValidateUtil.validateString(processId)) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | Integer attrType = 4; |
| | | Integer attrType = 5; |
| | | boolean b = docFileService.deleteByDocAttr(attrType, processId); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | |
| | | return docRelativeService.deleteByDocAttr(attrType, processId); |
| | | } |
| | | |
| | | /** |
| | | * 删除工步下的所有文档 |
| | | * @param stepId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean deleteByStepId(String stepId){ |
| | | if(!ValidateUtil.validateString(stepId)) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | Integer attrType = 6; |
| | | boolean b = docFileService.deleteByDocAttr(attrType, stepId); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = deleteByDocAttr(attrType, stepId); |
| | | if(!b) { |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | return docRelativeService.deleteByDocAttr(attrType, stepId); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean deleteByDocAttr(Integer attrType, String attrId) { |
| | | int i = super.getBaseMapper().deleteByDocAttr(attrType, attrId); |
| | | if(i >= 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | return i >= 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | String filePath = docFile.getFilePath(); |
| | | String fileEncodeName = docFile.getFileEncodeName(); |
| | | FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("设备结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(7); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("出库"+docFile.getFileSuffix()+"格式文档,文档名称:"+fileName); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return null; |
| | | } |
| | | |
| | |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]); |
| | | } |
| | | } |
| | | queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime()); |
| | | queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime()); |
| | | queryWrapper.orderByDesc("u.create_time"); |
| | | if (docQuery.getDocStatus() != null && docQuery.getDocStatus().contains(",")) { |
| | | String[] docStatusArray = docQuery.getDocStatus().split(","); |
| | | List<Integer> docStatusList = Arrays.stream(docStatusArray).map(Integer::parseInt).collect(Collectors.toList()); |
| | | queryWrapper.in("u.doc_status",docStatusList); |
| | | }else { |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocStatus()),"u.doc_status",docQuery.getDocStatus()); |
| | | } |
| | | if (docQuery.getDocDispatchStatus() != null && docQuery.getDocDispatchStatus().contains(",")) { |
| | | String[] docDispatchStatusArray = docQuery.getDocDispatchStatus().split(","); |
| | | List<Integer> docDispatchStatusList = Arrays.stream(docDispatchStatusArray).map(Integer::parseInt).collect(Collectors.toList()); |
| | | queryWrapper.in("u.doc_dispatch_status",docDispatchStatusList); |
| | | }else { |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocDispatchStatus()),"u.doc_dispatch_status",docQuery.getDocDispatchStatus()); |
| | | } |
| | | if (StrUtil.isNotEmpty(docQuery.getPullStatus())){ |
| | | if (("1").equals(docQuery.getPullStatus())){ |
| | | queryWrapper.isNull("o.doc_id"); |
| | | }else if (("2").equals(docQuery.getPullStatus())){ |
| | | queryWrapper.isNotNull("o.doc_id"); |
| | | } |
| | | } |
| | | if (docQuery.getSyncStatus()!=null){ |
| | | if (docQuery.getSyncStatus()==1){ |
| | | queryWrapper.isNotNull("t.sync_flag"); |
| | | }else if (docQuery.getSyncStatus()==2){ |
| | | queryWrapper.isNull("t.sync_flag"); |
| | | } |
| | | } |
| | | queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"u.create_time",docQuery.getStartTime()+" 00:00:00"); |
| | | queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"u.create_time",docQuery.getEndTime()+" 23:59:59"); |
| | | if (("desc").equals(docQuery.getOrder())){ |
| | | queryWrapper.orderByDesc("u."+ CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); |
| | | }else { |
| | | queryWrapper.orderByAsc("u."+CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); |
| | | } |
| | | IPage<DocInfo> docInfoIPage = super.getBaseMapper().findDeviceDocExtList(pageData, queryWrapper); |
| | | if (docInfoIPage != null && docInfoIPage.getRecords() != null && !docInfoIPage.getRecords().isEmpty()) { |
| | | for (DocInfo d : docInfoIPage.getRecords()) { |
| | |
| | | } |
| | | |
| | | QueryWrapper<DocInfo> queryWrapper = Wrappers.query(); |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocId()),"u.doc_id",docQuery.getDocId()); |
| | | queryWrapper.eq("r.attribution_type", docQuery.getAttributionType()).eq("r.attribution_id", docQuery.getAttributionId()) |
| | | .eq("r.classification_id", docClassification.getClassificationId()); |
| | | if (StringUtils.isNotEmpty(docQuery.getDocName())) { |
| | |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]); |
| | | } |
| | | } |
| | | queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime()); |
| | | queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime()); |
| | | queryWrapper.orderByDesc("u.create_time"); |
| | | getDocQuery(docQuery, queryWrapper); |
| | | return super.getBaseMapper().findDocExtList(queryWrapper); |
| | | } |
| | | |