| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.config.EnumWorksheetType; |
| | | import com.whyc.dto.MailDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.WorksheetMainDTO; |
| | | import com.whyc.dto.WorksheetMainDTO2; |
| | |
| | | import com.whyc.mapper.WorksheetMainMapper; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.Word2PdfAsposeUtil; |
| | | import com.whyc.util.WordUtil; |
| | | import com.whyc.util.Zip4jUtil; |
| | | import org.aspectj.util.FileUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.mail.MessagingException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | private ProductBomApprovingService approvingService; |
| | | |
| | | @Autowired |
| | | private ProductApprovingService paService; |
| | | |
| | | @Autowired |
| | | private MaterialProductApprovingService cpApprovingService; |
| | | |
| | | @Autowired |
| | | private MaterialApprovingService cApprovingService; |
| | | private MaterialApprovingService mApprovingService; |
| | | |
| | | @Autowired |
| | | private MaterialService cService; |
| | | private MaterialService mService; |
| | | |
| | | @Autowired |
| | | private ProductBomService pbService; |
| | |
| | | @Autowired |
| | | private ProductSoftwareApprovingService psaService; |
| | | |
| | | @Autowired |
| | | private ProductSoftwareService productSoftwareService; |
| | | |
| | | @Autowired |
| | | private ProductService productService; |
| | | |
| | | @Autowired |
| | | private ProductHistoryService productHistoryService; |
| | | |
| | | @Autowired |
| | | private MailService mailService; |
| | | |
| | | @Autowired |
| | | private ProcedureDocApprovingService procedureDocApprovingService; |
| | | |
| | | @Transactional |
| | | public boolean submit(WorksheetMain main, DocUser user) { |
| | | public boolean submit(WorksheetMain main, DocUser user) throws IOException { |
| | | main.setType(1); |
| | | List<ProductBomApproving> bomList = main.getApprovingBomList(); |
| | | int rejectVersion=-1; |
| | | ProductApproving productApproving = main.getProductApproving(); |
| | | List<ProductBomApproving> bomList = productApproving.getBomApprovingList(); |
| | | //提交主表 |
| | | main.setCreateUserId(user.getId()); |
| | | //提交人角色来判断工作流层级 |
| | |
| | | main.setLevel(2); |
| | | main.setStatus(1); |
| | | mainMapper.insert(main); |
| | | }else { |
| | | rejectVersion = approvingService.getRejectVersion(main.getId()); |
| | | } |
| | | //提交子表 |
| | | WorksheetLink link =new WorksheetLink(); |
| | |
| | | link.setDealDesc(main.getDealDesc()); |
| | | link.setLinkStatus(0); |
| | | link.setEnableArchive(0); |
| | | link.setRejectVersion(rejectVersion+1); |
| | | linkMapper.insert(link); |
| | | } |
| | | else if(user.getRoleId().equals("1002")){ |
| | |
| | | main.setLevel(1); |
| | | main.setStatus(2); |
| | | mainMapper.insert(main); |
| | | }else { |
| | | rejectVersion = approvingService.getRejectVersion(main.getId()); |
| | | } |
| | | //提交子表 |
| | | WorksheetLink link =new WorksheetLink(); |
| | |
| | | link.setDealDesc(main.getDealDesc()); |
| | | link.setLinkStatus(0); |
| | | link.setEnableArchive(1); |
| | | link.setRejectVersion(rejectVersion+1); |
| | | linkMapper.insert(link); |
| | | } |
| | | else if(user.getRoleId().equals("1003")){ |
| | |
| | | return false; |
| | | } |
| | | //产品bom/图纸图片提交 |
| | | //查询当前驳回版本 |
| | | int nextRejectVersion = rejectVersion+1; |
| | | if(productApproving.getCustomCode()!=null && bomList.get(0).getId()!=null) { //与前端约定 定制表单号关联产品,则关联的产品id写入id |
| | | Product product = productService.getById(bomList.get(0).getId()); |
| | | List<ProductBom> productBomList = pbService.getBomByProductId(bomList.get(0).getId()); |
| | | //product下的图纸复制到新的审批路径 |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date()); |
| | | long timeStamp = System.currentTimeMillis(); |
| | | String filePath = rootFile + "product_approving" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp; |
| | | String inFilePath = rootFile + "product" + File.separator + product.getParentModel() + File.separator + "standard"+ File.separator + product.getVersion(); |
| | | File parentFile = new File(filePath); |
| | | //FileCopyUtils.copy(new File(inFilePath),parentFile); |
| | | FileUtil.copyDir(new File(inFilePath),parentFile); |
| | | productApproving.setFileUrl(filePath); |
| | | bomList.clear(); |
| | | productBomList.forEach(bom->{ |
| | | ProductBomApproving approving = new ProductBomApproving(); |
| | | approving.setCategory(bom.getCategory()); |
| | | approving.setSubCode(bom.getSubCode()); |
| | | approving.setSubName(bom.getSubName()); |
| | | approving.setSubModel(bom.getSubModel()); |
| | | approving.setUnit(bom.getUnit()); |
| | | approving.setQuantity(bom.getQuantity()); |
| | | approving.setProducer(bom.getProducer()); |
| | | approving.setMaterial(bom.getMaterial()); |
| | | approving.setThickness(bom.getThickness()); |
| | | approving.setSurfaceDetail(bom.getSurfaceDetail()); |
| | | approving.setNotes(bom.getNotes()); |
| | | |
| | | bomList.add(approving); |
| | | }); |
| | | } |
| | | //冻结(不启用)已存在的产品编码+定制保单号 |
| | | productService.deleteByParentCodeAndCustomCode(productApproving.getParentCode(),productApproving.getCustomCode()); |
| | | productHistoryService.updateEnabledStatus(productApproving.getParentCode(),productApproving.getCustomCode(),0); |
| | | |
| | | productApproving.setMainId(main.getId()); |
| | | productApproving.setCreateTime(new Date()); |
| | | paService.insert(productApproving); |
| | | |
| | | bomList.forEach(bom->{ |
| | | bom.setMainId(main.getId()); |
| | | //bom.setMainId(main.getId()); |
| | | bom.setProductApprovingId(productApproving.getId()); |
| | | bom.setUpUserId(user.getId()); |
| | | //lxw注释 |
| | | //bom.setRejectVersion(nextRejectVersion); |
| | | bom.setCreateDate(new Date()); |
| | | if(bom.getDwgUrl()==null){ |
| | | bom.setDwgUrl(""); |
| | |
| | | List<MaterialProductApproving> approvingList = new LinkedList<>(); |
| | | WorksheetMain main = mainDTO.getMain(); |
| | | List<MaterialProductApproving> addedList = mainDTO.getAddedList(); |
| | | List<MaterialProductApproving> replacedList = mainDTO.getReplacedList(); |
| | | //List<MaterialProductApproving> replacedList = mainDTO.getReplacedList(); |
| | | List<MaterialProductApproving> removedList = mainDTO.getRemovedList(); |
| | | |
| | | main.setType(EnumWorksheetType.MaterialProduct.getType()); |
| | |
| | | }else{ |
| | | return false; |
| | | } |
| | | //散装件-产品审批提交 |
| | | //物料-产品审批提交 |
| | | if(addedList!=null && addedList.size()!=0){ |
| | | addedList.forEach(item->{ |
| | | item.setMainId(main.getId()); |
| | |
| | | }); |
| | | approvingList.addAll(addedList); |
| | | } |
| | | if(replacedList!=null && replacedList.size()!=0){ |
| | | /*if(replacedList!=null && replacedList.size()!=0){ |
| | | replacedList.forEach(item->{ |
| | | item.setMainId(main.getId()); |
| | | item.setLinkType(2); |
| | | }); |
| | | approvingList.addAll(replacedList); |
| | | } |
| | | }*/ |
| | | if(removedList!=null && removedList.size()!=0){ |
| | | removedList.forEach(item->{ |
| | | item.setMainId(main.getId()); |
| | |
| | | return true; |
| | | } |
| | | |
| | | public Response MaterialSubmit(WorksheetMain main, DocUser user) { |
| | | public Response materialSubmit(WorksheetMain main, DocUser user) { |
| | | Response<Object> response = new Response<>(); |
| | | List<MaterialApproving> cApprovingList = main.getCApprovingList(); |
| | | List<MaterialApproving> mApprovingList = main.getMApprovingList(); |
| | | //判断是新增还是删除 |
| | | boolean isAdded = cApprovingList.get(0).getSubName()!=null; |
| | | boolean isAdded = mApprovingList.get(0).getSubName()!=null; |
| | | if(isAdded) { //新增 |
| | | //查询是否有 已生效或者已提交审批的 相同的散装件 |
| | | //查询是否有 已生效或者已提交审批的 相同的物料 |
| | | List<Material> existMaterialList = new LinkedList<>(); |
| | | List<MaterialApproving> existCAList = new LinkedList<>(); |
| | | |
| | | List<Material> MaterialList = cService.getList(); |
| | | List<MaterialApproving> cAList = cApprovingService.getListByStatus(1); |
| | | for (int i = 0; i < cApprovingList.size(); i++) { |
| | | MaterialApproving MaterialApproving = cApprovingList.get(i); |
| | | for (int j = 0; j < MaterialList.size(); j++) { |
| | | if (MaterialApproving.getSubCode().equals(MaterialList.get(j).getSubCode()) |
| | | && MaterialApproving.getSubName().equals(MaterialList.get(j).getSubName()) |
| | | && MaterialApproving.getSubModel().equals(MaterialList.get(j).getSubModel()) |
| | | List<Material> materialList = mService.getList(); |
| | | List<MaterialApproving> cAList = mApprovingService.getListByStatus(1); |
| | | for (int i = 0; i < mApprovingList.size(); i++) { |
| | | MaterialApproving materialApproving = mApprovingList.get(i); |
| | | for (int j = 0; j < materialList.size(); j++) { |
| | | if (materialApproving.getSubCode().equals(materialList.get(j).getSubCode()) |
| | | && materialApproving.getSubName().equals(materialList.get(j).getSubName()) |
| | | && materialApproving.getSubModel().equals(materialList.get(j).getSubModel()) |
| | | ) { |
| | | existMaterialList.add(MaterialList.get(j)); |
| | | existMaterialList.add(materialList.get(j)); |
| | | } |
| | | } |
| | | |
| | | for (int j = 0; j < cAList.size(); j++) { |
| | | if (MaterialApproving.getSubCode().equals(cAList.get(j).getSubCode()) |
| | | && MaterialApproving.getSubName().equals(cAList.get(j).getSubName()) |
| | | && MaterialApproving.getSubModel().equals(cAList.get(j).getSubModel()) |
| | | if (materialApproving.getSubCode().equals(cAList.get(j).getSubCode()) |
| | | && materialApproving.getSubName().equals(cAList.get(j).getSubName()) |
| | | && materialApproving.getSubModel().equals(cAList.get(j).getSubModel()) |
| | | ) { |
| | | existCAList.add(cAList.get(j)); |
| | | } |
| | |
| | | int existMaterialSize = existMaterialList.size(); |
| | | if (existCASize != 0) { |
| | | if (existMaterialSize != 0) { |
| | | response.setII(21, existCAList, existMaterialList, "重复提交:现有散装件及正在进行审批的散装件中,存在当前提交上传的散装件"); |
| | | response.setII(21, existCAList, existMaterialList, "重复提交:现有物料及正在进行审批的物料中,存在当前提交上传的物料"); |
| | | } else { |
| | | response.set(22, existCAList, "重复提交:正在进行审批的散装件中,存在当前提交上传的散装件"); |
| | | response.set(22, existCAList, "重复提交:正在进行审批的物料中,存在当前提交上传的物料"); |
| | | } |
| | | return response; |
| | | } else { |
| | | if (existMaterialSize != 0) { |
| | | return response.setII(23, null, existMaterialList, "重复提交:现有散装件中,存在当前提交上传的散装件"); |
| | | return response.setII(23, null, existMaterialList, "重复提交:现有物料中,存在当前提交上传的物料"); |
| | | } |
| | | } |
| | | }else{ //删除 |
| | | //判断是否在散装件审批删除中,是否存在产品关联及关联审批 |
| | | //判断是否在物料审批删除中,是否存在产品关联及关联审批 |
| | | MaterialApproving deleteApproving = new MaterialApproving(); |
| | | List<MaterialProductHistory> existMaterialProducts = new LinkedList<>(); |
| | | List<MaterialProductApproving> existMaterialProductApprovingList = new LinkedList<>(); |
| | | deleteApproving = cApprovingService.getListByMaterialId(cApprovingList.get(0).getMaterialId()); |
| | | deleteApproving = mApprovingService.getListByMaterialId(mApprovingList.get(0).getMaterialId()); |
| | | |
| | | //查看产品关联 |
| | | List<MaterialProductHistory> cphLatestExistList = cphService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId()); |
| | | List<MaterialProductHistory> cphLatestExistList = cphService.getLatestExistListByMaterialId(mApprovingList.get(0).getMaterialId()); |
| | | //查看产品关联审批 |
| | | //lxw注释 |
| | | //List<MaterialProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId()); |
| | | List<MaterialProductApproving> cpaLatestExistList =new ArrayList<>(); |
| | | List<MaterialProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByMaterialId(mApprovingList.get(0).getMaterialId()); |
| | | if(deleteApproving!=null){ |
| | | return response.set(31,deleteApproving,"拒绝本次删除申请,当前散装件正在进行删除审批"); |
| | | return response.set(31,deleteApproving,"拒绝本次删除申请,当前物料正在进行删除审批"); |
| | | } |
| | | if(cphLatestExistList!=null && cphLatestExistList.size()!=0){ |
| | | if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){ |
| | | return response.setII(32,cpaLatestExistList,cphLatestExistList,"拒绝本次删除申请,当前散装已经关联产品及在产品关联审批"); |
| | | }else{ |
| | | return response.setII(33,null,cphLatestExistList,"拒绝本次删除申请,当前散装件在产品关联审批"); |
| | | return response.setII(33,null,cphLatestExistList,"拒绝本次删除申请,当前物料在产品关联审批"); |
| | | } |
| | | }else{ |
| | | if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){ |
| | | return response.set(34,cpaLatestExistList,"拒绝本次删除申请,当前散装件已经关联产品"); |
| | | return response.set(34,cpaLatestExistList,"拒绝本次删除申请,当前物料已经关联产品"); |
| | | } |
| | | } |
| | | |
| | |
| | | }else{ |
| | | return response.set(3); |
| | | } |
| | | //散装件-审批提交 |
| | | cApprovingList.forEach(cApproving->{ |
| | | //物料-审批提交 |
| | | mApprovingList.forEach(cApproving->{ |
| | | cApproving.setCreateDate(new Date()); |
| | | cApproving.setMainId(main.getId()); |
| | | cApproving.setStatus(1); |
| | | }); |
| | | |
| | | cApprovingService.insert(cApprovingList); |
| | | mApprovingService.insert(mApprovingList); |
| | | return response.set(1); |
| | | } |
| | | |
| | |
| | | Response response = new Response(); |
| | | WorksheetMain main = mainDTO.getMain(); |
| | | ProductSoftwareApproving approving = mainDTO.getApproving(); |
| | | //首先校验文件名是否已存在 |
| | | String filename = file.getOriginalFilename(); |
| | | List<ProductSoftwareApproving> softwareApprovingList = psaService.getAll(); |
| | | List<ProductSoftware> softwareList = productSoftwareService.getAll(); |
| | | List<String> existApprovingList = softwareApprovingList.stream().map(ProductSoftwareApproving::getSoftwareName).collect(Collectors.toList()); |
| | | List<String> existList = softwareList.stream().map(ProductSoftware::getSoftwareName).collect(Collectors.toList()); |
| | | |
| | | for (String existFilename:existList){ |
| | | if(filename.equals(existFilename)){ |
| | | return response.set(1,false,"软件文件名已存在"); |
| | | } |
| | | } |
| | | for (String existFilename:existApprovingList){ |
| | | if(filename.equals(existFilename)){ |
| | | return response.set(1,false,"软件文件名在审批列表中已存在"); |
| | | } |
| | | } |
| | | |
| | | main.setType(1); |
| | | //提交主表 |
| | |
| | | String filePath = rootFile + productSoftwarePath; |
| | | String originalFilename = file.getOriginalFilename(); |
| | | File zipFile = new File(filePath+File.separator+ originalFilename); |
| | | if(!zipFile.exists()){ |
| | | /*if(!zipFile.exists()){ |
| | | zipFile.mkdirs(); |
| | | }*/ |
| | | File parentFile = new File(filePath); |
| | | if (!parentFile.exists()) { |
| | | parentFile.mkdirs(); |
| | | } |
| | | file.transferTo(zipFile); |
| | | approving.setSoftwareUrl("doc_file"+productSoftwarePath+File.separator+ originalFilename); |
| | |
| | | //判断是哪种类型的审批,返回不同的类型 具体数据 |
| | | Integer type = getInfoById(id).getType(); |
| | | if(type.intValue() == EnumWorksheetType.ProductBom.getType()) { |
| | | return mainMapper.getLinkList(id); |
| | | WorksheetMain main = mainMapper.getLinkList(id); |
| | | List<ProductBomApproving> pbaList = approvingService.getList(main.getProductApproving().getId()); |
| | | main.getProductApproving().setBomApprovingList(pbaList); |
| | | return main; |
| | | }else if(type.intValue() == EnumWorksheetType.Material.getType()){ |
| | | //lxw注释 |
| | | //return mainMapper.getLinkListWithMaterials(id); |
| | | return null; |
| | | }else{ //散装件-产品 |
| | | //return mainMapper.getLinkListWithMaterialProducts(id); |
| | | return null; |
| | | return mainMapper.getLinkListWithMaterials(id); |
| | | }else{ //物料-产品 |
| | | return mainMapper.getLinkListWithMaterialProducts(id); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | public Response addProductProcedureAndSOP(ProcedureDocApproving approving, DocUser user) throws IOException, MessagingException { |
| | | WorksheetMain main = new WorksheetMain(); |
| | | //存储上传信息到主表,节点表 |
| | | //文件保存在/doc_file/procedure_approving/xxx_时间戳.doc |
| | | MultipartFile multipartFile = approving.getMultipartFile(); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | Date date = new Date(); |
| | | String filename = originalFilename.replace(".doc","_"+date.getTime()+".doc"); |
| | | String suffixFilePath = "procedure_approving" + File.separator + filename; |
| | | String outFilePath = rootFile + suffixFilePath; |
| | | File outFile = new File(outFilePath); |
| | | multipartFile.transferTo(outFile); |
| | | |
| | | main.setTitle(approving.getName()); |
| | | main.setDescription(approving.getDescription()); |
| | | main.setCreateUserId(user.getId()); |
| | | main.setBeginTime(date); |
| | | main.setStatus(1); |
| | | if(approving.getType()==1){ |
| | | main.setType(EnumWorksheetType.ProductProcedure.getType()); |
| | | }else{ |
| | | main.setType(EnumWorksheetType.SOP.getType()); |
| | | } |
| | | mainMapper.insert(main); |
| | | |
| | | List<WorksheetLink> links = new LinkedList<>(); |
| | | WorksheetLink baseLink = new WorksheetLink(); |
| | | WorksheetLink linkFzr = new WorksheetLink(); |
| | | WorksheetLink linkBz = new WorksheetLink(); |
| | | WorksheetLink linkZz = new WorksheetLink(); |
| | | WorksheetLink linkPb = new WorksheetLink(); |
| | | |
| | | baseLink.setMainId(main.getId()); |
| | | baseLink.setLinkStatus(0); |
| | | baseLink.setCreateTime(date); |
| | | |
| | | BeanUtils.copyProperties(baseLink,linkFzr); |
| | | BeanUtils.copyProperties(baseLink,linkBz); |
| | | BeanUtils.copyProperties(baseLink,linkZz); |
| | | BeanUtils.copyProperties(baseLink,linkPb); |
| | | |
| | | linkFzr.setDealUserId(approving.getFzr()); |
| | | linkBz.setDealUserId(approving.getBz()); |
| | | linkZz.setDealUserId(approving.getZz()); |
| | | linkPb.setDealUserId(approving.getPb()); |
| | | links.add(linkFzr); |
| | | links.add(linkBz); |
| | | links.add(linkZz); |
| | | links.add(linkPb); |
| | | linkMapper.insertBatchSomeColumn(links); |
| | | |
| | | //流程文档审批子表存入 |
| | | approving.setFile("doc_file"+ File.separator + suffixFilePath); |
| | | approving.setMainId(main.getId()); |
| | | procedureDocApprovingService.insert(approving); |
| | | //发送邮件给四个确认人 |
| | | QueryWrapper<DocUser> query = Wrappers.query(); |
| | | query.select("mail").in("id",approving.getFzr(),approving.getBz(),approving.getZz(),approving.getPb()); |
| | | List<DocUser> docUsers = userMapper.selectList(query); |
| | | List<String> userMailList = docUsers.stream().map(DocUser::getMail).collect(Collectors.toList()); |
| | | |
| | | MailDTO mailDTO = new MailDTO(); |
| | | mailDTO.setMailList(userMailList); |
| | | if(approving.getType()==1){ |
| | | mailDTO.setTitle("【流程卡确认】"+main.getTitle()); |
| | | mailDTO.setContent(user.getName()+"在文档管理平台上传了产品流程卡,请及时确认"); |
| | | }else{ |
| | | mailDTO.setTitle("【SOP确认】"+main.getTitle()); |
| | | mailDTO.setContent(user.getName()+"在文档管理平台上传了SOP,请及时确认"); |
| | | } |
| | | mailService.sendMail(mailDTO); |
| | | |
| | | return new Response().setII(1,"上传完成"); |
| | | } |
| | | |
| | | /** |
| | | * 统计数量: |
| | | * 我的提交 |
| | | * 待处理 |
| | | * 已处理 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | public Map<String, Integer> getProcedureDocApprovingStatusStatistic(DocUser user) { |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | |
| | | //我的提交 |
| | | QueryWrapper<WorksheetMain> query = Wrappers.query(); |
| | | query.eq("create_user_id",user.getId()).in("type",EnumWorksheetType.ProductProcedure.getType(),EnumWorksheetType.SOP.getType()); |
| | | List<WorksheetMain> worksheetMains = mainMapper.selectList(query); |
| | | map.put("mySubmit",worksheetMains.size()); |
| | | //待处理|已处理 |
| | | int handlingCount = 0; |
| | | int handledCount = 0; |
| | | List<WorksheetLink> links = linkMapper.getProcedureDocApprovingByUserId(user.getId()); |
| | | for (WorksheetLink link : links) { |
| | | //dealType的值为主表的状态 |
| | | if(link.getDealType() == 1 && link.getLinkStatus() == 0){ //未处理且审批未结束 |
| | | handlingCount++; |
| | | }else if(link.getLinkStatus() == 1 || link.getLinkStatus() ==2){ //已确认或已拒绝 |
| | | handledCount++; |
| | | } |
| | | } |
| | | map.put("handling",handlingCount); |
| | | map.put("handled",handledCount); |
| | | return map; |
| | | } |
| | | |
| | | public Response procedurePreview(HttpServletResponse response, int mainId) throws IOException { |
| | | //查询当前单据审批人的确认状态 |
| | | ProcedureDocApproving approving = procedureDocApprovingService.getByMainId(mainId); |
| | | List<WorksheetLink> linkList = linkMapper.getList(mainId); |
| | | String fzr = linkList.get(0).getLinkStatus() == 1 ? linkList.get(0).getDealUsername():""; |
| | | String bz = linkList.get(1).getLinkStatus() == 1 ? linkList.get(1).getDealUsername():""; |
| | | String zz = linkList.get(2).getLinkStatus() == 1 ? linkList.get(2).getDealUsername():""; |
| | | String pb = linkList.get(3).getLinkStatus() == 1 ? linkList.get(3).getDealUsername():""; |
| | | List<String> list = new LinkedList(); |
| | | list.add(fzr); |
| | | list.add(bz); |
| | | list.add(zz); |
| | | list.add(pb); |
| | | //获取word模板具体文件 |
| | | |
| | | long currentTimeMillis = System.currentTimeMillis(); |
| | | String projectDir = CommonUtil.getProjectDir(); |
| | | String fileRelativePath = approving.getFile(); |
| | | String inFilePath = projectDir + File.separator + fileRelativePath; |
| | | String outFilePath = inFilePath.replace(".doc","_"+currentTimeMillis+".doc"); |
| | | WordUtil.fillValue(inFilePath,outFilePath,list); |
| | | //pdf带水印的地址 /doc_file/procedure_approving/xxx.doc |
| | | String suffixOutPdfFilePath = "doc_file" + File.separator + "procedure_approving" + File.separator + outFilePath.substring(outFilePath.lastIndexOf(File.separator)+1,outFilePath.lastIndexOf(".")) + ".pdf"; |
| | | String outPdfFilePath = projectDir + File.separator + suffixOutPdfFilePath; |
| | | Word2PdfAsposeUtil.doc2pdfWithWaterMark(outFilePath,outPdfFilePath,true); |
| | | return new Response().setII(1,suffixOutPdfFilePath); |
| | | /*try { |
| | | // 转码防止乱码 |
| | | //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1")); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( fileRelativePath.substring(fileRelativePath.lastIndexOf(File.separator+1)), "utf-8")); |
| | | OutputStream out = response.getOutputStream(); |
| | | FileInputStream in = new FileInputStream(outFilePath); |
| | | int len=0; |
| | | byte[] buffer =new byte[1024]; |
| | | //7. 将缓冲区中的数据输出 |
| | | while ((len=in.read(buffer))>0){ |
| | | out.write(buffer,0,len); |
| | | } |
| | | in.close(); |
| | | out.close(); |
| | | } catch (FileNotFoundException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }*/ |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的工单,所有人可见 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public Response getAllPage(WorksheetMain param) { |
| | | Integer pageNum = param.getPageNum(); |
| | | Integer pageSize = param.getPageSize(); |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | |
| | | int createUserId = param.getCreateUserId().intValue(); |
| | | Date beginTime = param.getBeginTime(); |
| | | Date endTime = param.getEndTime(); |
| | | Integer type = param.getType(); |
| | | QueryWrapper<WorksheetMain> query = Wrappers.query(); |
| | | if(createUserId>0){ |
| | | query.eq("create_user_id",createUserId); |
| | | } |
| | | query.ge("begin_time",beginTime); |
| | | query.le("begin_time",endTime); |
| | | if(type!=null && type>=0){ |
| | | query.eq("type",type); |
| | | } |
| | | List<WorksheetMain> worksheetMains = mainMapper.selectList(query); |
| | | PageInfo pageInfo = new PageInfo(worksheetMains); |
| | | return new Response().set(1,pageInfo); |
| | | } |
| | | } |