| | |
| | | import com.whyc.mapper.MaterialMapper; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.Material; |
| | | import com.whyc.pojo.MaterialHistory; |
| | | import com.whyc.pojo.ProductBom; |
| | | import com.whyc.util.DateUtil; |
| | | import com.whyc.util.*; |
| | |
| | | public class MaterialService { |
| | | @Autowired(required = false) |
| | | private MaterialMapper mapper; |
| | | |
| | | @Autowired |
| | | private MaterialHistoryService mhService; |
| | | |
| | | //查询所有的散装件信息加设置了替换关系的子件信息 |
| | | /*public Response getAllMaterial(String category,String subCode,String subName,String subModel,int pageCurr,int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | |
| | | public Response getMaterialLimit(String subCode, String subName, String subModel, int pageCurr, int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | List<Material> list=mapper.getMaterialLimit(subCode,subName,subModel); |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | int flag=0; |
| | | // 返回是否存在附件 |
| | | if(list!=null&&list.size()>0){ |
| | | for (Material m:list) { |
| | | if(m.getFileUrl()!=null&&!m.getFileUrl().isEmpty()){ |
| | | File file = new File(fileDirName+File.separator+m.getFileUrl()); |
| | | if(!file.exists()) { |
| | | flag=0; |
| | | }else{ |
| | | String[] fileNames = file.list();//获取该文件夹下的所有文件以及目录的名字 |
| | | if(fileNames.length>0){ |
| | | flag=1; |
| | | }else{ |
| | | flag=0; |
| | | } |
| | | } |
| | | } |
| | | m.setHasAttachFlag(flag); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"查询所有物料(分页,模糊查询)"); |
| | | } |
| | |
| | | List<String> currentFileList = new LinkedList<>(); |
| | | List<String> uploadingFileList = new LinkedList<>(); |
| | | |
| | | String dirPathDB = "doc_file" + File.separator + "material" + File.separator + material.getId() + "-" + material.getSubCode() + "-" + material.getSubModel(); |
| | | String dirPath = CommonUtil.getRootFile() + "material" + File.separator + material.getId() + "-" + material.getSubCode() + "-" + material.getSubModel(); |
| | | String dirPathDB = "doc_file" + File.separator + "material" + File.separator + material.getSubCode() + "-" + material.getSubModel(); |
| | | String dirPath = CommonUtil.getRootFile() + "material" + File.separator + material.getSubCode() + "-" + material.getSubModel(); |
| | | File dirFile = new File(dirPath); |
| | | |
| | | Date now = new Date(); |
| | |
| | | multipartFile.transferTo(zipFile); |
| | | |
| | | //路径不存在,说明是首次上传,设置物料对应的fileUrl |
| | | //同时在物料历史里面添加记录 |
| | | Material temp = new Material(); |
| | | MaterialHistory mh = new MaterialHistory(); |
| | | |
| | | temp.setId(material.getId()); |
| | | mh.setProductId(-1); |
| | | mh.setMaterialId(material.getId()); |
| | | int userId = ActionUtil.getUser().getId().intValue(); |
| | | mh.setUpUserId(userId); |
| | | mh.setCreateTime(now); |
| | | if(fileSuffix.equals("dwg")){ |
| | | temp.setDwgUrl(dirPathDB + fileFullName); |
| | | mh.setDwgUrl(dirPathDB + fileFullName); |
| | | }else { |
| | | temp.setPictureUrl(dirPathDB + fileFullName); |
| | | mh.setPictureUrl(dirPathDB + fileFullName); |
| | | } |
| | | mapper.updateById(temp); |
| | | mhService.insert(mh); |
| | | |
| | | return new Response().set(1, true, "上传完成"); |
| | | } |
| | |
| | | } |
| | | ExcelUtil.exportExcel("清单","物料",title,values,null,response); |
| | | } |
| | | |
| | | public Material getLastByCode(String code) { |
| | | QueryWrapper<Material> query = Wrappers.query(); |
| | | query.eq("sub_code",code).orderByDesc("id").last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | } |