| | |
| | | |
| | | @ApiOperation("源码上传") |
| | | @PostMapping("uploadCode") |
| | | public Response uploadCode(@RequestParam MultipartFile file, @RequestParam String softIds) throws IOException { |
| | | return service.uploadCode(file,softIds); |
| | | public Response uploadCode(@RequestParam MultipartFile file, @RequestParam String fileNames) throws IOException { |
| | | return service.uploadCode(file,fileNames); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据软件id实现源码下载") |
| | | @GetMapping("downLoadCode") |
| | | public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, @RequestParam String softId){ |
| | | service.downLoadCode(req,resp,softId); |
| | | public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, @RequestParam String fileName){ |
| | | service.downLoadCode(req,resp,fileName); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据板号和物料编码查询软件记录") |
| | | @GetMapping("getSoftwareByBoardAndMaterialCode") |
| | | public Response getSoftwareByBoardAndMaterialCode(@RequestParam String board,@RequestParam String materialCode){ |
| | | return wareService.getSoftwareByBoardAndMaterialCode(board,materialCode); |
| | | @ApiOperation(value = "查询日期三天内的所有上传软件名称") |
| | | @GetMapping("getFileNameByCreateTime") |
| | | public Response getFileNameByCreateTime(@RequestParam String createTime){ |
| | | return wareService.getFileNameByCreateTime(createTime); |
| | | } |
| | | } |
| | |
| | | @Data |
| | | public class SoftDto implements Serializable { |
| | | private String fileUrl; |
| | | private String fileName; |
| | | private Integer lockFlag; |
| | | private Integer codeFlag; |
| | | private List<Software> softwares; |
| | | } |
| | |
| | | |
| | | private Integer num; |
| | | |
| | | @ApiModelProperty("软件id") |
| | | private String softId; |
| | | @ApiModelProperty("软件名称") |
| | | private String fileName; |
| | | |
| | | @ApiModelProperty("源码路径") |
| | | private String codeUrl; |
| | |
| | | this.num = num; |
| | | } |
| | | |
| | | public String getSoftId() { |
| | | return softId; |
| | | public String getFileName() { |
| | | return fileName; |
| | | } |
| | | |
| | | public void setSoftId(String softId) { |
| | | this.softId = softId; |
| | | public void setFileName(String fileName) { |
| | | this.fileName = fileName; |
| | | } |
| | | |
| | | public String getCodeUrl() { |
| | |
| | | |
| | | |
| | | //源码上传 |
| | | public Response uploadCode(MultipartFile file, String softIds) throws IOException { |
| | | String[] softList=softIds.split(","); |
| | | public Response uploadCode(MultipartFile file, String fileNames) throws IOException { |
| | | String[] nameList=fileNames.split(","); |
| | | String fileName = file.getOriginalFilename(); |
| | | Date date = new Date(); |
| | | String dateUnion = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date); |
| | |
| | | } |
| | | String codeUrl=softcodeDir+File.separator+fileName; |
| | | file.transferTo(new File(codeUrl)); |
| | | if(softList.length>0){ |
| | | for(String softId:softList){ |
| | | if(nameList.length>0){ |
| | | for(String name:nameList){ |
| | | Softcode softcode=new Softcode(); |
| | | softcode.setSoftId(softId); |
| | | softcode.setFileName(name); |
| | | softcode.setCodeUrl(softcodeHttpUrl+File.separator+fileName); |
| | | //判断是否存在源码,存在修改,不存在添加 |
| | | if(mapper.selectOne(new QueryWrapper<Softcode>().eq("soft_id",softId))!=null){ |
| | | mapper.update(softcode,new UpdateWrapper<Softcode>().eq("soft_id",softId)); |
| | | if(mapper.selectOne(new QueryWrapper<Softcode>().eq("file_name",name))!=null){ |
| | | mapper.update(softcode,new UpdateWrapper<Softcode>().eq("file_name",name)); |
| | | }else{ |
| | | mapper.insert(softcode); |
| | | } |
| | |
| | | |
| | | |
| | | //根据软件id实现源码下载 |
| | | public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, String softId) { |
| | | public void downLoadCode(HttpServletRequest req, HttpServletResponse resp, String fileName) { |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("soft_id",softId); |
| | | wrapper.eq("file_name",fileName); |
| | | wrapper.last("limit 1"); |
| | | Softcode softcode=mapper.selectOne(wrapper); |
| | | |
| | |
| | | } |
| | | //记录日志 |
| | | logService.recordOperationLogDownLoad(ActionUtil.getUser().getId(),ActionUtil.getUser().getName(), UserOperation.TYPE_DOWNLOAD_SOFWARE.getType(),new Date(),req.getRemoteAddr() |
| | | ,filename,fileDirName+File.separator+softcode.getCodeUrl(),"",String.valueOf(softId),""); |
| | | ,filename,fileDirName+File.separator+softcode.getCodeUrl(),"",fileName,""); |
| | | } |
| | | } |
| | |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.SoftDto; |
| | | import com.whyc.mapper.SoftwareMapper; |
| | | import com.whyc.pojo.Software; |
| | | import com.whyc.util.ActionUtil; |
| | |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | |
| | | public Response getAllSoftware(Integer lockFlag, String fileName, String applyMaterialCode, String applyModel, String owner, String boardNumber |
| | | ,String version, int pageCurr, int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | List list=mapper.getFileUrl(lockFlag,fileName,applyMaterialCode,applyModel,owner,boardNumber,version); |
| | | List<SoftDto> list=mapper.getFileUrl(lockFlag,fileName,applyMaterialCode,applyModel,owner,boardNumber,version); |
| | | //根据软件名称查询是否存在源码(0:否,1:存在) |
| | | for (SoftDto dto:list) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("file_name",dto.getFileName()); |
| | | if(mapper.selectCount(wrapper)>0){ |
| | | dto.setCodeFlag(1); |
| | | }else{ |
| | | dto.setCodeFlag(0); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"软件信息返回"); |
| | | } |
| | |
| | | return new Response().set(1,flag>0,"件id实现软件删除"); |
| | | } |
| | | |
| | | //根据板号和物料编码查询软件记录 |
| | | public Response getSoftwareByBoardAndMaterialCode(String board, String materialCode) { |
| | | //查询日期三天内的所有上传软件名称 |
| | | public Response getFileNameByCreateTime(String createTime) { |
| | | //获取endtime的三天前的时间 |
| | | LocalDate createDay= LocalDate.parse(createTime); |
| | | LocalDateTime end = createDay.atTime(LocalTime.MAX); |
| | | Date endtime=Date.from(end.atZone(ZoneId.systemDefault()).toInstant()); |
| | | //获取createTime的三天前的时间 |
| | | LocalDate threeDaysAgo = createDay.minusDays(3); |
| | | LocalDateTime startOfDay = threeDaysAgo.atStartOfDay(); |
| | | Date starttime=Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()); |
| | | |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("board_number",board); |
| | | wrapper.eq("apply_material_code",materialCode); |
| | | List<Software> softwareList = mapper.selectList(wrapper); |
| | | return new Response().setII(1,softwareList!=null,softwareList,"根据板号和物料编码查询软件记录"); |
| | | wrapper.select("distinct file_name"); |
| | | wrapper.ge("create_time",starttime); |
| | | wrapper.le("create_time",endtime); |
| | | List<Software> list=mapper.selectList(wrapper); |
| | | //获取list中fileName的集合 |
| | | List<String> nameList = list.stream().map(Software::getFileName).collect(Collectors.toList()); |
| | | return new Response().setII(1,nameList!=null,nameList,"查询日期三天内的所有上传软件名称"); |
| | | } |
| | | } |
| | |
| | | <resultMap id="softwares" type="softDto"> |
| | | <result column="file_url" property="fileUrl" /> |
| | | <result column="lock_flag" property="lockFlag"/> |
| | | <result column="file_name" property="fileName"/> |
| | | <collection property="softwares" javaType="java.util.ArrayList" ofType="com.whyc.pojo.Software" column="{fileUrl = file_url,lockFlag = lock_flag}" select="selectSoftWare"> |
| | | </collection> |
| | | </resultMap> |
| | | |
| | | <select id="getFileUrl" resultMap="softwares"> |
| | | select distinct file_url,lock_flag from tb_software |
| | | select distinct file_url,lock_flag,file_name from tb_software |
| | | <where> |
| | | 1=1 |
| | | <choose> |