From 06c02c5e24462dc1fcbe34c5e70b2c764d9ac4e2 Mon Sep 17 00:00:00 2001 From: haozq <1611483981@qq.com> Date: Wed, 13 Nov 2024 13:23:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=20bast64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bases/controller/PartApplyController.java | 1 - .../bases/controller/PartInputController.java | 4 ++-- .../business/bases/entity/PartInputVo.java | 15 ++++++++++++ .../bases/mapper/PartInputMapper.java | 2 +- .../bases/service/PartInputServiceImpl.java | 19 +++++++-------- .../business/utils/FileUploadService.java | 8 +++---- .../manager/common/config/WebMvcConfig.java | 2 +- src/main/resources/application.yml | 4 ++-- .../mappers/bases/PartInputMapper.xml | 24 ++++++++++++------- 9 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java index 8c671c2..ed3797a 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartApplyController.java @@ -72,7 +72,6 @@ public class PartApplyController { - /** * 图片文件上传 * @return diff --git a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java index 887720d..682f71f 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/controller/PartInputController.java @@ -50,7 +50,7 @@ public class PartInputController { * @return */ @PostMapping("addInputData") - public ServerResponse addInputData(HttpServletRequest request, @RequestParam("file[]") MultipartFile[] files) { + public ServerResponse addInputData(HttpServletRequest request, @RequestParam(value = "file[]",required = false) MultipartFile[] files) { return service.addInputData(request,files); } @@ -61,7 +61,7 @@ public class PartInputController { * @return */ @PostMapping("updateInputData") - public ServerResponse updateInputData(HttpServletRequest request, @RequestParam("file[]") MultipartFile[] files) { + public ServerResponse updateInputData(HttpServletRequest request, @RequestParam(value = "file[]",required = false) MultipartFile[] files) { return service.updateInputData(request,files); } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java index 073745f..5caf49a 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/entity/PartInputVo.java @@ -91,5 +91,20 @@ public class PartInputVo { * 文件上传 集合 */ private List fileList; + /** + * + */ + private String type; + /** + * + */ + private String name; + /** + * + */ + private String model; + + + } diff --git a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java index f72c5b1..3ad878d 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/mapper/PartInputMapper.java @@ -76,7 +76,7 @@ public interface PartInputMapper { * 修改 入库信息 * @param list */ - int uploadDetails(List list); + int uploadDetails(PartInputDetails data); /** * 更新1数据 diff --git a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java index 521b10d..32c13fd 100644 --- a/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java +++ b/src/main/java/com/bonus/gzgqj/business/bases/service/PartInputServiceImpl.java @@ -48,10 +48,6 @@ public class PartInputServiceImpl implements PartInputService{ public List findByPage(PartInputVo data) { List list=new ArrayList<>(); try{ - if(StringHelper.isNotEmpty(data.getInputDay())){ - data.setStartDay(data.getInputDay().split(" ~ ")[0]); - data.setEndDay(data.getInputDay().split(" ~ ")[1]); - } list=mapper.findByPage(data); }catch (Exception e){ @@ -177,20 +173,23 @@ public class PartInputServiceImpl implements PartInputService{ detail.setTotalPrice(totalPrice.toString()); }); //修改详情 - int num2= mapper.uploadDetails(list); + int num2=0; + for (int i = 0; i { //更新 -及平准单价 // String pzPrice=mapper.getPzPrice(detail); - mapper.updateTypeNum2(detail.getPartId(),detail.getPartPrice()); }); } } //文件上传 - if(files!=null || files.length>0){ + if(files!=null && files.length>0){ List fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input",null); if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){ return ServerResponse.createErroe("入库失败"); @@ -198,18 +197,18 @@ public class PartInputServiceImpl implements PartInputService{ } List childerList=mapper.getInputDetailList(vo); AtomicReference isFlag= new AtomicReference<>("1"); - BigDecimal allPrice = new BigDecimal("0"); + final BigDecimal[] allPrice = {new BigDecimal("0")}; childerList.forEach(data->{ BigDecimal price = new BigDecimal(data.getPartPrice()); BigDecimal num = new BigDecimal(data.getInputNum()); BigDecimal totalPrice = price.multiply(num); - allPrice.add(totalPrice); + allPrice[0] = allPrice[0].add(totalPrice); if("0".equals(data.getPartPrice())){ isFlag.set("0"); } }); vo.setIsFlag(isFlag.get()); - vo.setAllPrice(allPrice.toString()); + vo.setAllPrice(allPrice[0].toString()); int num3= mapper.updateInputData(vo); if(num3>0){ return ServerResponse.createSuccess("修改成功","修改成功"); diff --git a/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java b/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java index 1636095..99e0e57 100644 --- a/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java +++ b/src/main/java/com/bonus/gzgqj/business/utils/FileUploadService.java @@ -42,11 +42,11 @@ public class FileUploadService { try { for (String bast64 : files) { String fileName=IDUtils.createID()+".png"; - String filePath= DateTimeHelper.getNowYMD()+"/"+ fileName; + String filePath= "/"+DateTimeHelper.getNowYMD()+"/"+ fileName; String newPath= SystemUtils.getUploadPath()+filePath; // 解码Base64字符串 byte[] decodedBytes = Base64.getDecoder().decode(bast64); - try (FileOutputStream fileOutputStream = new FileOutputStream(filePath)) { + try (FileOutputStream fileOutputStream = new FileOutputStream(newPath)) { // 将字节写入文件 fileOutputStream.write(decodedBytes); } catch (IOException e) { @@ -54,7 +54,7 @@ public class FileUploadService { } FileUploadVo vo=new FileUploadVo(); vo.setFileName(fileName); - vo.setFileUrl(newPath); + vo.setFileUrl(filePath); vo.setOwnId(outId); vo.setModelTable(table); vo.setSuffix(".png"); @@ -86,7 +86,7 @@ public class FileUploadService { for (MultipartFile file : files) { String fileName = file.getOriginalFilename(); String suffix=IDUtils.getSuffix(fileName); - String path= DateTimeHelper.getNowYMD()+"/"+ IDUtils.createID()+suffix; + String path="/"+DateTimeHelper.getNowYMD()+"/"+ IDUtils.createID()+suffix; String newPath= SystemUtils.getUploadPath()+path; File uploadFile = new File(newPath); //生成文件夹 diff --git a/src/main/java/com/bonus/gzgqj/manager/common/config/WebMvcConfig.java b/src/main/java/com/bonus/gzgqj/manager/common/config/WebMvcConfig.java index 40dd5a6..e8eb43b 100644 --- a/src/main/java/com/bonus/gzgqj/manager/common/config/WebMvcConfig.java +++ b/src/main/java/com/bonus/gzgqj/manager/common/config/WebMvcConfig.java @@ -39,7 +39,7 @@ public class WebMvcConfig implements WebMvcConfigurer { String filePath= SystemUtils.getUploadPath();//获取文件上传路径 /** 本地文件上传路径 */ registry.addResourceHandler("/statics/**") - .addResourceLocations("file:" + filePath); + .addResourceLocations("file:" + filePath+"/"); registry.addResourceHandler("/files/**") .addResourceLocations("file:"+filePath); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 267f338..6c33e7f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -40,8 +40,8 @@ zhly: file: upload_path: - windows: D://files/zg_gqj/ - linux: /home/zg_gqj/files/ + windows: D://files/zg_gqj + linux: /home/zg_gqj/files diff --git a/src/main/resources/mappers/bases/PartInputMapper.xml b/src/main/resources/mappers/bases/PartInputMapper.xml index bac9424..f4ca1d3 100644 --- a/src/main/resources/mappers/bases/PartInputMapper.xml +++ b/src/main/resources/mappers/bases/PartInputMapper.xml @@ -29,11 +29,9 @@ - - update t_part_put_details set part_price=#{item.partPrice}, vender_id=#{item.vendId}, - total_price=#{item.totalPrice}, set vender_name=#{item.vendName} - where id=#{item.id} - + update t_part_put_details set part_price=#{partPrice}, vender_id=#{vendId}, + total_price=#{totalPrice},vender_name=#{vendName} + where id=#{id} update t_part_input set updater=#{updater},update_time=now(),all_price=#{allPrice}, @@ -49,15 +47,16 @@ and (tpi.code like concat('%',#{keyWord},'%') or - tpi.creator like concat('%',#{keyWord},'%') or + tpi.input_user like concat('%',#{keyWord},'%') or tpi.input_day like concat('%',#{keyWord},'%') or tpi.remark like concat('%',#{keyWord},'%') ) - + and STR_TO_DATE(tpi.input_day, '%Y-%m-%d') between STR_TO_DATE(#{startDay} ,'%Y-%m-%d') AND STR_TO_DATE(#{endDay},'%Y-%m-%d') + order by tpi.create_time desc