| | |
| | | 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.CamelToSnakeRegex; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | |
| | | |
| | |
| | | |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.response.*; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | 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 { |
| | |
| | | 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()); |
| | |
| | | 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 (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 (("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); |
| | |
| | | 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 |
| | |
| | | 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 (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.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()); |
| | | getDocQuery(docQuery, queryWrapper); |
| | | return super.getBaseMapper().findDocExtList(queryWrapper); |
| | | } |
| | | |