| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | 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.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | 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.request.DocInfoQueryRequest; |
| | | import org.jeecg.modules.dnc.request.DocInfoUploadRequest; |
| | | import org.jeecg.modules.dnc.response.*; |
| | | 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.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.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.service.IDispatchFileService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.system.entity.SysParams; |
| | | import org.jeecg.modules.system.service.ISysParamsService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | |
| | | private IDeviceInfoService deviceInfoService; |
| | | @Autowired |
| | | private IDeviceGroupService deviceGroupService; |
| | | |
| | | @Autowired |
| | | private IDispatchFileService dispatchFileService; |
| | | @Autowired |
| | | private ISysParamsService sysParamsService; |
| | | @Autowired |
| | | @Lazy |
| | | private IComponentInfoService componentInfoService; |
| | | |
| | | /*备份处理*/ |
| | | @Override |
| | |
| | | docRelative.setAttributionType(uploadRequest.getAttributionType()); |
| | | docRelative.setClassificationId(docClass.getClassificationId()); |
| | | boolean b = docRelativeService.save(docRelative); |
| | | if (uploadRequest.getAttributionType()==2){ |
| | | //查询借用的部件 |
| | | List<ComponentInfo> borrowComponentInfoList=componentInfoService.list(new QueryWrapper<ComponentInfo>().eq("borrow_id", uploadRequest.getAttributionId())); |
| | | if (!borrowComponentInfoList.isEmpty()) { |
| | | borrowComponentInfoList.forEach(item->{ |
| | | DocRelative borrowDocRelative = new DocRelative(); |
| | | BeanUtil.copyProperties(docRelative,borrowDocRelative); |
| | | borrowDocRelative.setAttributionId(item.getComponentId()); |
| | | borrowDocRelative.setId(null); |
| | | docRelativeService.save(borrowDocRelative); |
| | | }); |
| | | } |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR); |
| | | DocFile docFile = new DocFile(); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | boolean saveBool = super.save(docInfo); |
| | | SysParams sysParams=sysParamsService.getSysPramBySettingKey("nc_dispatch_file"); |
| | | if (sysParams ==null){ |
| | | throw new JeecgBootException("未配置导入NC与电子图版是否触发审签流程,请联系管理员"); |
| | | }else { |
| | | if (saveBool&&sysParams.getSettingValue().equals("1")){ |
| | | //触发审签 |
| | | 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; |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean deleteDocInfo(String id) { |
| | | public boolean deleteDocInfo(String id,String attrType,String attrId) { |
| | | if(!ValidateUtil.validateString(id)) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | DocInfo en = super.getById(id); |
| | |
| | | ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); |
| | | if(en.getDocStatus() != 1) |
| | | ExceptionCast.cast(DocumentCode.DOC_DEL_ERROR); |
| | | //查询对应的关系 |
| | | if ("2".equals(attrType)) { |
| | | //判断部件引用 |
| | | ComponentInfo componentInfo=componentInfoService.getById(attrId); |
| | | if(componentInfo!=null&&componentInfo.getBorrowId()!=null){ |
| | | //借用的部件,只删除自己的关系 |
| | | DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>() |
| | | .eq("attribution_id", attrId).eq("attribution_type", 2).eq("doc_id",id)); |
| | | if(docRelative!=null){ |
| | | docRelativeService.removeById(docRelative.getId()); |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | FileOperate operate = fileOperateService.getByDocId(id); |
| | | if(operate != null) |
| | | ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING); |
| | |
| | | }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"); |
| | |
| | | } |
| | | 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())); |
| | | 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())); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @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 |
| | |
| | | }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"); |
| | |
| | | } |
| | | |
| | | 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())) { |
| | |
| | | getDocQuery(docQuery, queryWrapper); |
| | | return super.getBaseMapper().findDocExtList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 通过一组attributionId,docClassCode,attributionType查询可指派的文档信息列表 |
| | | * @param docQuery |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DocInfo> findListByDocQuery(DocInfoQueryRequest docQuery){ |
| | | if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionIds()) |
| | | || !ValidateUtil.validateInteger(docQuery.getAttributionType()) || |
| | | !ValidateUtil.validateString(docQuery.getDocClassCode())) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | } |
| | | DocClassification docClassification = docClassificationService.getByCode(docQuery.getDocClassCode()); |
| | | if(docClassification == null) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PAGE); |
| | | } |
| | | List<String> attributionIds = Arrays.asList(docQuery.getAttributionIds().split(",")); |
| | | |
| | | QueryWrapper<DocInfo> queryWrapper = Wrappers.query(); |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocId()),"u.doc_id",docQuery.getDocId()); |
| | | queryWrapper.eq("r.attribution_type", docQuery.getAttributionType()) |
| | | .in("r.attribution_id", attributionIds) |
| | | .eq("r.classification_id", docClassification.getClassificationId()); |
| | | if (StringUtils.isNotEmpty(docQuery.getDocName())) { |
| | | int dotIndex = docQuery.getDocName().lastIndexOf("."); |
| | | if (dotIndex == -1) { |
| | | queryWrapper.like("u.doc_name", docQuery.getDocName()); |
| | | } else { |
| | | String[] docNameArr = docQuery.getDocName().split("\\."); |
| | | queryWrapper.like(StrUtil.isNotEmpty(docNameArr[0]), "u.doc_name", docNameArr[0]); |
| | | queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]); |
| | | } |
| | | } |
| | | getDocQuery(docQuery, queryWrapper); |
| | | return super.getBaseMapper().findDocExtList(queryWrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<DocInfo> getByProcessIds(List<ProcessStream> streams) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean batchRemoveDocInfo(String[] docIds) { |
| | | public boolean batchRemoveDocInfo(String[] docIds,String attrType,String attrId) { |
| | | if(docIds == null || docIds.length < 1) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | for(String docId : docIds) { |
| | | this.deleteDocInfo(docId); |
| | | this.deleteDocInfo(docId,attrType,attrId); |
| | | } |
| | | return true; |
| | | } |