From 166205878953df10dcdd1ec570ae214516fb9b02 Mon Sep 17 00:00:00 2001 From: bawei <95887577@qq.com> Date: Wed, 7 Jun 2023 14:20:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=9C=89?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TradeuploadController.java | 407 +++++++++--------- 1 file changed, 204 insertions(+), 203 deletions(-) diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/tradeupload/controller/TradeuploadController.java b/SC-boot/linkage-scm/src/main/java/jnpf/tradeupload/controller/TradeuploadController.java index 53b1b910..44c5434c 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/tradeupload/controller/TradeuploadController.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/tradeupload/controller/TradeuploadController.java @@ -76,8 +76,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * * tradeupload + * * @版本: V3.2.0 * @版权: LINKAGE-BOOT * @作者: LINKAGE-BOOT研发团队 @@ -85,7 +85,7 @@ import java.util.regex.Pattern; */ @Slf4j @RestController -@Api(tags = "tradeupload" , value = "tradeupload") +@Api(tags = "tradeupload", value = "tradeupload") @RequestMapping("/api/tradeupload/Tradeupload") public class TradeuploadController { @@ -133,7 +133,7 @@ public class TradeuploadController { @ApiOperation("上传文件/图片") @PostMapping(value = "/UploaderPondList/{type}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ActionResult uploader(@RequestPart("file") MultipartFile file, @PathVariable("type") String type) throws IOException, ParseException, DataException { - String userId=userProvider.get().getUserId(); + String userId = userProvider.get().getUserId(); String orgnize = null; if (!userProvider.get().getIsAdministrator()) { orgnize = userProvider.getOrganizeId(userId); @@ -147,7 +147,7 @@ public class TradeuploadController { String result = VatInvoice.weightNote(file); JSONObject jsonObject = JSON.parseObject(result); UploaderVO vo = uploaderVO(file, type); - JSONArray jsonArray = jsonObject.getJSONArray("words_result"); + JSONArray jsonArray = jsonObject.getJSONArray("words_result"); String TareWeight = ""; String CrossWeight = ""; String PlateNum = ""; @@ -156,7 +156,7 @@ public class TradeuploadController { String ReceivingCompany = ""; String PrintTime = ""; String NetWeight = ""; - if (jsonArray!=null && jsonArray.size()>0) { + if (jsonArray != null && jsonArray.size() > 0) { if (jsonArray.getJSONObject(0).getJSONArray("TareWeight") != null && jsonArray.getJSONObject(0).getJSONArray("TareWeight").size() > 0) { TareWeight = jsonArray.getJSONObject(0).getJSONArray("TareWeight").getJSONObject(0).getString("word"); } @@ -188,12 +188,12 @@ public class TradeuploadController { tradeuploadCrForm.setCustomerId(ReceivingCompany); QueryWrapper customerQueryWrapper = new QueryWrapper<>(); customerQueryWrapper.lambda().eq(CustomerEntity::getSupplierNm, tradeuploadCrForm.getCustomerId()); - customerQueryWrapper.lambda().eq(CustomerEntity::getOrgnizeId,orgnize); + customerQueryWrapper.lambda().eq(CustomerEntity::getOrgnizeId, orgnize); List customerEntityList = customerService.list(customerQueryWrapper); CustomerEntity customerEntity; - if(customerEntityList != null && customerEntityList.size() > 0){ + if (customerEntityList != null && customerEntityList.size() > 0) { customerEntity = customerEntityList.get(0); - }else{ + } else { customerEntity = new CustomerEntity(); } tradeuploadCrForm.setCustomerId(customerEntity.getId()); @@ -220,13 +220,13 @@ public class TradeuploadController { String detpartment = null; if (!userProvider.get().getIsAdministrator()) { detpartment = userProvider.getDepartmentId(userId); - vehicleQueryWrapper.lambda().eq(VehicleEntity::getDepartmentId,detpartment); + vehicleQueryWrapper.lambda().eq(VehicleEntity::getDepartmentId, detpartment); } List vehicleEntityList = vehicleService.list(vehicleQueryWrapper); VehicleEntity vehicleEntity; - if(vehicleEntityList != null && vehicleEntityList.size() > 0){ + if (vehicleEntityList != null && vehicleEntityList.size() > 0) { vehicleEntity = vehicleEntityList.get(0); - }else{ + } else { vehicleEntity = new VehicleEntity(); } tradeuploadCrForm.setVehicleId(vehicleEntity.getId()); @@ -234,46 +234,46 @@ public class TradeuploadController { tradeuploadCrForm.setVehiclePictures(vehicleEntity.getVehiclephotos()); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - if(StringUtils.isNotEmpty(PrintTime) && PrintTime.length() == 10){ + if (StringUtils.isNotEmpty(PrintTime) && PrintTime.length() == 10) { try { tradeuploadCrForm.setPoundDate(sdf.parse(PrintTime)); - }catch (Exception e){ + } catch (Exception e) { tradeuploadCrForm.setPoundDate(new Date()); } // tradeuploadCrForm.setPoundDate(sdf.parse(PrintTime)); - }else{ + } else { tradeuploadCrForm.setPoundDate(new Date()); } if (StringUtils.isEmpty(DeliveryNumber)) { tradeuploadCrForm.setPoundlistNo(generaterSwapUtil.getBillNumber("pd", false)); - }else { + } else { tradeuploadCrForm.setPoundlistNo(DeliveryNumber); } if (StringUtils.isNotEmpty(TareWeight)) { tradeuploadCrForm.setTareWeight(numberTransform(TareWeight)); - }else{ + } else { tradeuploadCrForm.setTareWeight("0"); } if (StringUtils.isNotEmpty(CrossWeight)) { tradeuploadCrForm.setGrossWeight(numberTransform(CrossWeight)); - }else{ + } else { tradeuploadCrForm.setGrossWeight("0"); } tradeuploadCrForm.setBuckleWeight("0"); if (StringUtils.isNotEmpty(NetWeight)) { tradeuploadCrForm.setNetWeight(numberTransform(NetWeight)); - }else{ + } else { tradeuploadCrForm.setNetWeight("0"); } float tareWeight = Float.parseFloat(tradeuploadCrForm.getTareWeight()); float grossWeight = Float.parseFloat(tradeuploadCrForm.getGrossWeight()); float buckleWeight = Float.parseFloat(tradeuploadCrForm.getBuckleWeight()); float netWeight = Float.parseFloat(tradeuploadCrForm.getNetWeight()); - if (grossWeight > (tareWeight + netWeight)){ + if (grossWeight > (tareWeight + netWeight)) { buckleWeight = grossWeight - tareWeight - netWeight; tradeuploadCrForm.setBuckleWeight(String.valueOf(buckleWeight)); } - if (grossWeight <= netWeight){ + if (grossWeight <= netWeight) { grossWeight = tareWeight + netWeight + buckleWeight; tradeuploadCrForm.setGrossWeight(String.valueOf(grossWeight)); } @@ -415,7 +415,7 @@ public class TradeuploadController { date = dateFormat.parse(printTime); return printTime.equals(dateFormat.format(date)); } catch (ParseException e) { - log.error("error{}",e.getMessage(),e); + log.error("error{}", e.getMessage(), e); return false; } } @@ -450,8 +450,8 @@ public class TradeuploadController { vo.setUrl(UploaderUtil.uploaderImg("/api/file/Image/annex/", fileName)); } else if (type.equalsIgnoreCase(FileTypeEnum.ANNEXPIC)) { vo.setUrl(UploaderUtil.uploaderImg("/api/file/Image/annex/", fileName)); - }else { - vo.setUrl(UploaderUtil.uploaderImg("/api/file/Image/"+type.toLowerCase()+"/", fileName)); + } else { + vo.setUrl(UploaderUtil.uploaderImg("/api/file/Image/" + type.toLowerCase() + "/", fileName)); } //上传到永中 @@ -472,6 +472,7 @@ public class TradeuploadController { } return vo; } + /** * 磅单识别 * @@ -480,54 +481,54 @@ public class TradeuploadController { */ @ApiOperation("磅单识别") @PostMapping("/poundai") - public ActionResult poundAI(MultipartFile file ) throws IOException { + public ActionResult poundAI(MultipartFile file) throws IOException { TradeuploadCrForm tradeuploadCrForm = new TradeuploadCrForm(); String result = VatInvoice.weightNote(file); - Map map = JsonUtil.stringToMap(result); + Map map = JsonUtil.stringToMap(result); tradeuploadCrForm.setCustomerId(String.valueOf(map.get("ReceivingCompany"))); QueryWrapper customerQueryWrapper = new QueryWrapper<>(); - customerQueryWrapper.lambda().eq(CustomerEntity::getSupplierNm,tradeuploadCrForm.getCustomerId()); + customerQueryWrapper.lambda().eq(CustomerEntity::getSupplierNm, tradeuploadCrForm.getCustomerId()); CustomerEntity customerEntity = customerService.getOne(customerQueryWrapper); tradeuploadCrForm.setClientId(customerEntity.getId()); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(ContractFileEntity::getCode,customerEntity.getId()); - queryWrapper.lambda().eq(ContractFileEntity::getContractType,"1"); - queryWrapper.lambda().eq(ContractFileEntity::getStatus,"1"); + queryWrapper.lambda().eq(ContractFileEntity::getCode, customerEntity.getId()); + queryWrapper.lambda().eq(ContractFileEntity::getContractType, "1"); + queryWrapper.lambda().eq(ContractFileEntity::getStatus, "1"); queryWrapper.lambda().orderByAsc(ContractFileEntity::getBidOpeningDate).last("limit 1"); ContractFileEntity contractFileEntity = contractFileService.getOne(queryWrapper); tradeuploadCrForm.setSalesId(contractFileEntity.getContractName()); tradeuploadCrForm.setVehicleId(String.valueOf(map.get("PlateNum"))); QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(); - vehicleQueryWrapper.lambda().eq(VehicleEntity::getTicketno,map.get("PlateNum")); + vehicleQueryWrapper.lambda().eq(VehicleEntity::getTicketno, map.get("PlateNum")); - String userId=userProvider.get().getUserId(); - vehicleQueryWrapper.lambda().eq(VehicleEntity::getTicketno,map.get("PlateNum")); + String userId = userProvider.get().getUserId(); + vehicleQueryWrapper.lambda().eq(VehicleEntity::getTicketno, map.get("PlateNum")); String detpartment = null; if (!userProvider.get().getIsAdministrator()) { detpartment = userProvider.getDepartmentId(userId); - vehicleQueryWrapper.lambda().eq(VehicleEntity::getDepartmentId,detpartment); + vehicleQueryWrapper.lambda().eq(VehicleEntity::getDepartmentId, detpartment); } VehicleEntity vehicleEntity = vehicleService.getOne(vehicleQueryWrapper); - if (vehicleEntity != null){ + if (vehicleEntity != null) { tradeuploadCrForm.setVehiclePictures(vehicleEntity.getVehiclephotos()); } - if (map.get("PrintTime") == null){ + if (map.get("PrintTime") == null) { tradeuploadCrForm.setPoundDate(new Date()); } //tradeuploadCrForm.setPoundDate(map.get("PrintTime")); - if (map.get("DeliveryNumber") == null){ + if (map.get("DeliveryNumber") == null) { tradeuploadCrForm.setPoundlistNo(String.valueOf(new Date())); } tradeuploadCrForm.setPoundlistNo(String.valueOf(map.get("DeliveryNumber"))); tradeuploadCrForm.setTareWeight(String.valueOf(map.get("TareWeight"))); tradeuploadCrForm.setGrossWeight(String.valueOf(map.get("CrossWeight"))); - if (map.get("NetWeight") == null){ + if (map.get("NetWeight") == null) { tradeuploadCrForm.setBuckleWeight("0"); } tradeuploadCrForm.setBuckleWeight(String.valueOf(map.get("NetWeight"))); - if (map.get("NetWeight") == null){ + if (map.get("NetWeight") == null) { tradeuploadCrForm.setNetWeight("0"); } tradeuploadCrForm.setNetWeight(String.valueOf(map.get("NetWeight"))); @@ -536,6 +537,7 @@ public class TradeuploadController { tradeuploadCrForm.setBusinessId(userInfo.getUserName()); return ActionResult.success(tradeuploadCrForm); } + /** * 批量审核 * @@ -544,17 +546,17 @@ public class TradeuploadController { */ @PostMapping("/batchAudit/{ids}") @Transactional - public ActionResult batchAudit(@PathVariable("ids") String ids,@RequestBody @Valid TradeuploadUpForm tradeuploadUpForm) throws DataException { + public ActionResult batchAudit(@PathVariable("ids") String ids, @RequestBody @Valid TradeuploadUpForm tradeuploadUpForm) throws DataException { String[] idList = ids.split(","); PoundlistEntity poundlistEntity = new PoundlistEntity(); poundlistEntity.setPurchaseId(tradeuploadUpForm.getPurchaseId()); poundlistEntity.setSupplierId(tradeuploadUpForm.getSupplierId()); poundlistEntity.setSupplierName(tradeuploadUpForm.getSupplierName()); poundlistEntity.setIsExamine("1"); - for (String allId : idList){ + for (String allId : idList) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.lambda().eq(PoundlistEntity::getId,allId); - poundlistMapper.update(poundlistEntity,updateWrapper); + updateWrapper.lambda().eq(PoundlistEntity::getId, allId); + poundlistMapper.update(poundlistEntity, updateWrapper); } return ActionResult.success("审核成功"); } @@ -567,10 +569,10 @@ public class TradeuploadController { * @return */ @PostMapping("/getList") - public ActionResult list(@RequestBody TradeuploadPagination tradeuploadPagination)throws IOException{ - List list= tradeuploadService.getList(tradeuploadPagination); + public ActionResult list(@RequestBody TradeuploadPagination tradeuploadPagination) throws IOException { + List list = tradeuploadService.getList(tradeuploadPagination); //处理id字段转名称,若无需转或者为空可删除 - for(TradeuploadEntity entity:list){ + for (TradeuploadEntity entity : list) { entity.setPoundPictures(generaterSwapUtil.getFileNameInJson(entity.getPoundPictures())); @@ -593,14 +595,14 @@ public class TradeuploadController { entity.setSupplierName(generaterSwapUtil.getPopupSelectValue("382494924156735557","id","supplier_name",entity.getSupplierId(),supplierIdMap));*/ entity.setOriginPlace(generaterSwapUtil.provinceData(entity.getOriginPlace())); } - List listVO=JsonUtil.getJsonToList(list,TradeuploadListVO.class); - for(TradeuploadListVO tradeuploadVO:listVO){ + List listVO = JsonUtil.getJsonToList(list, TradeuploadListVO.class); + for (TradeuploadListVO tradeuploadVO : listVO) { } - PageListVO vo=new PageListVO(); + PageListVO vo = new PageListVO(); vo.setList(listVO); - PaginationVO page=JsonUtil.getJsonToBean(tradeuploadPagination,PaginationVO.class); + PaginationVO page = JsonUtil.getJsonToBean(tradeuploadPagination, PaginationVO.class); vo.setPagination(page); return ActionResult.success(vo); } @@ -615,27 +617,26 @@ public class TradeuploadController { @PostMapping @Transactional public ActionResult create(@RequestBody @Valid TradeuploadCrForm tradeuploadCrForm) throws DataException { - String mainId =RandomUtil.uuId(); - UserInfo userInfo=userProvider.get(); + String mainId = RandomUtil.uuId(); + UserInfo userInfo = userProvider.get(); tradeuploadCrForm.setCreatorTime(DateUtil.getNow()); TradeuploadEntity entity = JsonUtil.getJsonToBean(tradeuploadCrForm, TradeuploadEntity.class); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(TradeuploadEntity::getPoundlistNo,entity.getPoundlistNo()); + queryWrapper.lambda().eq(TradeuploadEntity::getPoundlistNo, entity.getPoundlistNo()); List list = tradeuploadService.list(queryWrapper); - if (list != null && list.size()>0){ + if (list != null && list.size() > 0) { return ActionResult.fail("磅单重复"); } entity.setId(mainId); BigDecimal netWeight = new BigDecimal(tradeuploadCrForm.getNetWeight()); entity.setSettlement(netWeight); BigDecimal salesPrice = new BigDecimal(tradeuploadCrForm.getSalesPrice()); - entity.setSalesAmounts(salesPrice.multiply(netWeight).setScale(2,BigDecimal.ROUND_HALF_UP)); + entity.setSalesAmounts(salesPrice.multiply(netWeight).setScale(2, BigDecimal.ROUND_HALF_UP)); tradeuploadService.save(entity); return ActionResult.success("创建成功"); } - /** * 模板下载 * @@ -643,17 +644,18 @@ public class TradeuploadController { */ @ApiOperation("模板下载") @GetMapping("/templateDownload") - public ActionResult TemplateDownload(){ - UserInfo userInfo=userProvider.get(); - DownloadVO vo=DownloadVO.builder().build(); - try{ + public ActionResult TemplateDownload() { + UserInfo userInfo = userProvider.get(); + DownloadVO vo = DownloadVO.builder().build(); + try { vo.setName("职员信息.xlsx"); - vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=" ,userInfo.getId()+"#"+"职员信息.xlsx"+"#"+"Temporary")); - }catch(Exception e){ - log.error("信息导出Excel错误:{}" ,e.getMessage()); + vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=", userInfo.getId() + "#" + "职员信息.xlsx" + "#" + "Temporary")); + } catch (Exception e) { + log.error("信息导出Excel错误:{}", e.getMessage()); } return ActionResult.success(vo); } + /** * 导出Excel * @@ -662,126 +664,127 @@ public class TradeuploadController { @ApiOperation("导出Excel") @GetMapping("/Actions/Export") public ActionResult Export(TradeuploadPaginationExportModel tradeuploadPaginationExportModel) throws IOException { - if (StringUtil.isEmpty(tradeuploadPaginationExportModel.getSelectKey())){ + if (StringUtil.isEmpty(tradeuploadPaginationExportModel.getSelectKey())) { return ActionResult.fail("请选择导出字段"); } - TradeuploadPagination tradeuploadPagination=JsonUtil.getJsonToBean(tradeuploadPaginationExportModel, TradeuploadPagination.class); - List list= tradeuploadService.getTypeList(tradeuploadPagination,tradeuploadPaginationExportModel.getDataType()); + TradeuploadPagination tradeuploadPagination = JsonUtil.getJsonToBean(tradeuploadPaginationExportModel, TradeuploadPagination.class); + List list = tradeuploadService.getTypeList(tradeuploadPagination, tradeuploadPaginationExportModel.getDataType()); //处理id字段转名称,若无需转或者为空可删除 - for(TradeuploadEntity entity:list){ + for (TradeuploadEntity entity : list) { VehicleEntity vehicleEntity = vehicleService.getById(entity.getVehicleId()); - if (ObjectUtils.isNotEmpty(vehicleEntity)){ + if (ObjectUtils.isNotEmpty(vehicleEntity)) { entity.setVehicleName(vehicleEntity.getTicketno()); } MaterialEntity materialEntity = materialService.getById(entity.getMaterialId()); - if (ObjectUtils.isNotEmpty(materialEntity)){ + if (ObjectUtils.isNotEmpty(materialEntity)) { entity.setMaterialName(materialEntity.getItemName()); } CustomerEntity customerEntity = customerService.getById(entity.getCustomerId()); - if (ObjectUtils.isNotEmpty(customerEntity)){ + if (ObjectUtils.isNotEmpty(customerEntity)) { entity.setCustomerName(customerEntity.getSupplierNm()); } ContractFileEntity contractFileEntity = contractFileService.getById(entity.getSalesId()); - if (ObjectUtils.isNotEmpty(contractFileEntity)){ + if (ObjectUtils.isNotEmpty(contractFileEntity)) { entity.setSalesName(contractFileEntity.getContractName()); } entity.setPoundPictures(generaterSwapUtil.getFileNameInJson(entity.getPoundPictures())); entity.setVehiclePictures(generaterSwapUtil.getFileNameInJson(entity.getVehiclePictures())); entity.setAdvance("0".equals(entity.getAdvance()) ? "否" : "是"); - if("0".equals(entity.getTransportType())){ + if ("0".equals(entity.getTransportType())) { entity.setTransportType("汽运"); - }else if("1".equals(entity.getTransportType())){ + } else if ("1".equals(entity.getTransportType())) { entity.setTransportType("船运"); - }else if("2".equals(entity.getTransportType())){ + } else if ("2".equals(entity.getTransportType())) { entity.setTransportType("火车"); } } - List listVO=JsonUtil.getJsonToList(list,TradeuploadListVO.class); - for(TradeuploadListVO tradeuploadVO:listVO){ + List listVO = JsonUtil.getJsonToList(list, TradeuploadListVO.class); + for (TradeuploadListVO tradeuploadVO : listVO) { } //转换为map输出 - List>mapList=JsonUtil.getJsonToListMap(JsonUtil.getObjectToStringDateFormat(listVO,"yyyy-MM-dd HH:mm:ss")); - String[]keys=!StringUtil.isEmpty(tradeuploadPaginationExportModel.getSelectKey())?tradeuploadPaginationExportModel.getSelectKey().split(","):new String[0]; - UserInfo userInfo=userProvider.get(); - DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),mapList,keys,userInfo); + List> mapList = JsonUtil.getJsonToListMap(JsonUtil.getObjectToStringDateFormat(listVO, "yyyy-MM-dd HH:mm:ss")); + String[] keys = !StringUtil.isEmpty(tradeuploadPaginationExportModel.getSelectKey()) ? tradeuploadPaginationExportModel.getSelectKey().split(",") : new String[0]; + UserInfo userInfo = userProvider.get(); + DownloadVO vo = this.creatModelExcel(configValueUtil.getTemporaryFilePath(), mapList, keys, userInfo); return ActionResult.success(vo); } + //导出表格 - public DownloadVO creatModelExcel(String path,List>list,String[]keys,UserInfo userInfo){ - DownloadVO vo=DownloadVO.builder().build(); - List entitys=new ArrayList<>(); - if(keys.length>0){ - for(String key:keys){ - switch(key){ - case "poundPictures" : - entitys.add(new ExcelExportEntity("磅单图片" ,"poundPictures")); + public DownloadVO creatModelExcel(String path, List> list, String[] keys, UserInfo userInfo) { + DownloadVO vo = DownloadVO.builder().build(); + List entitys = new ArrayList<>(); + if (keys.length > 0) { + for (String key : keys) { + switch (key) { + case "poundPictures": + entitys.add(new ExcelExportEntity("磅单图片", "poundPictures")); break; - case "materialName" : - entitys.add(new ExcelExportEntity("物料名称" ,"materialName")); + case "materialName": + entitys.add(new ExcelExportEntity("物料名称", "materialName")); break; - case "customerName" : - entitys.add(new ExcelExportEntity("客户名称" ,"customerName")); + case "customerName": + entitys.add(new ExcelExportEntity("客户名称", "customerName")); break; - case "salesName" : - entitys.add(new ExcelExportEntity("销售合同" ,"salesName")); + case "salesName": + entitys.add(new ExcelExportEntity("销售合同", "salesName")); break; - case "vehicleName" : - entitys.add(new ExcelExportEntity("车牌号" ,"vehicleName")); + case "vehicleName": + entitys.add(new ExcelExportEntity("车牌号", "vehicleName")); break; - case "vehiclePictures" : - entitys.add(new ExcelExportEntity("车辆图片" ,"vehiclePictures")); + case "vehiclePictures": + entitys.add(new ExcelExportEntity("车辆图片", "vehiclePictures")); break; - case "poundDate" : - entitys.add(new ExcelExportEntity("磅单日期" ,"poundDate")); + case "poundDate": + entitys.add(new ExcelExportEntity("磅单日期", "poundDate")); break; - case "poundlistNo" : - entitys.add(new ExcelExportEntity("磅单号" ,"poundlistNo")); + case "poundlistNo": + entitys.add(new ExcelExportEntity("磅单号", "poundlistNo")); break; - case "tareWeight" : - entitys.add(new ExcelExportEntity("皮重" ,"tareWeight")); + case "tareWeight": + entitys.add(new ExcelExportEntity("皮重", "tareWeight")); break; - case "grossWeight" : - entitys.add(new ExcelExportEntity("毛重" ,"grossWeight")); + case "grossWeight": + entitys.add(new ExcelExportEntity("毛重", "grossWeight")); break; - case "buckleWeight" : - entitys.add(new ExcelExportEntity("扣重" ,"buckleWeight")); + case "buckleWeight": + entitys.add(new ExcelExportEntity("扣重", "buckleWeight")); break; - case "netWeight" : - entitys.add(new ExcelExportEntity("净重" ,"netWeight")); + case "netWeight": + entitys.add(new ExcelExportEntity("净重", "netWeight")); break; - case "unit" : - entitys.add(new ExcelExportEntity("单位 " ,"unit")); + case "unit": + entitys.add(new ExcelExportEntity("单位 ", "unit")); break; - case "originPlace" : - entitys.add(new ExcelExportEntity("起始地" ,"originPlace")); + case "originPlace": + entitys.add(new ExcelExportEntity("起始地", "originPlace")); break; - case "transportType" : - entitys.add(new ExcelExportEntity("运输类型" ,"transportType")); + case "transportType": + entitys.add(new ExcelExportEntity("运输类型", "transportType")); break; - case "advance" : - entitys.add(new ExcelExportEntity("是否垫资" ,"advance")); + case "advance": + entitys.add(new ExcelExportEntity("是否垫资", "advance")); break; - case "transportPrice" : - entitys.add(new ExcelExportEntity("运费" ,"transportPrice")); + case "transportPrice": + entitys.add(new ExcelExportEntity("运费", "transportPrice")); break; - case "salesPrice" : - entitys.add(new ExcelExportEntity("销售价格" ,"salesPrice")); + case "salesPrice": + entitys.add(new ExcelExportEntity("销售价格", "salesPrice")); break; - case "collectPrice" : - entitys.add(new ExcelExportEntity("收货价格" ,"collectPrice")); + case "collectPrice": + entitys.add(new ExcelExportEntity("收货价格", "collectPrice")); break; - case "businessName" : - entitys.add(new ExcelExportEntity("业务员" ,"businessName")); + case "businessName": + entitys.add(new ExcelExportEntity("业务员", "businessName")); break; - case "naturalName" : - entitys.add(new ExcelExportEntity("自然人" ,"naturalName")); + case "naturalName": + entitys.add(new ExcelExportEntity("自然人", "naturalName")); break; - case "remark" : - entitys.add(new ExcelExportEntity("备注" ,"remark")); + case "remark": + entitys.add(new ExcelExportEntity("备注", "remark")); break; - case "creatorTime" : - entitys.add(new ExcelExportEntity("磅单日期" ,"creatorTime")); + case "creatorTime": + entitys.add(new ExcelExportEntity("磅单日期", "creatorTime")); break; default: break; @@ -791,9 +794,9 @@ public class TradeuploadController { ExportParams exportParams = new ExportParams(null, "FormMessage"); exportParams.setType(ExcelType.XSSF); - try{ + try { @Cleanup Workbook workbook = new HSSFWorkbook(); - if (entitys.size()>0){ + if (entitys.size() > 0) { workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list); } String name = "FormMessage" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx"; @@ -822,14 +825,14 @@ public class TradeuploadController { */ @DeleteMapping("/batchRemove/{ids}") @Transactional - public ActionResult batchRemove(@PathVariable("ids") String ids){ + public ActionResult batchRemove(@PathVariable("ids") String ids) { String[] idList = ids.split(","); - int i =0; - for (String allId : idList){ + int i = 0; + for (String allId : idList) { this.delete(allId); i++; } - if (i == 0 ){ + if (i == 0) { return ActionResult.fail("删除失败"); } return ActionResult.success("删除成功"); @@ -843,58 +846,58 @@ public class TradeuploadController { * @return */ @GetMapping("/{id}") - public ActionResult info(@PathVariable("id") String id){ - TradeuploadEntity entity= tradeuploadService.getInfo(id); + public ActionResult info(@PathVariable("id") String id) { + TradeuploadEntity entity = tradeuploadService.getInfo(id); - TradeuploadInfoVO vo=JsonUtil.getJsonToBean(entity, TradeuploadInfoVO.class); - if(vo.getCreatorTime()!=null){ + TradeuploadInfoVO vo = JsonUtil.getJsonToBean(entity, TradeuploadInfoVO.class); + if (vo.getCreatorTime() != null) { vo.setCreatorTime(vo.getCreatorTime()); } - if(StringUtils.isNotBlank(vo.getMaterialId())){ + if (StringUtils.isNotBlank(vo.getMaterialId())) { MaterialEntity materialEntity = materialService.getById(vo.getMaterialId()); - if(materialEntity != null){ + if (materialEntity != null) { vo.setMaterialName(materialEntity.getItemName()); } } - if(StringUtils.isNotBlank(vo.getCustomerId())){ + if (StringUtils.isNotBlank(vo.getCustomerId())) { CustomerEntity customerEntity = customerService.getById(vo.getCustomerId()); - if(customerEntity != null){ + if (customerEntity != null) { vo.setCustomerName(customerEntity.getSupplierNm()); } } - if(StringUtils.isNotBlank(vo.getCustomerId())){ + if (StringUtils.isNotBlank(vo.getCustomerId())) { ContractFileEntity contractFileEntity = contractFileService.getById(vo.getSalesId()); - if(contractFileEntity != null){ + if (contractFileEntity != null) { vo.setSalesName(contractFileEntity.getContractName()); } } - if(StringUtils.isNotBlank(vo.getVehicleId())){ + if (StringUtils.isNotBlank(vo.getVehicleId())) { VehicleEntity vehicleEntity = vehicleService.getById(vo.getVehicleId()); - if(vehicleEntity != null){ + if (vehicleEntity != null) { vo.setVehicleName(vehicleEntity.getTicketno()); } } - if(StringUtils.isNotBlank(vo.getNaturalId())){ + if (StringUtils.isNotBlank(vo.getNaturalId())) { Jg_naturalEntity naturalEntity = naturalService.getById(vo.getNaturalId()); - if(naturalEntity != null){ + if (naturalEntity != null) { vo.setNaturalName(naturalEntity.getName()); } } - if(StringUtils.isNotBlank(vo.getPurchaseId())){ + if (StringUtils.isNotBlank(vo.getPurchaseId())) { ContractFileEntity contractFileEntity = contractFileService.getById(vo.getPurchaseId()); - if(contractFileEntity != null){ + if (contractFileEntity != null) { vo.setPurchaseName(contractFileEntity.getContractName()); } } - if(StringUtils.isNotBlank(vo.getSupplierId())){ + if (StringUtils.isNotBlank(vo.getSupplierId())) { SupplierEntity supplierEntity = supplierService.getById(vo.getSupplierId()); - if(supplierEntity != null){ + if (supplierEntity != null) { vo.setSupplierName(supplierEntity.getSupplierName()); } } - if(StringUtils.isNotBlank(vo.getPurchaseorderId())){ + if (StringUtils.isNotBlank(vo.getPurchaseorderId())) { PurchaseorderEntity purchaseorderEntity = purchaseorderService.getById(vo.getPurchaseorderId()); - if(purchaseorderEntity != null){ + if (purchaseorderEntity != null) { vo.setIsPayment(purchaseorderEntity.getIsPayment()); } } @@ -911,9 +914,9 @@ public class TradeuploadController { * @return */ @GetMapping("/detail/{id}") - public ActionResult detailInfo(@PathVariable("id") String id){ - TradeuploadEntity entity= tradeuploadService.getInfo(id); - TradeuploadInfoVO vo=JsonUtil.getJsonToBean(entity, TradeuploadInfoVO.class); + public ActionResult detailInfo(@PathVariable("id") String id) { + TradeuploadEntity entity = tradeuploadService.getInfo(id); + TradeuploadInfoVO vo = JsonUtil.getJsonToBean(entity, TradeuploadInfoVO.class); //子表数据转换 @@ -921,28 +924,26 @@ public class TradeuploadController { //添加到详情表单对象中 vo.setPoundPictures(generaterSwapUtil.getFileNameInJson(vo.getPoundPictures())); - Map materialIdMap = new HashMap<>(); - vo.setMaterialId(generaterSwapUtil.getPopupSelectValue("381037852907038533","id","item_name",vo.getMaterialId(),materialIdMap)); - Map customerIdMap = new HashMap<>(); - vo.setCustomerId(generaterSwapUtil.getPopupSelectValue("395936123471343749","id","supplier_nm",vo.getCustomerId(),customerIdMap)); - Map salesIdMap = new HashMap<>(); - vo.setSalesId(generaterSwapUtil.getPopupSelectValue("381037852907038533","id","contract_name",vo.getSalesId(),salesIdMap)); - Map vehicleIdMap = new HashMap<>(); - vo.setVehicleId(generaterSwapUtil.getPopupSelectValue("381432451370615173","id","ticketno",vo.getVehicleId(),vehicleIdMap)); + Map materialIdMap = new HashMap<>(); + vo.setMaterialId(generaterSwapUtil.getPopupSelectValue("381037852907038533", "id", "item_name", vo.getMaterialId(), materialIdMap)); + Map customerIdMap = new HashMap<>(); + vo.setCustomerId(generaterSwapUtil.getPopupSelectValue("395936123471343749", "id", "supplier_nm", vo.getCustomerId(), customerIdMap)); + Map salesIdMap = new HashMap<>(); + vo.setSalesId(generaterSwapUtil.getPopupSelectValue("381037852907038533", "id", "contract_name", vo.getSalesId(), salesIdMap)); + Map vehicleIdMap = new HashMap<>(); + vo.setVehicleId(generaterSwapUtil.getPopupSelectValue("381432451370615173", "id", "ticketno", vo.getVehicleId(), vehicleIdMap)); vo.setVehiclePictures(generaterSwapUtil.getFileNameInJson(vo.getVehiclePictures())); - Map businessIdMap = new HashMap<>(); - vo.setBusinessId(generaterSwapUtil.getPopupSelectValue("ebcc44be142e43b795c0d769abd6d25a","F_Id","F_RealName",vo.getBusinessId(),businessIdMap)); - Map naturalIdMap = new HashMap<>(); - vo.setNaturalId(generaterSwapUtil.getPopupSelectValue("395933800510599301","id","name",vo.getNaturalId(),naturalIdMap)); - Map purchaseIdMap = new HashMap<>(); - entity.setPurchaseId(generaterSwapUtil.getPopupSelectValue("397408984857931205","id","document_no",entity.getPurchaseId(),purchaseIdMap)); + Map businessIdMap = new HashMap<>(); + vo.setBusinessId(generaterSwapUtil.getPopupSelectValue("ebcc44be142e43b795c0d769abd6d25a", "F_Id", "F_RealName", vo.getBusinessId(), businessIdMap)); + Map naturalIdMap = new HashMap<>(); + vo.setNaturalId(generaterSwapUtil.getPopupSelectValue("395933800510599301", "id", "name", vo.getNaturalId(), naturalIdMap)); + Map purchaseIdMap = new HashMap<>(); + entity.setPurchaseId(generaterSwapUtil.getPopupSelectValue("397408984857931205", "id", "document_no", entity.getPurchaseId(), purchaseIdMap)); vo.setOriginPlace(generaterSwapUtil.provinceData(vo.getOriginPlace())); return ActionResult.success(vo); } - - /** * 更新 * @@ -951,11 +952,11 @@ public class TradeuploadController { */ @PutMapping("/{id}") @Transactional - public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid TradeuploadUpForm tradeuploadUpForm) throws DataException { - UserInfo userInfo=userProvider.get(); - TradeuploadEntity entity= tradeuploadService.getInfo(id); - if(entity!=null){ - TradeuploadEntity subentity=JsonUtil.getJsonToBean(tradeuploadUpForm, TradeuploadEntity.class); + public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid TradeuploadUpForm tradeuploadUpForm) throws DataException { + UserInfo userInfo = userProvider.get(); + TradeuploadEntity entity = tradeuploadService.getInfo(id); + if (entity != null) { + TradeuploadEntity subentity = JsonUtil.getJsonToBean(tradeuploadUpForm, TradeuploadEntity.class); subentity.setCreatorTime(entity.getCreatorTime()); BigDecimal netWeight = new BigDecimal(tradeuploadUpForm.getNetWeight()); BigDecimal salesPrice = new BigDecimal(tradeuploadUpForm.getSalesPrice()); @@ -964,38 +965,38 @@ public class TradeuploadController { subentity.setSalesAmounts(salesPrice.multiply(netWeight).setScale(2, BigDecimal.ROUND_HALF_UP)); subentity.setPurchaseAmounts(purchasePrice.multiply(netWeight).setScale(2, BigDecimal.ROUND_HALF_UP)); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(TradeuploadEntity::getPoundlistNo,entity.getPoundlistNo()); + queryWrapper.lambda().eq(TradeuploadEntity::getPoundlistNo, entity.getPoundlistNo()); List list = tradeuploadService.list(queryWrapper); - if (list != null && list.size()>0 && !ObjectUtil.equal(id, list.get(0).getId())){ + if (list != null && list.size() > 0 && !ObjectUtil.equal(id, list.get(0).getId())) { return ActionResult.fail("磅单重复"); } - if (list.size()>0 && entity.getPurchaseorderId()!=null){ + if (list.size() > 0 && entity.getPurchaseorderId() != null) { QueryWrapper PurchaseorderqueryWrapper = new QueryWrapper<>(); - PurchaseorderqueryWrapper.lambda().eq(PurchaseorderEntity::getId,entity.getPurchaseorderId()); + PurchaseorderqueryWrapper.lambda().eq(PurchaseorderEntity::getId, entity.getPurchaseorderId()); List Pur = purchaseorderService.list(PurchaseorderqueryWrapper); - int s=Integer.valueOf(Pur.get(0).getIsPayment()); - if (list !=null && list.get(0).getPurchaseorderId()!=null && s==1){ - - int s21=Integer.valueOf(tradeuploadUpForm.getCustomerId()); - int s22=Integer.valueOf(list.get(0).getCustomerId()); - if (s21==s22){ - tradeuploadService.update(id, subentity); - return ActionResult.success("更新成功"); - }else if (s21!=s22){ - return ActionResult.fail("提了付款申请不能修改客户"); + if (Pur.size() > 0) { + int s = Integer.valueOf(Pur.get(0).getIsPayment()); + if (list != null && list.get(0).getPurchaseorderId() != null && s == 1) { + int s21 = Integer.valueOf(tradeuploadUpForm.getCustomerId()); + int s22 = Integer.valueOf(list.get(0).getCustomerId()); + if (s21 == s22) { + tradeuploadService.update(id, subentity); + return ActionResult.success("更新成功"); + } else if (s21 != s22) { + return ActionResult.fail("提了付款申请不能修改客户"); + } } } } tradeuploadService.update(id, subentity); return ActionResult.success("更新成功"); - }else{ + } else { return ActionResult.fail("更新失败,数据不存在"); } } - /** * 删除 * @@ -1004,20 +1005,20 @@ public class TradeuploadController { */ @DeleteMapping("/{id}") @Transactional - public ActionResult delete(@PathVariable("id") String id){ - TradeuploadEntity entity= tradeuploadService.getInfo(id); - if(entity!=null){ + public ActionResult delete(@PathVariable("id") String id) { + TradeuploadEntity entity = tradeuploadService.getInfo(id); + if (entity != null) { tradeuploadService.delete(entity); } return ActionResult.success("删除成功"); } - public String numberTransform(String str){ + public String numberTransform(String str) { List list = new ArrayList<>(); // 声明正则,匹配数字(1个或多个).数字(1个或多个) String regex = "\\d+"; - if(str.indexOf(".") > 0){ + if (str.indexOf(".") > 0) { regex = "\\d+\\.+\\d+"; } //String regex = "\\d+\\.+\\d+"; @@ -1031,7 +1032,7 @@ public class TradeuploadController { String group = matcher.group(); list.add(group); } - if(list.size() == 0){ + if (list.size() == 0) { return "0"; } return list.get(0);