Commit 79cf6251 authored by chenying's avatar chenying

6.6修改仓库数据下载接口,修改添加公司接口,修改角色接口

parent ce9d3833
package com.example.tdl.common; package com.example.tdl.common;
import com.example.tdl.domain.vo.DownloadWarehouseVo; import com.example.tdl.domain.vo.*;
import com.example.tdl.domain.vo.TDLDeviceDetailVo;
import com.example.tdl.domain.vo.WarehouseDetailVo;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
...@@ -28,13 +26,16 @@ public class WarehouseExcel { ...@@ -28,13 +26,16 @@ public class WarehouseExcel {
private HttpServletResponse response; private HttpServletResponse response;
private List<DownloadWarehouseVo> downloadWarehouseVos; private List<ResultWarehouseNoAndTDLSNAndTimeVo> resultWarehouseNoAndTDLSNAndTimeVo;
public WarehouseExcel(String fileName, List<DownloadWarehouseVo> downloadWarehouseVos , String userName, HttpServletResponse response) { // private List<DownloadWarehouseVo> downloadWarehouseVos;
public WarehouseExcel(String fileName, List<ResultWarehouseNoAndTDLSNAndTimeVo> resultWarehouseNoAndTDLSNAndTimeVo , String userName, HttpServletResponse response) {
this.userName = userName; this.userName = userName;
this.resultWarehouseNoAndTDLSNAndTimeVo=resultWarehouseNoAndTDLSNAndTimeVo;
this.fileName = fileName; this.fileName = fileName;
this.response = response; this.response = response;
this.downloadWarehouseVos=downloadWarehouseVos; // this.downloadWarehouseVos=downloadWarehouseVos;
} }
/* /*
...@@ -67,128 +68,133 @@ public class WarehouseExcel { ...@@ -67,128 +68,133 @@ public class WarehouseExcel {
//合并单元格(参数1:起始行,参数2:截至行,参数3:起始列,参数4:截至列) //合并单元格(参数1:起始行,参数2:截至行,参数3:起始列,参数4:截至列)
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6)); sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
int rowCount=1;
/* for (int a=0;a<resultWarehouseNoAndTDLSNAndTimeVo.size();a++){
* 创建第二行 /*
* */ * 创建第二行
HSSFRow row2 = sheet.createRow((short) 1); * */
HSSFCell cell2 = null; HSSFRow row2 = sheet.createRow((short) rowCount);
HSSFCellStyle rowStyle2 = getStyle(workbook); HSSFCell cell2 = null;
cell2 = row2.createCell(0); HSSFCellStyle rowStyle2 = getStyle(workbook);
cell2.setCellValue("年度"); cell2 = row2.createCell(0);
cell2.setCellStyle(rowStyle2); cell2.setCellValue("年度");
cell2 = row2.createCell(1);
cell2.setCellValue("");
cell2.setCellStyle(rowStyle2);
for (int n = 2; n < 6; n++) {
cell2 = row2.createCell(n);
//设置列的格式
cell2.setCellStyle(rowStyle2); cell2.setCellStyle(rowStyle2);
//将标题添加到列中 cell2 = row2.createCell(1);
cell2.setCellValue("库房适宜温度为xx℃-xx℃,湿度保持xx%-xx%,超标要做必要调节。"); cell2.setCellValue("");
sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 5)); cell2.setCellStyle(rowStyle2);
} for (int n = 2; n < 6; n++) {
cell2 = row2.createCell(6); cell2 = row2.createCell(n);
cell2.setCellValue("记录人:"+userName); //设置列的格式
cell2.setCellStyle(rowStyle2); cell2.setCellStyle(rowStyle2);
row2.setHeight((short) (26 * 20)); //将标题添加到列中
cell2.setCellValue("库房适宜温度为"+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getTemMin()+"℃-"+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getTemMax()+"℃,湿度保持"+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getHumidityMin()+"%-"+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getHumidityMax()+"%,超标要做必要调节。");
sheet.addMergedRegion(new CellRangeAddress(rowCount, rowCount, 2, 5));
}
cell2 = row2.createCell(6);
cell2.setCellValue("记录人:"+userName);
cell2.setCellStyle(rowStyle2);
row2.setHeight((short) (26 * 20));
/* /*
* 创建第三行 * 创建第三行
* */ * */
HSSFRow row3 = sheet.createRow((short) 2); rowCount=rowCount+1;
HSSFCell cell3 = null; HSSFRow row3 = sheet.createRow((short) rowCount);
HSSFCellStyle rowStyle3 = getStyle(workbook); HSSFCell cell3 = null;
for (int n = 0; n < 3; n++) { HSSFCellStyle rowStyle3 = getStyle(workbook);
cell3 = row3.createCell(n); for (int n = 0; n < 3; n++) {
cell3 = row3.createCell(n);
cell3.setCellStyle(rowStyle3);
//将标题添加到列中
cell3.setCellValue("采样时间");
sheet.addMergedRegion(new CellRangeAddress(rowCount, rowCount, 0, 2));
}
cell3 = row3.createCell(3);
cell3.setCellValue("天气");
cell3.setCellStyle(rowStyle3); cell3.setCellStyle(rowStyle3);
//将标题添加到列中 cell3 = row3.createCell(4);
cell3.setCellValue("采样时间"); cell3.setCellValue("温度");
sheet.addMergedRegion(new CellRangeAddress(2, 2, 0, 2)); cell3.setCellStyle(rowStyle3);
} cell3 = row3.createCell(5);
cell3 = row3.createCell(3); cell3.setCellValue("湿度");
cell3.setCellValue("天气"); cell3.setCellStyle(rowStyle3);
cell3.setCellStyle(rowStyle3); cell3 = row3.createCell(6);
cell3 = row3.createCell(4); cell3.setCellValue("是否预警");
cell3.setCellValue("温度"); cell3.setCellStyle(rowStyle3);
cell3.setCellStyle(rowStyle3); row3.setHeight((short) (26 * 20));
cell3 = row3.createCell(5);
cell3.setCellValue("湿度");
cell3.setCellStyle(rowStyle3);
cell3 = row3.createCell(6);
cell3.setCellValue("是否预警");
cell3.setCellStyle(rowStyle3);
row3.setHeight((short) (26 * 20));
/** 创建第四行 /** 创建第四行
* */ * */
HSSFRow row4= sheet.createRow((short) 3); rowCount=rowCount+1;
HSSFCell cell4 = null; HSSFRow row4= sheet.createRow((short) rowCount);
HSSFCellStyle rowStyle4 = getStyle(workbook); HSSFCell cell4 = null;
cell4 = row4.createCell(0); HSSFCellStyle rowStyle4 = getStyle(workbook);
cell4.setCellValue("月"); cell4 = row4.createCell(0);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("月");
cell4 = row4.createCell(1); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("日"); cell4 = row4.createCell(1);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("日");
cell4 = row4.createCell(2); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("时分"); cell4 = row4.createCell(2);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("时分");
cell4 = row4.createCell(3); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("天气"); cell4 = row4.createCell(3);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("天气");
cell4 = row4.createCell(4); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("温度"); cell4 = row4.createCell(4);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("温度");
cell4 = row4.createCell(5); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("湿度"); cell4 = row4.createCell(5);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("湿度");
cell4 = row4.createCell(6); cell4.setCellStyle(rowStyle4);
cell4.setCellValue("是否预警"); cell4 = row4.createCell(6);
cell4.setCellStyle(rowStyle4); cell4.setCellValue("是否预警");
sheet.addMergedRegion(new CellRangeAddress(2, 3, 3, 3)); cell4.setCellStyle(rowStyle4);
sheet.addMergedRegion(new CellRangeAddress(2, 3, 4, 4)); sheet.addMergedRegion(new CellRangeAddress(rowCount-1, rowCount, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(2, 3, 5, 5)); sheet.addMergedRegion(new CellRangeAddress(rowCount-1, rowCount, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(2, 3, 6, 6)); sheet.addMergedRegion(new CellRangeAddress(rowCount-1, rowCount, 5, 5));
row4.setHeight((short) (26 * 20)); sheet.addMergedRegion(new CellRangeAddress(rowCount-1, rowCount, 6, 6));
row4.setHeight((short) (26 * 20));
/** 循环创建仓库数据行数 /** 循环创建仓库数据行数
* */ * */
HSSFCellStyle rowStyle = getStyle(workbook); rowCount=rowCount+1;
int a=0; HSSFCellStyle rowStyle = getStyle(workbook);
for(int i = 0;i<downloadWarehouseVos.size();i++) { for(int i = 0;i<resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().size();i++) {
HSSFRow row = sheet.createRow((short) 4 + i); HSSFRow row = sheet.createRow((short) rowCount + i);
HSSFCell cell = null; HSSFCell cell = null;
Long time=Long.valueOf(downloadWarehouseVos.get(i).getTime()); Long time=Long.valueOf(resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().get(i).getTime());
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date(time); Date date=new Date(time);
cell2 = row2.createCell(1); cell2 = row2.createCell(1);
cell2.setCellValue(date.getYear()); cell2.setCellValue(date.getYear());
cell2.setCellStyle(rowStyle); cell2.setCellStyle(rowStyle);
cell = row.createCell(0); cell = row.createCell(0);
cell.setCellValue(date.getMonth()); cell.setCellValue(date.getMonth()+1);
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(1); cell = row.createCell(1);
cell.setCellValue(date.getDay()); cell.setCellValue(date.getDay());
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(2); cell = row.createCell(2);
cell.setCellValue(date.getHours()+":"+date.getMinutes()); cell.setCellValue(date.getHours()+":"+date.getMinutes());
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(3); cell = row.createCell(3);
cell.setCellValue("-"); cell.setCellValue("-");
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(4); cell = row.createCell(4);
cell.setCellValue(downloadWarehouseVos.get(i).getTemperature()); cell.setCellValue(resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().get(i).getTemperature());
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(5); cell = row.createCell(5);
cell.setCellValue(downloadWarehouseVos.get(i).getHumidity()); cell.setCellValue(resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().get(i).getHumidity());
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
cell = row.createCell(6); cell = row.createCell(6);
cell.setCellValue("是"); cell.setCellValue(resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().get(i).getAlarm());
cell.setCellStyle(rowStyle); cell.setCellStyle(rowStyle);
row.setHeight((short) (26 * 20)); row.setHeight((short) (26 * 20));
}
rowCount=rowCount+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getDownloadWarehouseVos().size();
} }
sheet.setColumnWidth(0, 10 * 256); sheet.setColumnWidth(0, 10 * 256);
sheet.setColumnWidth(1, 10 * 256); sheet.setColumnWidth(1, 10 * 256);
......
package com.example.tdl.domain.vo; package com.example.tdl.domain.vo;
public class DownloadForWarehouseVo { public class DownloadForWarehouseVo {
private String startTime;
private String stopTime;
private String warehouseNo; private String warehouseNo;
private String TDLSN; private String TDLSN;
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getStopTime() {
return stopTime;
}
public void setStopTime(String stopTime) {
this.stopTime = stopTime;
}
public String getWarehouseNo() { public String getWarehouseNo() {
return warehouseNo; return warehouseNo;
} }
......
...@@ -3,11 +3,11 @@ package com.example.tdl.domain.vo; ...@@ -3,11 +3,11 @@ package com.example.tdl.domain.vo;
public class DownloadWarehouseVo { public class DownloadWarehouseVo {
private String TDLSN; private String TDLSN;
private String pressure; private Float pressure;
private String temperature; private Float temperature;
private String humidity; private Float humidity;
private String time; private String time;
...@@ -21,27 +21,27 @@ public class DownloadWarehouseVo { ...@@ -21,27 +21,27 @@ public class DownloadWarehouseVo {
this.TDLSN = TDLSN; this.TDLSN = TDLSN;
} }
public String getPressure() { public Float getPressure() {
return pressure; return pressure;
} }
public void setPressure(String pressure) { public void setPressure(Float pressure) {
this.pressure = pressure; this.pressure = pressure;
} }
public String getTemperature() { public Float getTemperature() {
return temperature; return temperature;
} }
public void setTemperature(String temperature) { public void setTemperature(Float temperature) {
this.temperature = temperature; this.temperature = temperature;
} }
public String getHumidity() { public Float getHumidity() {
return humidity; return humidity;
} }
public void setHumidity(String humidity) { public void setHumidity(Float humidity) {
this.humidity = humidity; this.humidity = humidity;
} }
......
package com.example.tdl.domain.vo;
import java.util.List;
public class ResultWarehouseNoAndTDLSNAndTimeVo {
private String TDLSN;
private String gatewaySN;
private String gatewayType;
private String warehouseNo;
private String alarmType;
private Float temMax;
private Float temMin;
private Float humidityMax;
private Float humidityMin;
private List<DownloadWarehouseVo> downloadWarehouseVos;
public List<DownloadWarehouseVo> getDownloadWarehouseVos() {
return downloadWarehouseVos;
}
public void setDownloadWarehouseVos(List<DownloadWarehouseVo> downloadWarehouseVos) {
this.downloadWarehouseVos = downloadWarehouseVos;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getGatewayType() {
return gatewayType;
}
public void setGatewayType(String gatewayType) {
this.gatewayType = gatewayType;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public Float getTemMax() {
return temMax;
}
public void setTemMax(Float temMax) {
this.temMax = temMax;
}
public Float getTemMin() {
return temMin;
}
public void setTemMin(Float temMin) {
this.temMin = temMin;
}
public Float getHumidityMax() {
return humidityMax;
}
public void setHumidityMax(Float humidityMax) {
this.humidityMax = humidityMax;
}
public Float getHumidityMin() {
return humidityMin;
}
public void setHumidityMin(Float humidityMin) {
this.humidityMin = humidityMin;
}
}
...@@ -16,7 +16,7 @@ import java.util.Map; ...@@ -16,7 +16,7 @@ import java.util.Map;
public interface CompanyMapper { public interface CompanyMapper {
List<ResultCompanyVo> getAll(@Param("companyNo") String companyNo); List<ResultCompanyVo> getAll(@Param("companyNo") String companyNo);
int addCompany(AddCompanyVo addCompanyVo); int addCompany(Map<String,Object> map);
int updateCompany(UpdateCompanyVo updateCompanyVo); int updateCompany(UpdateCompanyVo updateCompanyVo);
......
...@@ -2,6 +2,7 @@ package com.example.tdl.mapper; ...@@ -2,6 +2,7 @@ package com.example.tdl.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -9,7 +10,7 @@ import java.util.Map; ...@@ -9,7 +10,7 @@ import java.util.Map;
@Mapper @Mapper
public interface RoleHasPermissionMapper { public interface RoleHasPermissionMapper {
List<String> getByRoleName(String roleName); List<String> getByRoleName(@Param("roleName") String roleName, @Param("companyName") String companyName);
int addRoleHasPermission(Map<String,Object> map); int addRoleHasPermission(Map<String,Object> map);
} }
...@@ -9,7 +9,7 @@ import java.util.List; ...@@ -9,7 +9,7 @@ import java.util.List;
@Mapper @Mapper
public interface SideMapper { public interface SideMapper {
List<ResultSideVo> selectAllTitle(String roleName); List<ResultSideVo> selectAllTitle(@Param("roleName") String roleName,@Param("companyName") String companyName);
List<ResultSideVo> selectBySideTitle(@Param("roleName") String roleName, @Param("sideTitle") String sideTitle); List<ResultSideVo> selectBySideTitle(@Param("roleName") String roleName,@Param("companyName") String companyName, @Param("sideTitle") String sideTitle);
} }
...@@ -25,4 +25,6 @@ public interface TDLLogMapper { ...@@ -25,4 +25,6 @@ public interface TDLLogMapper {
List<WarehouseLogVo> getByWarehouse(String warehouseNo); List<WarehouseLogVo> getByWarehouse(String warehouseNo);
List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo);
} }
...@@ -22,8 +22,8 @@ public class CompanyService { ...@@ -22,8 +22,8 @@ public class CompanyService {
return companyMapper.getAll(companyNo); return companyMapper.getAll(companyNo);
} }
public int addCompany(AddCompanyVo addCompanyVo){ public int addCompany(Map<String,Object> map){
return companyMapper.addCompany(addCompanyVo); return companyMapper.addCompany(map);
} }
public int updateCompany(UpdateCompanyVo updateCompanyVo){ public int updateCompany(UpdateCompanyVo updateCompanyVo){
......
...@@ -14,8 +14,8 @@ public class RoleHasPermissionService { ...@@ -14,8 +14,8 @@ public class RoleHasPermissionService {
@Autowired @Autowired
private RoleHasPermissionMapper roleHasPermissionMapper; private RoleHasPermissionMapper roleHasPermissionMapper;
public List<String> getByRoleName(String roleName){ public List<String> getByRoleName(String roleName,String companyName){
return roleHasPermissionMapper.getByRoleName(roleName); return roleHasPermissionMapper.getByRoleName(roleName,companyName);
} }
public int addRoleHasPermission(Map<String,Object> map){ public int addRoleHasPermission(Map<String,Object> map){
......
...@@ -13,12 +13,12 @@ public class SideService { ...@@ -13,12 +13,12 @@ public class SideService {
@Autowired @Autowired
private SideMapper sideMapper; private SideMapper sideMapper;
public List<ResultSideVo> selectAllTitle(String roleName){ public List<ResultSideVo> selectAllTitle(String roleName,String companyName){
return sideMapper.selectAllTitle(roleName); return sideMapper.selectAllTitle(roleName,companyName);
} }
public List<ResultSideVo> selectBySideTitle(String roleName,String sideTitle){ public List<ResultSideVo> selectBySideTitle(String roleName,String companyName,String sideTitle){
return sideMapper.selectBySideTitle(roleName,sideTitle); return sideMapper.selectBySideTitle(roleName,companyName,sideTitle);
} }
} }
...@@ -47,4 +47,7 @@ public class TDLLogService { ...@@ -47,4 +47,7 @@ public class TDLLogService {
return tdlLogMapper.getByWarehouse(warehouseNo); return tdlLogMapper.getByWarehouse(warehouseNo);
} }
public List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo){
return tdlLogMapper.getByWarehouseNoAndTDLSNAndTime(downloadForWarehouseVo);
}
} }
...@@ -149,14 +149,26 @@ public class CompanyController { ...@@ -149,14 +149,26 @@ public class CompanyController {
companyNos = companyNo + ((int) (Math.random() * (9999 - 1000 + 1)) + 1000); companyNos = companyNo + ((int) (Math.random() * (9999 - 1000 + 1)) + 1000);
} }
} }
addCompanyVo.setCompanyNo(companyNos); Map<String,Object> map=new HashMap<>();
int a = companyService.addCompany(addCompanyVo); map.put("companyNo",companyNos);
if (a>0){ map.put("companyName",addCompanyVo.getCompanyName());
map.put("alias",addCompanyVo.getAlias());
map.put("country",addCompanyVo.getCountry());
map.put("city",addCompanyVo.getCity());
map.put("addressDetail",addCompanyVo.getAddressDetail());
map.put("tel",addCompanyVo.getTel());
map.put("manager",addCompanyVo.getManager());
map.put("img",addCompanyVo.getImg());
map.put("createTime",System.currentTimeMillis());
companyService.addCompany(map);
Map<String,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("添加公司成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"addCompanySuccess")); fb.setMessage(i18n.getMessage(request,"addCompanySuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"addCompanyFailure")); fb.setMessage(msg.get("msg").toString());
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
......
...@@ -79,6 +79,16 @@ public class DownloadController { ...@@ -79,6 +79,16 @@ public class DownloadController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(downloadForWarehouseVo.getStartTime())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"downloadStartTime"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(downloadForWarehouseVo.getStopTime())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"downloadEndTime"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(downloadForWarehouseVo.getWarehouseNo())){ if (StringUtils.isEmpty(downloadForWarehouseVo.getWarehouseNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warehouseNo")); fb.setMessage(i18n.getMessage(request,"warehouseNo"));
...@@ -94,23 +104,38 @@ public class DownloadController { ...@@ -94,23 +104,38 @@ public class DownloadController {
fb.setMessage(i18n.getMessage(request,"Nonexistent")); fb.setMessage(i18n.getMessage(request,"Nonexistent"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取该tdl对应的网关信息 List<ResultWarehouseNoAndTDLSNAndTimeVo> resultWarehouseNoAndTDLSNAndTimeVo=tdlLogService.getByWarehouseNoAndTDLSNAndTime(downloadForWarehouseVo);
ResultTDLDeviceVo resultTDLDeviceVo=tdlDeviceService.getByTDLSN(downloadForWarehouseVo.getTDLSN()); if (resultWarehouseNoAndTDLSNAndTimeVo.size()==0){
//获取该tdl的报警信息 fb.setCode(0);
ResultAlarmVo resultAlarmVo=tdlLogService.getWarehouseByTdl(downloadForWarehouseVo.getWarehouseNo(),downloadForWarehouseVo.getTDLSN()); fb.setMessage("没有数据");
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+resultTDLDeviceVo.getGatewayType()+"_"+resultTDLDeviceVo.getGatewaySN()+"\" WHERE (\"tdl\" = '"+downloadForWarehouseVo.getTDLSN()+"') ORDER BY time DESC LIMIT 1"; return gson.toJson(fb);
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database)); }
List<DownloadWarehouseVo> downloadWarehouseVos=getWarehouseData(queryResults); for (int a=0;a<resultWarehouseNoAndTDLSNAndTimeVo.size();a++){
for (int i=0;i<downloadWarehouseVos.size();i++){ List<DownloadWarehouseVo> downloadWarehouseVos=new ArrayList<>();
if (Integer.valueOf(downloadWarehouseVos.get(i).getTemperature()) > resultAlarmVo.getTemMax()||Integer.valueOf(downloadWarehouseVos.get(i).getTemperature())<resultAlarmVo.getTemMin()){ String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getGatewayType()+"_"+resultWarehouseNoAndTDLSNAndTimeVo.get(a).getGatewaySN()+"\" WHERE (\"tdl\" = 'TDL-"+downloadForWarehouseVo.getTDLSN()+"') ORDER BY time ";
downloadWarehouseVos.get(i).setAlarm("报警"); QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
}else{ downloadWarehouseVos=getWarehouseData(queryResults);
downloadWarehouseVos.get(i).setAlarm("正常"); for (int i=0;i<downloadWarehouseVos.size();i++){
if (downloadWarehouseVos.get(i).getTemperature()>resultWarehouseNoAndTDLSNAndTimeVo.get(a).getTemMax()||
downloadWarehouseVos.get(i).getTemperature()<resultWarehouseNoAndTDLSNAndTimeVo.get(a).getTemMin()||
downloadWarehouseVos.get(i).getHumidity()>resultWarehouseNoAndTDLSNAndTimeVo.get(a).getHumidityMax()||
downloadWarehouseVos.get(i).getHumidity()<resultWarehouseNoAndTDLSNAndTimeVo.get(a).getHumidityMin()){
downloadWarehouseVos.get(i).setAlarm("报警");
}else{
downloadWarehouseVos.get(i).setAlarm("正常");
}
} }
if (downloadWarehouseVos.size()==0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
resultWarehouseNoAndTDLSNAndTimeVo.get(a).setDownloadWarehouseVos(downloadWarehouseVos);
} }
try { try {
String fileName = downloadForWarehouseVo.getWarehouseNo()+"仓库温湿度观测记录表-" +System.currentTimeMillis(); String fileName = downloadForWarehouseVo.getWarehouseNo()+"仓库温湿度观测记录表-" +System.currentTimeMillis();
WarehouseExcel warehouseExcel = new WarehouseExcel(fileName,downloadWarehouseVos,user.getUserName(),response); WarehouseExcel warehouseExcel = new WarehouseExcel(fileName,resultWarehouseNoAndTDLSNAndTimeVo,user.getUserName(),response);
File file=new File("E:"+File.separator+fileName); File file=new File("E:"+File.separator+fileName);
if(!file.exists()){ if(!file.exists()){
file.mkdir(); file.mkdir();
...@@ -169,9 +194,9 @@ public class DownloadController { ...@@ -169,9 +194,9 @@ public class DownloadController {
for(List<Object> value:values){ for(List<Object> value:values){
DownloadWarehouseVo downloadWarehouseVo = new DownloadWarehouseVo(); DownloadWarehouseVo downloadWarehouseVo = new DownloadWarehouseVo();
downloadWarehouseVo.setTime(parseTime(value.get(0).toString())); downloadWarehouseVo.setTime(parseTime(value.get(0).toString()));
downloadWarehouseVo.setPressure(value.get(1)==null ? "" :value.get(1).toString()); downloadWarehouseVo.setPressure(Float.parseFloat(value.get(1).toString()));
downloadWarehouseVo.setTemperature(value.get(2)==null ? "" :value.get(2).toString()); downloadWarehouseVo.setTemperature(Float.parseFloat(value.get(2).toString()));
downloadWarehouseVo.setHumidity(value.get(3)==null ? "" :value.get(3).toString()); downloadWarehouseVo.setHumidity(Float.parseFloat(value.get(3).toString()));
downloadWarehouseVos.add(downloadWarehouseVo); downloadWarehouseVos.add(downloadWarehouseVo);
} }
return downloadWarehouseVos; return downloadWarehouseVos;
......
...@@ -66,8 +66,8 @@ public class PermissionController { ...@@ -66,8 +66,8 @@ public class PermissionController {
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
//获取该公司的所有权限 //获取该公司的所有权限
String name = "系统管理员"; String name = "管理员";
List<String> permissionLists = roleHasPermissionService.getByRoleName(name); List<String> permissionLists = roleHasPermissionService.getByRoleName(name,user.getCompanyName());
List<String> parentLists =permissionService.getPermissionParentName(); List<String> parentLists =permissionService.getPermissionParentName();
List<PermissionGroupVo> vo =new ArrayList<>(); List<PermissionGroupVo> vo =new ArrayList<>();
//遍历取出每一个action匹配权限组 //遍历取出每一个action匹配权限组
...@@ -111,10 +111,10 @@ public class PermissionController { ...@@ -111,10 +111,10 @@ public class PermissionController {
roleName= (String) json.get("roleName"); roleName= (String) json.get("roleName");
//获取该公司的所有权限 //获取该公司的所有权限
String name = "系统管理员"; String name = "系统管理员";
List<String> permissionLists = roleHasPermissionService.getByRoleName(name); List<String> permissionLists = roleHasPermissionService.getByRoleName(name,user.getCompanyName());
List<String> parentLists =permissionService.getPermissionParentName(); List<String> parentLists =permissionService.getPermissionParentName();
//根据角色名获取拥有的角色 //根据角色名获取拥有的角色
List<String> rolePermission = roleHasPermissionService.getByRoleName(roleName); List<String> rolePermission = roleHasPermissionService.getByRoleName(roleName,user.getCompanyName());
List<PermissionGroupVo> vo =new ArrayList<>(); List<PermissionGroupVo> vo =new ArrayList<>();
//遍历取出每一个action匹配权限组 //遍历取出每一个action匹配权限组
for (String parentName : parentLists) { for (String parentName : parentLists) {
......
...@@ -271,6 +271,4 @@ public class RoleController { ...@@ -271,6 +271,4 @@ public class RoleController {
} }
} }
...@@ -52,7 +52,7 @@ public class RoleHasPermissionController { ...@@ -52,7 +52,7 @@ public class RoleHasPermissionController {
fb.setMessage("您没有登录,请先登录"); fb.setMessage("您没有登录,请先登录");
return gson.toJson(fb); return gson.toJson(fb);
}else{ }else{
return roleHasPermissionService.getByRoleName(user.getRoleName()); return roleHasPermissionService.getByRoleName(user.getRoleName(),user.getCompanyName());
} }
} }
......
...@@ -57,7 +57,7 @@ public class SideController { ...@@ -57,7 +57,7 @@ public class SideController {
// //获取用户角色编号 // //获取用户角色编号
// String roleName = roleService.getRoleNameByUserName(user.getUserName()); // String roleName = roleService.getRoleNameByUserName(user.getUserName());
//获取该用户所有的权限及对应的界面 //获取该用户所有的权限及对应的界面
List<ResultSideVo> sliderTitleVoList=sideService.selectAllTitle(user.getRoleName()); List<ResultSideVo> sliderTitleVoList=sideService.selectAllTitle(user.getRoleName(),user.getCompanyName());
Set<String> l=new HashSet<>(); Set<String> l=new HashSet<>();
for (int i=0;i<sliderTitleVoList.size();i++){ for (int i=0;i<sliderTitleVoList.size();i++){
l.add(sliderTitleVoList.get(i).getpName()); l.add(sliderTitleVoList.get(i).getpName());
...@@ -81,10 +81,8 @@ public class SideController { ...@@ -81,10 +81,8 @@ public class SideController {
fb.setMessage("查询的侧边栏名不能为空"); fb.setMessage("查询的侧边栏名不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取用户角色编号
String roleName= roleService.getRoleNameByUserName(user.getUserName());
//获取该用户所有的权限及对应的界面 //获取该用户所有的权限及对应的界面
List<ResultSideVo> sliderTitleVoList=sideService.selectBySideTitle(roleName,name); List<ResultSideVo> sliderTitleVoList=sideService.selectBySideTitle(user.getRoleName(),user.getCompanyName(),name);
Set<String> l=new HashSet<>(); Set<String> l=new HashSet<>();
for (int i=0;i<sliderTitleVoList.size();i++){ for (int i=0;i<sliderTitleVoList.size();i++){
l.add(sliderTitleVoList.get(i).getPermissionName()); l.add(sliderTitleVoList.get(i).getPermissionName());
......
...@@ -816,8 +816,6 @@ public class WarehouseController { ...@@ -816,8 +816,6 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value="添加网关",notes = "添加网关,传值:" + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
"SN:网关编号" + "SN:网关编号" +
...@@ -871,7 +869,6 @@ public class WarehouseController { ...@@ -871,7 +869,6 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//绑定报警联系人 //绑定报警联系人
@ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" + @ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
...@@ -925,7 +922,6 @@ public class WarehouseController { ...@@ -925,7 +922,6 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据仓库编号获取仓库实时数据 //根据仓库编号获取仓库实时数据
@ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" + @ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" +
" warehouseNo:仓库编号," + " warehouseNo:仓库编号," +
...@@ -1041,8 +1037,6 @@ public class WarehouseController { ...@@ -1041,8 +1037,6 @@ public class WarehouseController {
return warehouseGatewayDateVoList; return warehouseGatewayDateVoList;
} }
//货物仓库某一tdl的温湿度 //货物仓库某一tdl的温湿度
@ApiOperation(value="货物仓库某一tdl的温湿度",notes = "货物仓库某一tdl的温湿度,传值:" + @ApiOperation(value="货物仓库某一tdl的温湿度",notes = "货物仓库某一tdl的温湿度,传值:" +
" warehouseNo:仓库编号," + " warehouseNo:仓库编号," +
...@@ -1155,7 +1149,6 @@ public class WarehouseController { ...@@ -1155,7 +1149,6 @@ public class WarehouseController {
return warehouseNo; return warehouseNo;
} }
public List<WarehouseTimeAndDataVo> getData(QueryResult queryResult){ public List<WarehouseTimeAndDataVo> getData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult); List<List<Object>> values = getValues(queryResult);
List<WarehouseTimeAndDataVo> historyDataList = new ArrayList<>(); List<WarehouseTimeAndDataVo> historyDataList = new ArrayList<>();
......
...@@ -256,4 +256,6 @@ updateSuccess=\u4FEE\u6539\u89D2\u8272\u6210\u529F ...@@ -256,4 +256,6 @@ updateSuccess=\u4FEE\u6539\u89D2\u8272\u6210\u529F
updateFailure=\u4FEE\u6539\u89D2\u8272\u5931\u8D25 updateFailure=\u4FEE\u6539\u89D2\u8272\u5931\u8D25
deleteSuccess=\u5220\u9664\u89D2\u8272\u6210\u529F deleteSuccess=\u5220\u9664\u89D2\u8272\u6210\u529F
deleteFailure=\u5220\u9664\u89D2\u8272\u5931\u8D25 deleteFailure=\u5220\u9664\u89D2\u8272\u5931\u8D25
#\u4ED3\u5E93\u6570\u636E\u4E0B\u8F7D
downloadStartTime=\u67E5\u8BE2\u5F00\u59CB\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A
downloadEndTime=\u67E5\u8BE2\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A
...@@ -11,20 +11,24 @@ ...@@ -11,20 +11,24 @@
</if> </if>
</select> </select>
<insert id="addCompany" parameterType="com.example.tdl.domain.vo.AddCompanyVo"> <insert id="addCompany" parameterType="java.util.Map" statementType="CALLABLE">
INSERT INTO company VALUES ( <![CDATA[
NULL , {
#{companyNo,jdbcType=VARCHAR}, call pro_addCompany(
#{companyName,jdbcType=VARCHAR}, #{companyNo,mode=IN,jdbcType=VARCHAR},
#{alias,jdbcType=VARCHAR}, #{companyName,mode=IN,jdbcType=VARCHAR},
#{country,jdbcType=VARCHAR}, #{alias,mode=IN,jdbcType=VARCHAR},
#{city,jdbcType=VARCHAR}, #{country,mode=IN,jdbcType=VARCHAR},
#{addressDetail,jdbcType=VARCHAR}, #{city,mode=IN,jdbcType=VARCHAR},
#{tel,jdbcType=VARCHAR}, #{addressDetail,mode=IN,jdbcType=VARCHAR},
#{manager,jdbcType=VARCHAR}, #{tel,mode=IN,jdbcType=VARCHAR},
#{img,jdbcType=VARCHAR}, #{manager,mode=IN,jdbcType=VARCHAR},
1 #{img,mode=IN,jdbcType=VARCHAR},
) #{createTime,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert> </insert>
<update id="updateCompany" parameterType="com.example.tdl.domain.vo.UpdateCompanyVo"> <update id="updateCompany" parameterType="com.example.tdl.domain.vo.UpdateCompanyVo">
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
SELECT p.permissionName from role_has_permission rp,role r,permission p SELECT p.permissionName from role_has_permission rp,role r,permission p
WHERE rp.role_id=r.id WHERE rp.role_id=r.id
AND rp.permission_id=p.id AND rp.permission_id=p.id
AND r.roleName=#{roleName.jdbcType=VARCHAR} AND r.roleName=#{roleName,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select> </select>
<insert id="addRoleHasPermission" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addRoleHasPermission" parameterType="java.util.Map" statementType="CALLABLE">
......
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
SELECT (SELECT sideTitle FROM side WHERE id=s.pid) pName,s.sideTitle,p.permissionName FROM side_has_permission sp, side s,permission p SELECT (SELECT sideTitle FROM side WHERE id=s.pid) pName,s.sideTitle,p.permissionName FROM side_has_permission sp, side s,permission p
WHERE sp.permission_id=p.id WHERE sp.permission_id=p.id
AND sp.side_id=s.id AND sp.side_id=s.id
AND p.permissionName IN ( AND p.permissionName IN (select p.permissionName FROM role_has_permission rp,role r, permission p
select p.permissionName FROM role_has_permission rp,role r, permission p
where rp.role_id=r.id where rp.role_id=r.id
and rp.permission_id=p.id and rp.permission_id=p.id
AND r.id =( AND r.id =(select id from role where roleName =#{roleName,jdbcType=VARCHAR}
select id from role where roleName =#{roleName,jdbcType=VARCHAR})) AND company_id=(SELECT id from company where companyName=#{companyName})))
ORDER BY s.id; ORDER BY s.id;
</select> </select>
...@@ -24,8 +23,8 @@ ...@@ -24,8 +23,8 @@
select p.permissionName FROM role_has_permission rp,role r, permission p select p.permissionName FROM role_has_permission rp,role r, permission p
where rp.role_id=r.id where rp.role_id=r.id
and rp.permission_id=p.id and rp.permission_id=p.id
AND r.id =( AND r.id =(select id from role where roleName =#{roleName,jdbcType=VARCHAR}
select id from role where roleName =#{roleName,jdbcType=VARCHAR})) AND company_id=(SELECT id from company where companyName=#{companyName})))
AND s.sideTitle=#{sideTitle,jdbcType=VARCHAR} AND s.sideTitle=#{sideTitle,jdbcType=VARCHAR}
ORDER BY s.id; ORDER BY s.id;
</select> </select>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</select> </select>
<select id="getByTdl" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo"> <select id="getByTdl" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
select alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark select alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a,tdl_gateway_log t from alarm a,tdl_gateway_log t
where a.id = t.alarm_id where a.id = t.alarm_id
and transportationNo = #{transportationNo,jdbcType=VARCHAR} and transportationNo = #{transportationNo,jdbcType=VARCHAR}
...@@ -43,20 +43,28 @@ ...@@ -43,20 +43,28 @@
</select> </select>
<select id="getWarehouseByTdl" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo"> <select id="getWarehouseByTdl" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
select alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark select alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a,tdl_gateway_log t from alarm a,tdl_gateway_log t
where a.id = t.alarm_id where a.id = t.alarm_id
and warehouseNo = #{warehouseNo,jdbcType=VARCHAR} and warehouseNo = #{warehouseNo,jdbcType=VARCHAR}
and TDLSN = #{TDLSN,jdbcType=VARCHAR} and TDLSN = #{TDLSN,jdbcType=VARCHAR}
AND endTime is not null AND endTime is null
</select> </select>
<select id="getByWarehouse" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseLogVo"> <select id="getByWarehouse" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseLogVo">
select DISTINCT CONCAT( gatewaytype,"_",gatewaySN) device, tgl.gatewaySN SN,gatewaytype type,w.warehouseNo select DISTINCT CONCAT(gatewaytype,"_",gatewaySN) device, tgl.gatewaySN SN,gatewaytype type,w.warehouseNo
from tdl_gateway_log tgl,warehouse w from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR} and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and ISNULL(endTime) and ISNULL(endTime)
</select> </select>
<select id="getByWarehouseNoAndTDLSNAndTime" parameterType="com.example.tdl.domain.vo.DownloadForWarehouseVo" resultType="com.example.tdl.domain.vo.ResultWarehouseNoAndTDLSNAndTimeVo">
SELECT TDLSN,gatewaySN,gatewayType,warehouseNo,alarmType,temMax,temMin,humidityMax,humidityMin
from tdl_gateway_log t INNER JOIN alarm a ON t.alarm_id=a.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND TDLSN=#{TDLSN,jdbcType=VARCHAR}
AND createTime BETWEEN #{startTime,jdbcType=VARCHAR} AND #{stopTime,jdbcType=VARCHAR}
</select>
</mapper> </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