Commit 77a148fb authored by 张大伟's avatar 张大伟

Merge branch 'develop' of http://103.249.252.28:90/wangxiahui/zhny into develop

# Conflicts:
#	src/main/java/org/rcisoft/business/device/assets/service/impl/BusDeviceServiceImpl.java
parents cffbb1fe 3766bfce
...@@ -3,6 +3,7 @@ package org.rcisoft.business.device.assets.controller; ...@@ -3,6 +3,7 @@ package org.rcisoft.business.device.assets.controller;
/*固定导入*/ /*固定导入*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -10,6 +11,7 @@ import org.apache.poi.hssf.usermodel.*; ...@@ -10,6 +11,7 @@ import org.apache.poi.hssf.usermodel.*;
import org.rcisoft.business.device.assets.entity.BusDevice; import org.rcisoft.business.device.assets.entity.BusDevice;
import org.rcisoft.business.device.assets.service.BusDeviceService; import org.rcisoft.business.device.assets.service.BusDeviceService;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo; import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.device.assets.vo.DeviceParamsVo;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController; import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.GridModel; import org.rcisoft.core.model.GridModel;
...@@ -37,6 +39,7 @@ import java.util.List; ...@@ -37,6 +39,7 @@ import java.util.List;
/** /**
* Created by on 2018-4-12 15:33:23. * Created by on 2018-4-12 15:33:23.
*/ */
@Api(tags = "项目评估--参数库")
@RestController @RestController
@RequestMapping("busdevice") @RequestMapping("busdevice")
public class BusDeviceController extends PaginationController<BusDevice> { public class BusDeviceController extends PaginationController<BusDevice> {
...@@ -172,6 +175,10 @@ public class BusDeviceController extends PaginationController<BusDevice> { ...@@ -172,6 +175,10 @@ public class BusDeviceController extends PaginationController<BusDevice> {
webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
} }
@ApiOperation(value="参数库导出", notes="参数库导出功能,需要将页面上的名称、编号以json对象数组的形式传到后台")
@RequestMapping("/downloadExcel")
public void downloadExcel(HttpServletResponse response, @RequestBody List<DeviceParamsVo> list) {
busDeviceServiceImpl.downloadExcel(response, list);
}
} }
...@@ -2,9 +2,11 @@ package org.rcisoft.business.device.assets.service; ...@@ -2,9 +2,11 @@ package org.rcisoft.business.device.assets.service;
import org.rcisoft.business.device.assets.entity.BusDevice; import org.rcisoft.business.device.assets.entity.BusDevice;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo; import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.device.assets.vo.DeviceParamsVo;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -82,4 +84,10 @@ public interface BusDeviceService { ...@@ -82,4 +84,10 @@ public interface BusDeviceService {
* @return * @return
*/ */
Integer addRunTime(); Integer addRunTime();
/**
* 参数库导出
* @param response
*/
void downloadExcel(HttpServletResponse response, List<DeviceParamsVo> list);
} }
package org.rcisoft.business.device.assets.service.impl; package org.rcisoft.business.device.assets.service.impl;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellType;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import org.rcisoft.business.device.assets.dao.BusDeviceRepository; import org.rcisoft.business.device.assets.dao.BusDeviceRepository;
import org.rcisoft.business.device.assets.service.BusDeviceService; import org.rcisoft.business.device.assets.service.BusDeviceService;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo; import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.device.assets.vo.DeviceParamsVo;
import org.rcisoft.business.manage.dao.BusLibraryParamRepository; import org.rcisoft.business.manage.dao.BusLibraryParamRepository;
import org.rcisoft.business.manage.entity.BusDevicetpParam; import org.rcisoft.business.manage.entity.BusDevicetpParam;
import org.rcisoft.business.manage.entity.BusLibraryParam; import org.rcisoft.business.manage.entity.BusLibraryParam;
...@@ -24,13 +29,20 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -24,13 +29,20 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletResponse;
/** /**
* Created by on 2018-4-12 15:33:23. * Created by on 2018-4-12 15:33:23.
*/ */
...@@ -236,4 +248,40 @@ public class BusDeviceServiceImpl implements BusDeviceService { ...@@ -236,4 +248,40 @@ public class BusDeviceServiceImpl implements BusDeviceService {
return 0; return 0;
} }
@Override
public void downloadExcel(HttpServletResponse response, List<DeviceParamsVo> list) {
try (OutputStream outputStream = response.getOutputStream()) {
response.setHeader("Content-disposition", "attachment;filename=download.xls");
outputStream.write(this.createExcel(list));
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
private byte[] createExcel(List<DeviceParamsVo> list) throws IOException {
HSSFWorkbook workbook = null;
try(ByteArrayOutputStream os = new ByteArrayOutputStream()) {
workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("sheet1");
//表头
String[] title = new String[]{"名称", "编号"};
HSSFRow title_row = sheet.createRow(0);
for (int i = 0; i < title.length; i++) {
title_row.createCell(i, CellType.STRING).setCellValue(title[i]);
}
//内容
for (int i = 0; i < list.size(); i++) {
HSSFRow row = sheet.createRow(i + 1);
DeviceParamsVo deviceParamsVo = list.get(i);
row.createCell(0, CellType.STRING).setCellValue(deviceParamsVo.getName());
row.createCell(1, CellType.STRING).setCellValue(deviceParamsVo.getNum());
}
workbook.write(os);
return os.toByteArray();
} finally {
workbook.close();
}
}
} }
package org.rcisoft.business.device.assets.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Created by JiChao on 2018/5/25.
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class DeviceParamsVo {
private String name;
private String num;
}
...@@ -85,6 +85,8 @@ public class AdaptiveServiceImpl implements AdaptiveService { ...@@ -85,6 +85,8 @@ public class AdaptiveServiceImpl implements AdaptiveService {
BigDecimal hswd = (BigDecimal) json.get(code_array[1]); BigDecimal hswd = (BigDecimal) json.get(code_array[1]);
//水流量 //水流量
BigDecimal sll = (BigDecimal) json.get(code_array[2]); BigDecimal sll = (BigDecimal) json.get(code_array[2]);
//如果其中任何一个数据为空,继续下一条
if (gswd == null || hswd == null || sll == null) return;
//公式计算 //公式计算
Float building = Math.abs(gswd.subtract(hswd).multiply(sll).multiply(new BigDecimal(4.12)).divide(new BigDecimal(3.6), 1, BigDecimal.ROUND_HALF_UP).floatValue()); Float building = Math.abs(gswd.subtract(hswd).multiply(sll).multiply(new BigDecimal(4.12)).divide(new BigDecimal(3.6), 1, BigDecimal.ROUND_HALF_UP).floatValue());
buildingList.set(hour, building); buildingList.set(hour, building);
......
...@@ -58,6 +58,7 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -58,6 +58,7 @@ public class BusProjectServiceImpl implements BusProjectService {
busProject.setProId(busProject.getJwnum()); busProject.setProId(busProject.getJwnum());
BusProject bus = new BusProject(); BusProject bus = new BusProject();
bus.setProId(busProject.getProId()); bus.setProId(busProject.getProId());
bus.setSysNm("暖通空调");
if(findByParam(bus)!=null && findByParam(bus).size()>0){ if(findByParam(bus)!=null && findByParam(bus).size()>0){
line = 0; line = 0;
message = "网关编号重复,项目新增失败"; message = "网关编号重复,项目新增失败";
......
...@@ -23,8 +23,7 @@ public interface EnergyPriceRepository extends BaseMapper<EnergyPriceVo> { ...@@ -23,8 +23,7 @@ public interface EnergyPriceRepository extends BaseMapper<EnergyPriceVo> {
* @return * @return
*/ */
@Select("<script>select e.P_HOUR,SUM(IF(e.P_TP=1, e.P_PRICE, 0)) as WATER,SUM(IF(e.P_TP=2, e.P_PRICE, 0)) as ELEC,SUM(IF(e.P_TP=3, e.P_PRICE, 0)) as GAS from energy_price e where e.PRO_ID=#{proId} and e.P_HOUR=#{pHour}</script>") @Select("<script>select e.P_HOUR,SUM(IF(e.P_TP=1, e.P_PRICE, 0)) as WATER,SUM(IF(e.P_TP=2, e.P_PRICE, 0)) as ELEC,SUM(IF(e.P_TP=3, e.P_PRICE, 0)) as GAS from energy_price e where e.PRO_ID=#{proId} and e.P_HOUR=#{pHour}</script>")
@ResultMap("BaseResultMap") List<Map<String,Object>> getPrice(@Param("proId") String proId,@Param("pHour") String pHour);
EnergyPriceVo getPrice(@Param("proId") String proId,@Param("pHour") String pHour);
/** /**
* 查询项目能耗价格 * 查询项目能耗价格
......
...@@ -20,7 +20,7 @@ public interface OverViewService { ...@@ -20,7 +20,7 @@ public interface OverViewService {
* @param proId * @param proId
* @return * @return
*/ */
EnergyPriceVo getPrice(String proId); List<Map<String,Object>> getPrice(String proId);
/** /**
* 用量和费用统计,当日或当月 * 用量和费用统计,当日或当月
......
...@@ -292,7 +292,7 @@ public class OverViewServiceImpl implements OverViewService { ...@@ -292,7 +292,7 @@ public class OverViewServiceImpl implements OverViewService {
} }
@Override @Override
public EnergyPriceVo getPrice(String proId) { public List<Map<String,Object>> getPrice(String proId) {
int i = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); int i = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
return overViewRepository.getPrice(proId,String.valueOf(i)); return overViewRepository.getPrice(proId,String.valueOf(i));
} }
......
...@@ -41,11 +41,15 @@ public interface UserRepository extends BaseMapper<SysUser>{ ...@@ -41,11 +41,15 @@ public interface UserRepository extends BaseMapper<SysUser>{
* 查询所有用户 * 查询所有用户
* @return * @return
*/ */
@Select("<script>select a.USER_ID,a.USER_NM,a.USER_TP,b.* from sys_user a left join ${stable} b on a.USER_ID = b.USER_ID where" + @Select("<script>select a.USER_ID,a.USER_NM,a.USER_TP " +
" 1=1" + "<if test=\"stable != null\">,b.*</if> " +
"from sys_user a " +
"<if test=\"stable != null\">left join ${stable} b on a.USER_ID = b.USER_ID </if> " +
"where 1=1" +
"<if test = \"userTp=='1'.toString()\"> and (user_tp = '1' or user_tp = '2')</if>" + "<if test = \"userTp=='1'.toString()\"> and (user_tp = '1' or user_tp = '2')</if>" +
"<if test = \"userTp=='2'.toString()\"> and user_tp = '3'</if>" + "<if test = \"userTp=='2'.toString()\"> and user_tp = '3'</if>" +
"<if test = \"userTp=='3'.toString()\"> and user_tp = '4'</if></script>") "<if test = \"userTp=='3'.toString()\"> and user_tp = '4'</if>" +
"<if test = \"userTp=='5'.toString()\"> and user_tp = '5'</if></script>")
List<Map<String,Object>> listUserAll(@Param("stable") String stable,@Param("userTp") String userTp); List<Map<String,Object>> listUserAll(@Param("stable") String stable,@Param("userTp") String userTp);
} }
...@@ -33,7 +33,7 @@ public class SysUser { ...@@ -33,7 +33,7 @@ public class SysUser {
private String userTp; private String userTp;
private String userNickname; private String userNickName;
private String openid; private String openid;
......
...@@ -135,7 +135,7 @@ public class UserServiceImpl implements UserService { ...@@ -135,7 +135,7 @@ public class UserServiceImpl implements UserService {
flag = 1; flag = 1;
} }
if(UserTpConstant.TP_INSPECTPERSON.equals(userTp)){ if(UserTpConstant.TP_INSPECTPERSON.equals(userTp)){
userRepository.insertSelective(sysUser); flag = userRepository.insertSelective(sysUser);
} }
return flag; return flag;
} catch (Exception e) { } catch (Exception e) {
...@@ -175,6 +175,9 @@ public class UserServiceImpl implements UserService { ...@@ -175,6 +175,9 @@ public class UserServiceImpl implements UserService {
flag = 1; flag = 1;
} }
} }
if (UserTpConstant.TP_INSPECTPERSON.equals(userTp)) {
flag = userRepository.updateByPrimaryKeySelective(sysUser);
}
return flag; return flag;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -339,7 +342,7 @@ public class UserServiceImpl implements UserService { ...@@ -339,7 +342,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public List<Map<String, Object>> listUserAllByPagination(PageUtil<SysUser> paginationUtility,String userTp) { public List<Map<String, Object>> listUserAllByPagination(PageUtil<SysUser> paginationUtility,String userTp) {
String table = ""; String table = null;
if(userTp!=null && userTp.equals("1")){table = "sys_admins";} if(userTp!=null && userTp.equals("1")){table = "sys_admins";}
if(userTp!=null && userTp.equals("2")){table = "sys_owner";} if(userTp!=null && userTp.equals("2")){table = "sys_owner";}
if(userTp!=null && userTp.equals("3")){table = "sys_principal";} if(userTp!=null && userTp.equals("3")){table = "sys_principal";}
......
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