| | |
| | | import com.whyc.config.EnumWorksheetType; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.WorksheetMainDTO; |
| | | import com.whyc.dto.WorksheetMainDTO2; |
| | | import com.whyc.mapper.DocUserMapper; |
| | | import com.whyc.mapper.WorksheetLinkMapper; |
| | | import com.whyc.mapper.WorksheetMainMapper; |
| | | import com.whyc.pojo.*; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.Zip4jUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ComponentProductHistoryService cphService; |
| | | |
| | | @Autowired |
| | | private ProductSoftwareApprovingService psaService; |
| | | |
| | | @Transactional |
| | | public boolean submit(WorksheetMain main, DocUser user) { |
| | |
| | | return response.set(1); |
| | | } |
| | | |
| | | public Response productSoftwareSubmit(MultipartFile file, WorksheetMain main, DocUser user) throws IOException { |
| | | Response response = new Response(); |
| | | |
| | | ProductSoftwareApproving approving = main.getSoftwareApproving(); |
| | | |
| | | main.setType(1); |
| | | //提交主表 |
| | | main.setCreateUserId(user.getId()); |
| | | //提交人角色来判断工作流层级 |
| | | if(user.getRoleId().equals("1001")){ |
| | | if(main.getId()==null) { |
| | | main.setLevel(2); |
| | | main.setStatus(1); |
| | | mainMapper.insert(main); |
| | | } |
| | | //提交子表 |
| | | WorksheetLink link =new WorksheetLink(); |
| | | link.setMainId(main.getId()); |
| | | link.setParentId(0); |
| | | link.setDealUserId(main.getNextUser()); |
| | | link.setDealType(1); |
| | | link.setDealDesc(main.getDealDesc()); |
| | | link.setLinkStatus(0); |
| | | link.setEnableArchive(0); |
| | | linkMapper.insert(link); |
| | | } |
| | | else if(user.getRoleId().equals("1002")){ |
| | | if(main.getId()==null) { |
| | | main.setLevel(1); |
| | | main.setStatus(2); |
| | | mainMapper.insert(main); |
| | | } |
| | | //提交子表 |
| | | WorksheetLink link =new WorksheetLink(); |
| | | link.setMainId(main.getId()); |
| | | link.setParentId(0); |
| | | link.setDealUserId(main.getNextUser()); |
| | | link.setDealType(2); |
| | | link.setDealDesc(main.getDealDesc()); |
| | | link.setLinkStatus(0); |
| | | link.setEnableArchive(1); |
| | | linkMapper.insert(link); |
| | | } |
| | | else if(user.getRoleId().equals("1003")){ |
| | | main.setLevel(0); |
| | | main.setStatus(5); |
| | | mainMapper.insert(main); |
| | | }else{ |
| | | return response.set(1,false,"角色无法提交审批"); |
| | | } |
| | | //转化为审批路径 |
| | | //检查是否为zip |
| | | boolean isZip = Zip4jUtil.checkZipFileParam(file); |
| | | if(!isZip){ |
| | | return response.set(1,false,"上传的文件格式不是zip"); |
| | | } |
| | | //zip存储路径:doc_file/product_approving/${username}/{dateFormat}/${timeStamp} |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date()); |
| | | long timeStamp = System.currentTimeMillis(); |
| | | String productSoftwarePath = File.separator + "product_software" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp; |
| | | String filePath = rootFile + productSoftwarePath; |
| | | String originalFilename = file.getOriginalFilename(); |
| | | File zipFile = new File(filePath+File.separator+ originalFilename); |
| | | if(!zipFile.exists()){ |
| | | zipFile.mkdirs(); |
| | | } |
| | | file.transferTo(zipFile); |
| | | approving.setSoftwareUrl("doc_file"+productSoftwarePath+File.separator+ originalFilename); |
| | | approving.setSoftwareName(originalFilename); |
| | | approving.setCreateTime(new Date()); |
| | | approving.setMainId(main.getId()); |
| | | //产品软件提交 |
| | | psaService.insert(approving); |
| | | return response.set(1,true, "提交完成"); |
| | | } |
| | | |
| | | public WorksheetMain getInfoById(Integer id) { |
| | | return mainMapper.selectById(id); |
| | | } |