diff --git a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouse.java b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouse.java index b9070da8..a40f3ec8 100644 --- a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouse.java +++ b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouse.java @@ -94,5 +94,8 @@ public class ShStorehouse extends BaseEntity { private String linkerPhone; // 联系人电话 @ApiModelProperty("图片访问url") private String picUrl; // 图片访问url - + @ApiModelProperty("精度") + private String lon; + @ApiModelProperty("维度") + private String lat; } diff --git a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDetailsVo.java b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDetailsVo.java index 1266f627..667cdcd0 100644 --- a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDetailsVo.java +++ b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDetailsVo.java @@ -26,12 +26,15 @@ package com.wh.pojo.shstorehouse; +import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentVo; import com.yxt.common.core.vo.Vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * Project: yxt_supervise(宇信通监管)
* File: ShStorehouseVo.java
@@ -95,5 +98,10 @@ public class ShStorehouseDetailsVo implements Vo { private String linkerPhone; // 联系人电话 @ApiModelProperty("图片访问url") private String picUrl; // 图片访问url - + @ApiModelProperty("图片集合") + private List pics; + @ApiModelProperty("精度") + private String lon; + @ApiModelProperty("维度") + private String lat; } \ No newline at end of file diff --git a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDto.java b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDto.java index a21fa854..64bd2b0c 100644 --- a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDto.java +++ b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseDto.java @@ -33,6 +33,9 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * Project: yxt_supervise(宇信通监管)
* File: ShStorehouseDto.java
@@ -96,4 +99,10 @@ public class ShStorehouseDto implements Dto { private String linkerPhone; // 联系人电话 @ApiModelProperty("图片访问url") private String picUrl; // 图片访问url + @ApiModelProperty("图片的集合") + private List pics=new ArrayList<>(); + @ApiModelProperty("精度") + private String lon; + @ApiModelProperty("维度") + private String lat; } \ No newline at end of file diff --git a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseQuery.java b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseQuery.java index 0202131f..a8ea3c9e 100644 --- a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseQuery.java +++ b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseQuery.java @@ -93,5 +93,8 @@ public class ShStorehouseQuery implements Query { private String linkerPhone; // 联系人电话 @ApiModelProperty("图片访问url") private String picUrl; // 图片访问url - + @ApiModelProperty("精度") + private String lon; + @ApiModelProperty("维度") + private String lat; } diff --git a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseVo.java b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseVo.java index 6f945ab5..fa8eb5cd 100644 --- a/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseVo.java +++ b/warehousing-system/project/wh-common/src/main/java/com/wh/pojo/shstorehouse/ShStorehouseVo.java @@ -95,5 +95,8 @@ public class ShStorehouseVo implements Vo { private String linkerPhone; // 联系人电话 @ApiModelProperty("图片访问url") private String picUrl; // 图片访问url - + @ApiModelProperty("精度") + private String lon; + @ApiModelProperty("维度") + private String lat; } diff --git a/warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java b/warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java index 0d8c68ac..f128c11c 100644 --- a/warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java +++ b/warehousing-system/project/wh-manage/src/main/java/com/wh/controller/shstorehouse/ShStorehouseRest.java @@ -29,11 +29,14 @@ import cn.hutool.core.lang.Assert; import com.wh.feign.enterpriseinformation.WhEnterpriseInformationFeign; import com.wh.feign.enterpriseinformation.WhEnterpriseInformationVo; import com.wh.pojo.shstorehouse.*; +import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentDto; import com.wh.service.shstorehouse.ShStorehouseService; +import com.wh.service.shstorehouseattachment.ShStorehouseAttachmentService; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -43,6 +46,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.util.List; +import java.util.UUID; /** * Project: yxt_supervise(宇信通监管)
@@ -66,6 +70,8 @@ public class ShStorehouseRest { @Autowired private ShStorehouseService shStorehouseService; @Autowired + private ShStorehouseAttachmentService shStorehouseAttachmentService; + @Autowired private WhEnterpriseInformationFeign whEnterpriseInformationFeign; @ApiOperation("根据条件分页查询数据的列表") @PostMapping("/listPage") @@ -147,6 +153,42 @@ public class ShStorehouseRest { } return ResultBean.fireSuccess().setData(urlPath); } + @ApiOperation("图片上传") + @PostMapping("/uploadPics") + public ResultBean uploadPics(@RequestParam("file") MultipartFile file, HttpServletRequest request) { + String filePath = ""; // 文件保存的位置 + String urlPath = "";// 文件web浏览路径 + Assert.isTrue(!file.isEmpty(), "文件为空"); + // 原始名 以 a.jpg为例 + String originalFilename = file.getOriginalFilename(); + // 获取后缀并拼接'/'用于分类,也可以用日期 例: suffix = "jpg/" + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1) + "/"; + // 加上时间戳生成新的文件名,防止重复 newFileName = "1595511980146a.jpg" + String newFileName = System.currentTimeMillis() + originalFilename; + filePath = fileRootPath+ suffix + newFileName; + System.out.println(filePath); + String s = UUID.randomUUID().toString(); + try { + File file1 = new File(filePath); + if (!file1.exists()) file1.mkdirs(); // 要是目录不存在,创建一个 + file.transferTo(file1); // 保存起来 + urlPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/archive/" + suffix + newFileName; + ShStorehouseAttachmentDto dto=new ShStorehouseAttachmentDto(); +// dto.setStorehouseSid(); // 库房sid +// dto.setStorehouseName(); // 库房名称 + dto.setFileName(newFileName); // 文件名称 + dto.setFileDesc(""); // 文件描述 + dto.setFileType(suffix); // 文件类型,Word,Excel,PDF或图片 + dto.setFileSuffix(suffix); // 文件后缀,如:png,jpg,xls,xlsx + dto.setFilePath(filePath); // 文件在服务器的存放路径 + dto.setFileUrl(urlPath); // 文件获取的url地址 + dto.setSid(s); + shStorehouseAttachmentService.insertByDto(dto); + } catch (Exception e) { + e.printStackTrace(); + } + return ResultBean.fireSuccess().setData(s); + } @ApiOperation("获取所有的企业信息") @GetMapping("/fetchEntList") public ResultBean> fetchDetailsBySid(){ diff --git a/warehousing-system/project/wh-manage/src/main/java/com/wh/mapper/shstorehouseattachment/ShStorehouseAttachmentMapper.java b/warehousing-system/project/wh-manage/src/main/java/com/wh/mapper/shstorehouseattachment/ShStorehouseAttachmentMapper.java index 7f9be86c..61351b66 100644 --- a/warehousing-system/project/wh-manage/src/main/java/com/wh/mapper/shstorehouseattachment/ShStorehouseAttachmentMapper.java +++ b/warehousing-system/project/wh-manage/src/main/java/com/wh/mapper/shstorehouseattachment/ShStorehouseAttachmentMapper.java @@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachment; import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentVo; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -62,4 +63,6 @@ public interface ShStorehouseAttachmentMapper extends BaseMapper selectListVo(); + @Delete("delete from sh_storehouse_attachment where storehouse_sid=#{shsid}") + void deleteByHouseSid(@Param("shsid") String dtoSid); } \ No newline at end of file diff --git a/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouse/ShStorehouseService.java b/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouse/ShStorehouseService.java index 15e0cba8..574b66d0 100644 --- a/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouse/ShStorehouseService.java +++ b/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouse/ShStorehouseService.java @@ -30,6 +30,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.wh.mapper.shstorehouse.ShStorehouseMapper; import com.wh.pojo.shstorehouse.*; +import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentDetailsVo; +import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentDto; +import com.wh.pojo.shstorehouseattachment.ShStorehouseAttachmentVo; +import com.wh.service.shstorehouseattachment.ShStorehouseAttachmentService; import com.yxt.common.base.config.component.FileUploadComponent; import com.yxt.common.base.config.component.ImageUploadUtil; import com.yxt.common.core.result.FileUploadResult; @@ -42,6 +46,7 @@ import com.yxt.common.core.vo.PagerVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.File; @@ -66,6 +71,7 @@ import java.util.Map; public class ShStorehouseService extends MybatisBaseService { @Autowired private FileUploadComponent fileUploadComponent; + private ShStorehouseAttachmentService shStorehouseAttachmentService; private QueryWrapper createQueryWrapper(ShStorehouseQuery query) { // todo: 这里根据具体业务调整查询条件 // 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName())); @@ -95,12 +101,15 @@ public class ShStorehouseService extends MybatisBaseService pics = dto.getPics(); + for (String pic : pics) { + ShStorehouseAttachmentDetailsVo shStorehouseAttachmentDetailsVo = shStorehouseAttachmentService.fetchDetailsVoBySid(pic); + shStorehouseAttachmentDetailsVo.setStorehouseSid(entity.getSid()); + shStorehouseAttachmentDetailsVo.setStorehouseName(entity.getName()); + ShStorehouseAttachmentDto picdto=new ShStorehouseAttachmentDto(); + BeanUtil.copyProperties(pic,picdto); + shStorehouseAttachmentService.updateByDto(picdto); + } baseMapper.insert(entity); } @@ -127,6 +145,15 @@ public class ShStorehouseService extends MybatisBaseService pics = dto.getPics(); + for (String pic : pics) { + ShStorehouseAttachmentDetailsVo shStorehouseAttachmentDetailsVo = shStorehouseAttachmentService.fetchDetailsVoBySid(pic); + shStorehouseAttachmentDetailsVo.setStorehouseSid(entity.getSid()); + shStorehouseAttachmentDetailsVo.setStorehouseName(entity.getName()); + ShStorehouseAttachmentDto picdto=new ShStorehouseAttachmentDto(); + BeanUtil.copyProperties(pic,picdto); + shStorehouseAttachmentService.updateByDto(picdto); + } baseMapper.updateById(entity); } @@ -135,7 +162,9 @@ public class ShStorehouseService extends MybatisBaseService pics=shStorehouseAttachmentService.fetchDetailsVoByShSid(sid); BeanUtil.copyProperties(entity, vo); + vo.setPics(pics); return vo; } diff --git a/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouseattachment/ShStorehouseAttachmentService.java b/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouseattachment/ShStorehouseAttachmentService.java index e7620ff5..11c7310c 100644 --- a/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouseattachment/ShStorehouseAttachmentService.java +++ b/warehousing-system/project/wh-manage/src/main/java/com/wh/service/shstorehouseattachment/ShStorehouseAttachmentService.java @@ -39,6 +39,7 @@ import com.yxt.common.core.vo.PagerVo; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -83,7 +84,7 @@ public class ShStorehouseAttachmentService extends MybatisBaseService fetchDetailsVoByShSid(String sid) { + QueryWrapper qw =new QueryWrapper<>(); + if (StringUtils.isBlank(sid)){ + return new ArrayList<>(); + } + qw.eq("storehouse_sid",sid); + return baseMapper.selectListAllVo(qw); + } } \ No newline at end of file