| | |
| | | import com.whyc.mapper.SOPMapper; |
| | | import com.whyc.pojo.SOP; |
| | | import com.whyc.pojo.SOPFileType; |
| | | import com.whyc.pojo.SOPLockLog; |
| | | import com.whyc.pojo.SOPProduct; |
| | | import com.whyc.util.*; |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | |
| | | |
| | | @Autowired |
| | | private SOPFileTypeService fileTypeService; |
| | | |
| | | @Autowired |
| | | private SOPLockLogService sopLockLogService; |
| | | |
| | | |
| | | @Transactional |
| | |
| | | @Transactional |
| | | public Response add(SOP sop,MultipartFile multipartFile) throws IOException { |
| | | //是否存在旧版本,存在则把所有旧版本状态更新为0 |
| | | String userName = ActionUtil.getUser().getName(); |
| | | Date now = new Date(); |
| | | QueryWrapper<SOP> query = Wrappers.query(); |
| | | query.eq("file_name",sop.getFileName()).eq("status",1); |
| | | List<SOP> sopListExists = mapper.selectList(query); |
| | |
| | | for (SOP sopExists : sopListExists) { |
| | | sopExists.setStatus(0); |
| | | mapper.updateById(sopExists); |
| | | |
| | | SOPLockLog lockLog = new SOPLockLog(); |
| | | lockLog.setSopId(sopExists.getId()); |
| | | lockLog.setReason("新版本上传,系统自动锁定旧版本"); |
| | | lockLog.setUserName(userName); |
| | | lockLog.setCreateTime(now); |
| | | lockLog.setStatus(0); |
| | | sopLockLogService.insert(lockLog); |
| | | } |
| | | } |
| | | |
| | | List<SOPProduct> sopProductList = sop.getSopProductList(); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String[] fileNameSplit = originalFilename.split("\\."); |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(new Date()); |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(now); |
| | | String newFileName = fileNameSplit[0]+"_"+dateFormat+"."+fileNameSplit[1]; |
| | | String fileUrlTemp = FileUtil.saveFile(multipartFile,"/sop/"+newFileName); |
| | | //String fileUrlTemp = sop.getFileUrl(); |
| | |
| | | |
| | | List<String> uploadTypeStrList = typeList.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | List<String> dbTypeStrList = recordListInDB.stream().map(type -> type.getType1() + ";" + type.getType2()).collect(Collectors.toList()); |
| | | Date now = new Date(); |
| | | for (int i = 0; i < uploadTypeStrList.size(); i++) { |
| | | String uploadTypeStr = uploadTypeStrList.get(i); |
| | | if (!dbTypeStrList.contains(uploadTypeStr)) { |
| | |
| | | } |
| | | |
| | | //查询sop信息 |
| | | public Response getSopInfo(List<SopDto> sqlList, String code, String model,int pageCurr,int pageSize) { |
| | | public Response getSopInfo(List<SopDto> sqlList, String code, String model, Integer status,String fileName, int pageCurr, int pageSize) { |
| | | String sqlStr=" "; |
| | | if(sqlList!=null&&sqlList.size()>0){ |
| | | for (SopDto dto:sqlList) { |
| | |
| | | for (int i=0;i<dto.getChileType().size();i++){ |
| | | sqlStr+=" and file_type like "+"'%"+dto.getParentType()+"-"+dto.getChileType().get(i)+"%' "; |
| | | } |
| | | }else{ |
| | | sqlStr+=" and file_type like "+"'%"+dto.getParentType()+"%' "; |
| | | } |
| | | } |
| | | } |
| | | if(status!=null) { |
| | | sqlStr += " and status = "+status; |
| | | } |
| | | if(fileName!=null) { |
| | | sqlStr += " and file_name like "+"'%"+fileName+"%' "; |
| | | } |
| | | List<SOP> list=mapper.getSopInfo(sqlStr,code,model); |
| | | PageInfo pageInfo= PageInfoUtils.list2PageInfo(list,pageCurr,pageSize); |
| | |
| | | return new Response().setII(1,"更新sop说明完成"); |
| | | } |
| | | |
| | | public Response updateStatusById(int id, int status) { |
| | | @Transactional |
| | | public Response updateStatusById(SOPLockLog lockLog) { |
| | | Integer id = lockLog.getSopId(); |
| | | Integer status = lockLog.getStatus(); |
| | | UpdateWrapper<SOP> update = Wrappers.update(); |
| | | update.set("status",status).eq("id",id); |
| | | mapper.update(null,update); |
| | | |
| | | //添加日志 |
| | | String name = ActionUtil.getUser().getName(); |
| | | lockLog.setUserName(name); |
| | | lockLog.setCreateTime(new Date()); |
| | | sopLockLogService.insert(lockLog); |
| | | |
| | | return new Response().setII(1,"设置完成"); |
| | | } |
| | | //查询sop历史 |
| | | public Response getSopHis(String fileName) { |
| | | List<SOP> list=mapper.getSopHis(fileName); |
| | | return new Response().setII(1,list.size()>0,list,"查询sop历史"); |
| | | } |
| | | } |