Commit 43ef55d1 authored by zhuangzhuang's avatar zhuangzhuang

5.25-仓库图片

parent d914c49e
......@@ -2,6 +2,8 @@ package com.example.tdl.domain.vo;
public class AddWarehouseVo {
private String img;
private String warehouseName;
private String country;
......@@ -40,6 +42,14 @@ public class AddWarehouseVo {
private String remark;
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getWarehouseName() {
return warehouseName;
}
......
......@@ -4,6 +4,8 @@ public class ResultWarehouseVo {
private String warehouseNo;//仓库编号
private String img;
private String warehouseName;
private String country;
......@@ -54,6 +56,14 @@ public class ResultWarehouseVo {
this.warehouseNo = warehouseNo;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getWarehouseName() {
return warehouseName;
}
......@@ -221,4 +231,6 @@ public class ResultWarehouseVo {
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -4,6 +4,8 @@ public class SimpleWarehouseVo {
private String warehouseNo;
private String img;
private String warehouseName;
private String regions;
......@@ -18,6 +20,14 @@ public class SimpleWarehouseVo {
this.warehouseNo = warehouseNo;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getWarehouseName() {
return warehouseName;
}
......
......@@ -43,5 +43,6 @@ public interface WarehouseMapper {
List<GatewaySNVo> getGateway(String warehouseNo);
Integer updateImg(@Param("warehouseNo")String warehouseNo,@Param("img")String img,@Param("updateTime") Long updateTime);
}
......@@ -75,4 +75,8 @@ public class WarehouseService {
public List<GatewaySNVo> getGateway(String warehouseNo){
return warehouseMapper.getGateway(warehouseNo);
}
public Integer updateImg(String warehouseNo, String img, Long updateTime){
return warehouseMapper.updateImg(warehouseNo,img,updateTime);
}
}
......@@ -285,6 +285,7 @@ public class EquipmentBindingController {
map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo());
map.put("gSN",addWarehouseGatewayVo.getSN());
map.put("gType","WTD93LG");
map.put("endTime",System.currentTimeMillis());
warehouseService.untieGateway(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
......
......@@ -2,14 +2,15 @@ package com.example.tdl.web;
import com.aliyun.oss.OSSClient;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.service.*;
import com.example.tdl.util.AliyunOSSClientUtil;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -25,6 +26,21 @@ public class PicUploadController {
CommFeedback fb = new CommFeedback();
@Autowired
private UserService userService;
@Autowired
private CarService carService;
@Autowired
private WarehouseService warehouseService;
@Autowired
private CircuitService circuitService;
@Autowired
private CompanyService companyService;
// 允许上传的格式
private static final String[] IMAGE_TYPE = new String[]{".jpg",".png" };
......@@ -63,18 +79,18 @@ public class PicUploadController {
fb.setMessage("上传失败");
fb.setCode(0);
} else {
if("user".equals(imageType)){
//https://tdlcloud.oss-cn-shanghai.aliyuncs.com
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/userImage/" + url);
}else if("company".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/companyLog/" + url);
}else if("palte".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/palteImage/" + url);
}else if ("wareHouse".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/wareHouseImage/" + url);
}else if("circuit".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/userImage/" + url);
}
if("user".equals(imageType)){
//https://tdlcloud.oss-cn-shanghai.aliyuncs.com
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/userImage/" + url);
}else if("company".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/companyLog/" + url);
}else if("palte".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/palteImage/" + url);
}else if ("wareHouse".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/wareHouseImage/" + url);
}else if("circuit".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/userImage/" + url);
}
fb.setCode(1);
}
} catch (Exception e) {
......@@ -89,4 +105,80 @@ public class PicUploadController {
}
return gson.toJson(fb);
}
//上传图片
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value = "/updateImg",method = RequestMethod.POST)
public String updateImg(MultipartFile multipartFile, @RequestParam(value = "imageType",required = true) String imageType,@RequestParam(value = "number",required = true) String number){
if (multipartFile.isEmpty() || StringUtils.isBlank(multipartFile.getOriginalFilename())) {
fb.setCode(0);
fb.setMessage("图片不能为空");
return gson.toJson(fb);
}
if (multipartFile.getSize() > 5 * 1024 * 1024) {
fb.setCode(0);
fb.setMessage("上传图片大小不能超过5M!");
return gson.toJson(fb);
}
boolean isLegal = false;
// 判断文件后缀名是否符合
for (String type : IMAGE_TYPE) {
if (StringUtils.endsWithIgnoreCase(multipartFile.getOriginalFilename(), type)) {
isLegal = true;
break;
}
}
if (isLegal) {
try {
OSSClient ossClient = AliyunOSSClientUtil.getOSSClient();
LOGGER.info(multipartFile.getOriginalFilename());
String url = AliyunOSSClientUtil.uploadImg2Oss(ossClient, multipartFile,number,imageType);
if (url == null) {
fb.setMessage("图片上传失败");
fb.setCode(0);
} else {
fb.setCode(1);
String img = "https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/";
int i = 0;
if("user".equals(imageType)){
//修改用户图片
// i = userService.updateImg(number,img);
img = img +"userImage/" +url;
}else if("company".equals(imageType)){
// i = companyService.updateImg(number,img);
img = img +"companyLog/" +url;
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/companyLog/" + url);
}else if("palte".equals(imageType)){
// i = carService.updateImg(number,img);
img = img +"palteImage/" +url;
}else if ("warehouse".equals(imageType)) {
img = img + "wareHouseImage/" + url;
i = warehouseService.updateImg(number, img,System.currentTimeMillis());
}
if(i>0){
fb.setCode(1);
fb.setMessage(img);
}else{
fb.setCode(0);
fb.setMessage("修改图片失败");
}
}
} catch (Exception e) {
fb.setCode(0);
fb.setMessage("图片修改失败");
e.printStackTrace();
LOGGER.info(e.toString());
}
} else {
fb.setCode(0);
fb.setMessage("图片格式不正确");
}
return gson.toJson(fb);
}
}
......@@ -5,25 +5,19 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.Warehouse;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.util.PicUploadUtil;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -60,6 +54,7 @@ public class WarehouseController {
@ApiOperation(value = "查询所有仓库信息",notes = "查询所有仓库信息,返回值说明:" +
" warehouseName:仓库名," +
" warehouseNo:仓库编号," +
" img:图片路径" +
" country:国家," +
" city:市," +
" regions:国家地区," +
......@@ -252,6 +247,11 @@ public class WarehouseController {
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String warehouseNo = getWarehouseNo();
if(StringUtils.isEmpty(addWarehouseVo.getImg())){
fb.setCode(0);
fb.setMessage("仓库图片不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getWarehouseName())){
fb.setCode(0);
fb.setMessage("仓库名不能为空");
......@@ -397,6 +397,7 @@ public class WarehouseController {
map.put("companyName",user.getCompanyName());
map.put("createTime",System.currentTimeMillis());
map.put("updateTime",System.currentTimeMillis());
map.put("img",addWarehouseVo.getImg());
map.put("remark",addWarehouseVo.getRemark()== null ? "" :addWarehouseVo.getRemark());
warehouseService.addWarehouse(map);
Map<Object,Object> msg=new HashMap<>();
......@@ -565,11 +566,6 @@ public class WarehouseController {
fb.setMessage("时区不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getWarehouseInfo())){
fb.setCode(0);
fb.setMessage("基础描述不能为空");
return gson.toJson(fb);
}
ResultWarehouseVo resultWarehouseVo=warehouseService.getByWarehouseName(updateWarehouseVo.getWarehouseName(),user.getCompanyName());
if (resultWarehouseVo!=null&&!resultWarehouseVo.getWarehouseNo().equals(updateWarehouseVo.getWarehouseNo())){
fb.setCode(0);
......@@ -599,7 +595,7 @@ public class WarehouseController {
map.put("companyName",user.getCompanyName());
map.put("updateTime",System.currentTimeMillis());
map.put("remark",updateWarehouseVo.getRemark());
warehouseService.delWarehouse(map);
warehouseService.updateWarehouse(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if(msg.get("msg").equals("修改仓库成功")){
......@@ -638,7 +634,8 @@ public class WarehouseController {
Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",warehouseNo);
map.put("companyName",user.getCompanyName());
warehouseService.updateWarehouse(map);
map.put("endTime",System.currentTimeMillis());
warehouseService.delWarehouse(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if(msg.get("msg").equals("仓库删除成功")){
......@@ -689,6 +686,7 @@ public class WarehouseController {
map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo());
map.put("gSN",addWarehouseGatewayVo.getSN());
map.put("gType","WTD93LG");
map.put("startTime",System.currentTimeMillis());
warehouseService.addGateway(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
......@@ -759,8 +757,6 @@ public class WarehouseController {
//生成仓库编号
public String getWarehouseNo(){
String warehouseNo = "WH" +System.currentTimeMillis() ;
......
spring.datasource.url=jdbc:mysql://housetest-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
# Redisַ
tdl.redis.host=housetest-redis
server.port=8092
......
#
alarmType=Early warning type can not be empty
alarmScene=Early warning scene can not be empty
wrongAlarmScene=Please choose the right warning scene
......
......@@ -35,10 +35,10 @@
AND c.cargoNo like CONCAT(CONCAT('%',#{cargoNo,jdbcType=VARCHAR}),'%')
</if>
<if test="startTime!=null">
AND c.startTime &gt;= #{startTime,jdbcType=BIGINT}
AND c.createTime &gt;= #{startTime,jdbcType=BIGINT}
</if>
<if test="endTime!=null">
AND c.endTime &lt;= #{endTime,jdbcType=BIGINT}
AND c.createTime &lt;= #{endTime,jdbcType=BIGINT}
</if>
</select>
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.example.tdl.mapper.WarehouseMapper">
<!--查询所有仓库信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select warehouseNo,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c
where c.id = w.company_id
......@@ -15,7 +15,7 @@
<!-- 根据条件查询仓库信息-->
<select id="getAllByTerm" resultType="com.example.tdl.domain.vo.ResultWarehouseVo" parameterType="com.example.tdl.domain.vo.WarehouseTermVo">
select warehouseNo,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c
where c.id = w.company_id
......@@ -49,7 +49,7 @@
<select id="getByWarehouseName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select warehouseNo,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c
where c.id = w.company_id
......@@ -86,6 +86,7 @@
#{companyName,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{updateTime,mode=IN,jdbcType=BIGINT},
#{img,mode=IN,jdbcType=VARCHAR},
#{remark,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
......@@ -131,6 +132,7 @@
call pro_deleteWarehouse(
#{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{companyName,mode=IN,jdbcType=VARCHAR},
#{endTime,mode=IN,jdbcType=BIGINT},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
......@@ -144,6 +146,7 @@
#{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{startTime,mode=IN,jdbcType=BIGINT},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
......@@ -158,6 +161,7 @@
#{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{endTime,mode=IN,jdbcType=BIGINT},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
......@@ -185,7 +189,7 @@
</select>
<select id="getByWarehouseNoAndSN" resultType="java.lang.Integer" parameterType="String">
select count(id) from gateway_warehouse gw,warehouse w,gateway g
select count(w.warehouseNo) from gateway_warehouse gw,warehouse w,gateway g
where gw.gateway_id=g.id
and gw.warehouse_id = w.id
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
......@@ -194,7 +198,7 @@
<!--根据报警信息查询仓库信息-->
<select id="getByAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
SELECT warehouseNo,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
SELECT warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark
from warehouse w,alarm a ,region r,company c,city ct
WHERE w.alarm_id=a.id
......@@ -208,7 +212,7 @@
</select>
<select id="getByWarehouse" parameterType="com.example.tdl.domain.vo.WareHouseByTermVo" resultType="com.example.tdl.domain.vo.SimpleWarehouseVo">
select warehouseNo, warehouseName,CONCAT_WS("-",c.country,c.city) regions, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count
select warehouseNo, w.img,warehouseName,CONCAT_WS("-",c.country,c.city) regions, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count
from warehouse w ,company c ,city ct
where c.id=w.company_id
and ct.id = w.city_id
......@@ -243,4 +247,8 @@
and w.warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
</select>
<update id="updateImg">
UPDATE warehouse set img = #{img,jdbcType=VARCHAR}, updateTime =#{updateTime,mode=IN,jdbcType=BIGINT} where warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment