Commit d190a75e authored by 王夏晖's avatar 王夏晖

修改设备类型及设备列表的查询,关联模板一起查出来

parent 55598f3f
......@@ -23,10 +23,9 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
*
*/
@Select("<script>select * from bus_device where 1=1 and pro_id = #{proId} " +
"<if test=''></if>"
"<if test='devTpId != null'> and dev_tp_id = #{devTpId}</if>"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BusDevice> queryBusDevices(BusDevice busDevice);
List<Map<String,Object>> queryBusDevices(BusDevice busDevice);
/*
通过项目id与子系统id获取子系统中的所有设备
......
......@@ -6,6 +6,7 @@ import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-4-12 15:33:23.
......@@ -45,8 +46,8 @@ public interface BusDeviceService {
* @param busDevice
* @return
*/
List<BusDevice> findAllByPagination(PageUtil<BusDevice> paginationUtility,
BusDevice busDevice);
List<Map<String,Object>> findAllByPagination(PageUtil<BusDevice> paginationUtility,
BusDevice busDevice);
/**
*通过项目id与子系统id获取系统中所有的设备
......
......@@ -4,6 +4,7 @@ import org.rcisoft.business.device.assets.dao.BusDeviceRepository;
import org.rcisoft.business.device.assets.service.BusDeviceService;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.manage.entity.BusDevicetpParam;
import org.rcisoft.business.manage.service.BusDeviceParamService;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.device.assets.entity.BusDevice;
......@@ -33,6 +34,8 @@ public class BusDeviceServiceImpl implements BusDeviceService {
@Autowired
private BusDeviceRepository busDeviceRepository;
@Autowired
private BusDeviceParamService busDeviceParamService;
/**
......@@ -105,11 +108,15 @@ public class BusDeviceServiceImpl implements BusDeviceService {
* @return
*/
@Override
public List<BusDevice> findAllByPagination(PageUtil<BusDevice> paginationUtility,
public List<Map<String,Object>> findAllByPagination(PageUtil<BusDevice> paginationUtility,
BusDevice busDevice){
//避免查出所有设备
if(busDevice.getProId()!=null && !busDevice.getProId().equals("")){
return busDeviceRepository.queryBusDevices(busDevice);
List<Map<String,Object>> list = busDeviceRepository.queryBusDevices(busDevice);
for(Map<String,Object> tmap : list){
tmap.put("paramList",busDeviceParamService.findByDev(tmap.get("DEV_NUM").toString(),tmap.get("PRO_ID").toString()));
}
return list;
}
return null;
}
......
......@@ -35,10 +35,9 @@ public class BusEnergyPlanController extends PaginationController<BusEnergyPlan>
private BusEnergyPlanService busEnergyPlanServiceImpl;
@ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@ApiOperation(value="添加能耗计划", notes="添加能耗计划")
@PostMapping(value = "/add")
public Result add(@Valid EnergyPlanList energyPlanlist) throws Exception{
public Result add(@RequestBody EnergyPlanList energyPlanlist) throws Exception{
List<EnergyPlanVo> epList = energyPlanlist.getEnergyPlanVoList();
for(EnergyPlanVo energyPlanVo : epList){
busEnergyPlanServiceImpl.save(energyPlanVo);
......@@ -49,43 +48,14 @@ public class BusEnergyPlanController extends PaginationController<BusEnergyPlan>
null);
}
@ApiOperation(value="逻辑删除", notes="逻辑删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@DeleteMapping("/delete/{id:\\w+}")
public Result delete(@PathVariable String id) {
BusEnergyPlan busEnergyPlan = new BusEnergyPlan();
PersistModel data = busEnergyPlanServiceImpl.remove(busEnergyPlan);
@ApiOperation(value="删除设备某一天的能耗计划", notes="删除设备某一天的能耗计划")
@DeleteMapping("/delete")
public Result delete(@RequestParam String devNum,@RequestParam String day) {
PersistModel data = busEnergyPlanServiceImpl.remove(devNum,day);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
id);
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/update/{id:\\w+}")
public Result update(@Valid BusEnergyPlan busEnergyPlan, BindingResult bindingResult) {
PersistModel data = busEnergyPlanServiceImpl.merge(busEnergyPlan);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busEnergyPlan);
}
@ApiOperation(value="查看单 ", notes="查看单 ")
@GetMapping("/detail/{id:\\w+}")
public Result detail(@PathVariable int id) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busEnergyPlanServiceImpl.findById(id));
}
@ApiOperation(value="查看 集合", notes="查看 集合")
@GetMapping(value = "/queryBusEnergyPlanByPagination")
public GridModel listByPagination(BusEnergyPlan busEnergyPlan) {
busEnergyPlanServiceImpl.findAllByPagination(getPaginationUtility(), busEnergyPlan);
return getGridModelResponse();
null);
}
@ApiOperation(value="根据项目查询某一天计划总能耗", notes="根据项目查询某一天计划总能耗")
......
......@@ -148,5 +148,13 @@ public interface BusEnergyPlanRepository extends BaseMapper<BusEnergyPlan> {
"where PRO_ID = #{pro_id} and DATE_FORMAT(tm,'%Y-%m-%d') = #{day}" +
"</script>")
List<Map<String,Object>> querySensor(Map<String,Object> map);
/**
* 根据设备编号和日期删除某一天该设备的用能计划
* @param map
* @return
*/
@Select("<script>delete from bus_energy_plan where dev_num = #{dev_num} and DATE_FORMAT(tm,'%Y-%m-%d') = #{day}</script>")
void deleteEnergyPlanDay(Map<String,Object> map);
}
......@@ -5,6 +5,7 @@ import org.rcisoft.business.mainte.energyplan.entity.BusEnergyPlan;
import org.rcisoft.business.mainte.energyplan.vo.EnergyPlanVo;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
......@@ -22,33 +23,11 @@ public interface BusEnergyPlanService {
PersistModel save(EnergyPlanVo energyPlan)throws Exception;
/**
* 逻辑删除
* @param busEnergyPlan
* 删除能耗计划
* @return
*/
PersistModel remove(BusEnergyPlan busEnergyPlan);
PersistModel remove(String devNum,String day);
/**
* 修改
* @param busEnergyPlan
* @return
*/
PersistModel merge(BusEnergyPlan busEnergyPlan);
/**
* 根据id查询
* @param id
* @return
*/
BusEnergyPlan findById(int id);
/**
* 分页查询
* @param busEnergyPlan
* @return
*/
List<BusEnergyPlan> findAllByPagination(PageUtil<BusEnergyPlan> paginationUtility,
BusEnergyPlan busEnergyPlan);
/**
* 根据项目查询某一天的电、气的总能耗
......
......@@ -25,6 +25,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;
/**
* Created by on 2018-4-17 17:47:37.
......@@ -115,46 +116,24 @@ public class BusEnergyPlanServiceImpl implements BusEnergyPlanService {
/**
* 逻辑删除
* @param busEnergyPlan
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BusEnergyPlan busEnergyPlan){
int line = busEnergyPlanRepository.logicalDelete(busEnergyPlan);
return new PersistModel(line);
}
/**
* 修改 busEnergyPlan
* @param busEnergyPlan
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(BusEnergyPlan busEnergyPlan){
int line = busEnergyPlanRepository.updateByPrimaryKeySelective(busEnergyPlan);
public PersistModel remove(String devNum,String day){
int line = 1;
Map<String,Object> map = new HashMap<>();
map.put("dev_num",devNum);
map.put("day",day);
try {
busEnergyPlanRepository.deleteEnergyPlanDay(map);
}catch(Exception e){
line = 0;
}
return new PersistModel(line);
}
/**
* 根据id查询 busEnergyPlan
* @param id
* @return
*/
public BusEnergyPlan findById(int id){
return busEnergyPlanRepository.selectByPrimaryKey(id);
}
/**
* 分页查询 busEnergyPlan
* @param busEnergyPlan
* @return
*/
public List<BusEnergyPlan> findAllByPagination(PageUtil<BusEnergyPlan> paginationUtility,
BusEnergyPlan busEnergyPlan){
return busEnergyPlanRepository.queryBusEnergyPlans(busEnergyPlan);
}
@Override
public List<Map<String, Object>> queryEnergyPlanDay(String proid, String day) {
......
......@@ -88,4 +88,15 @@ public class ParamLibraryController {
MessageConstant.MESSAGE_ALERT_ERROR,
busParamLibraryList);
}
@ApiOperation(value="清空设备参数库", notes="清空设备参数库")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/delete")
public Result delete(@RequestParam String devNum) {
PersistModel data = paramLibraryService.delete(devNum);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
devNum);
}
}
......@@ -19,4 +19,6 @@ public interface ParamLibraryService {
List<Map<String,Object>> queryParamLibrary(Map<String,Object> map);
PersistModel save(BusParamLibraryList busPramLibraryList);
PersistModel delete(String devNum);
}
......@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -70,4 +71,13 @@ public class ParamLibraryServiceImpl implements ParamLibraryService {
}
return new PersistModel(1);
}
@Override
public PersistModel delete(String devNum) {
Example example = new Example(BusParamLibrary.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("devNum",devNum);
int line = paramLibraryRepository.deleteByExample(example);
return new PersistModel(line);
}
}
......@@ -41,7 +41,7 @@ public class BusDeviceParamController extends PaginationController<BusDevicePara
@ApiOperation(value="修改设备参数模板", notes="修改设备参数模板")
@PutMapping("/update")
public Result update(@Valid BusDeviceParamList busDeviceParamList) {
public Result update(@RequestBody BusDeviceParamList busDeviceParamList) {
PersistModel data = busDeviceParamServiceImpl.merge(busDeviceParamList);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -49,6 +49,23 @@ public class BusDeviceParamController extends PaginationController<BusDevicePara
busDeviceParamList);
}
@ApiOperation(value="添加或修改设备参数模板", notes="添加或修改设备参数模板")
@PutMapping("/saveOrupdate")
public Result saveOrupdate(@RequestBody BusDeviceParamList busDeviceParamList,@RequestParam String proId) {
PersistModel data = null;
String devNum = busDeviceParamList.getBusDeviceParamList().get(0).getDevNum();
List<Map<String,Object>> list = busDeviceParamServiceImpl.findByDev(devNum,proId);
if(list.size()>0){
data = busDeviceParamServiceImpl.merge(busDeviceParamList);
}else{
data = busDeviceParamServiceImpl.save(busDeviceParamList);
}
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDeviceParamList);
}
@ApiOperation(value="删除设备参数模板", notes="删除设备参数模板")
@PutMapping("/delete")
public Result delete(@RequestParam String devNum) {
......
......@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-5-2 16:09:29.
......@@ -59,7 +60,7 @@ public class BusDeviceTpController extends PaginationController<BusDeviceTp> {
@ApiOperation(value="设备类型列表", notes="设备类型列表")
@GetMapping(value = "/queryBusDeviceTpList")
public List<BusDeviceTp> queryBusDeviceTpList(BusDeviceTp busDeviceTp) {
return busDeviceTpServiceImpl.queryBusDeviceTpList();
public List<Map<String,Object>> queryBusDeviceTpList(@RequestParam String proId) {
return busDeviceTpServiceImpl.queryBusDeviceTpList(proId);
}
}
......@@ -48,7 +48,7 @@ public class BusDevicetpParamController extends PaginationController<BusDevicetp
*/
@ApiOperation(value="修改设备类型模板", notes="修改设备类型模板")
@PostMapping(value = "/update")
public Result update(@Valid BusDevicetpParamList busDevicetpParamList) {
public Result update(@RequestBody BusDevicetpParamList busDevicetpParamList) {
PersistModel data = busDevicetpParamServiceImpl.update(busDevicetpParamList);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -56,6 +56,22 @@ public class BusDevicetpParamController extends PaginationController<BusDevicetp
busDevicetpParamList);
}
@ApiOperation(value="添加或修改设备类型模板", notes="添加或修改设备类型模板")
@PostMapping(value = "/saveOrUpdate")
public Result saveOrUpdate(@RequestBody BusDevicetpParamList busDevicetpParamList) {
PersistModel data = null;
List<BusDevicetpParam> list = busDevicetpParamServiceImpl.queryBusDevicetpParam(busDevicetpParamList.getBusDevicetpParamList().get(0));
if(list.size()>0){
data = busDevicetpParamServiceImpl.update(busDevicetpParamList);
}else{
data = busDevicetpParamServiceImpl.save(busDevicetpParamList);
}
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDevicetpParamList);
}
/**
* 删除模板
* @return
......
......@@ -28,7 +28,7 @@ public class BusProjectController extends PaginationController<BusProject> {
private BusProjectService busProjectServiceImpl;
@ApiOperation(value="添加", notes="添加")
@ApiOperation(value="添加项目", notes="添加项目")
@PostMapping(value = "/add")
public Result add(@Valid BusProject busProject) {
PersistModel data = busProjectServiceImpl.save(busProject);
......@@ -39,7 +39,7 @@ public class BusProjectController extends PaginationController<BusProject> {
}
@ApiOperation(value="修改", notes="修改")
@ApiOperation(value="修改项目信息", notes="修改项目信息")
@PutMapping("/update")
public Result update(@Valid BusProject busProject) {
PersistModel data = busProjectServiceImpl.merge(busProject);
......@@ -61,9 +61,9 @@ public class BusProjectController extends PaginationController<BusProject> {
busProject);
}
@ApiOperation(value="查看单 ", notes="查看单 ")
@GetMapping("/detail/{id:\\w+}")
public Result detail(@PathVariable String id) {
@ApiOperation(value="根据ID查询单个项目信息", notes="根据ID查询单个项目信息")
@GetMapping("/detail")
public Result detail(@RequestParam String id) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
......@@ -21,8 +21,7 @@ public interface BusDeviceTpRepository extends BaseMapper<BusDeviceTp> {
*/
@Select("<script>select * from bus_device_tp where 1=1 "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BusDeviceTp> queryBusDeviceTps();
List<Map<String,Object>> queryBusDeviceTps();
/**
* 查看该设备类型是否配置模板
......
......@@ -56,6 +56,8 @@ public class BusProject{
private BigDecimal energyPotential;
private String topology;
private BigDecimal shutPower;
}
......@@ -34,7 +34,7 @@ public interface BusDeviceParamService {
* 根据设备编号查询设备参数模板
* @return
*/
List<Map<String,Object>> findByDev(String devid,String proid);
List<Map<String,Object>> findByDev(String devNum,String proid);
......
......@@ -4,6 +4,7 @@ import org.rcisoft.business.manage.entity.BusDeviceTp;
import org.rcisoft.core.model.PersistModel;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-5-2 16:09:29.
......@@ -36,7 +37,7 @@ public interface BusDeviceTpService {
* 列表
* @return
*/
List<BusDeviceTp> queryBusDeviceTpList();
List<Map<String,Object>> queryBusDeviceTpList(String proId);
......
......@@ -5,6 +5,7 @@ import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-5-2 16:09:30.
......@@ -38,7 +39,7 @@ public interface BusProjectService {
* @param id
* @return
*/
List<BusProject> findById(String id);
List<Map<String,Object>> findById(String id);
/**
* 分页查询
......
......@@ -3,8 +3,10 @@ package org.rcisoft.business.manage.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.manage.dao.BusDeviceTpRepository;
import org.rcisoft.business.manage.entity.BusDeviceTp;
import org.rcisoft.business.manage.entity.BusDevicetpParam;
import org.rcisoft.business.manage.entity.BusProject;
import org.rcisoft.business.manage.service.BusDeviceTpService;
import org.rcisoft.business.manage.service.BusDevicetpParamService;
import org.rcisoft.core.model.PersistModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -28,6 +30,8 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService {
@Autowired
private BusDeviceTpRepository busDeviceTpRepository;
@Autowired
private BusDevicetpParamService busDevicetpParamService;
/**
......@@ -75,8 +79,15 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService {
}
@Override
public List<BusDeviceTp> queryBusDeviceTpList() {
return busDeviceTpRepository.queryBusDeviceTps();
public List<Map<String,Object>> queryBusDeviceTpList(String proId) {
List<Map<String,Object>> list = busDeviceTpRepository.queryBusDeviceTps();
for(Map<String,Object> tmap : list){
BusDevicetpParam bdp = new BusDevicetpParam();
bdp.setDevTpId(tmap.get("DEV_TP_ID").toString());
bdp.setProId(proId);
tmap.put("paramList",busDevicetpParamService.queryBusDevicetpParam(bdp));
}
return list;
}
......
......@@ -3,6 +3,7 @@ package org.rcisoft.business.manage.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.manage.entity.BusProject;
import org.rcisoft.business.manage.service.BusProjectService;
import org.rcisoft.business.overview.dao.BusProjectRepository;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.manage.dao.ProjectRepository;
......@@ -27,6 +28,8 @@ public class BusProjectServiceImpl implements BusProjectService {
@Autowired
private ProjectRepository projectRepository;
@Autowired
private BusProjectRepository busProjectRepository;
/**
......@@ -80,10 +83,10 @@ public class BusProjectServiceImpl implements BusProjectService {
* @param id
* @return
*/
public List<BusProject> findById(String id){
BusProject bus = new BusProject();
public List<Map<String,Object>> findById(String id){
org.rcisoft.business.overview.entity.BusProject bus = new org.rcisoft.business.overview.entity.BusProject();
bus.setProId(id);
return projectRepository.queryBusProjects(bus);
return busProjectRepository.queryBusProjects(bus);
}
/**
......
......@@ -9,6 +9,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with on 2018-4-14 10:15:52.
......@@ -20,9 +21,18 @@ public interface BusProjectRepository extends BaseMapper<BusProject> {
* 查询项目信息
* @return
*/
@Select("<script>select * from bus_project</script>")
@ResultMap(value = "BaseResultMap" )
List<BusProject> queryBusProjects();
@Select("<script>SELECT\n" +
"\ta.*,e.SYS_NM,b.BLD_TP_NM,c.OWN_NM,d1.TEAM_NM TEAM_NM_ON,d2.TEAM_NM TEAM_NM_OFF\n" +
"FROM bus_project a \n" +
"LEFT JOIN bus_build_tp b ON a.BLD_TP_ID = b.BLD_TP_ID\n" +
"LEFT JOIN sys_owner c ON a.OWN_ID = c.OWN_ID\n" +
"LEFT JOIN bus_team d1 on a.TEAM_ID_ON = d1.TEAM_ID\n" +
"LEFT JOIN bus_team d2 on a.TEAM_ID_OFF = d2.TEAM_ID\n" +
"LEFT JOIN bus_system e on a.PRO_ID = e.PRO_ID\n" +
"where 1=1 " +
"<if test =' proId != null '> and a.pro_id = #{proId}</if>" +
"</script>")
List<Map<String,Object>> queryBusProjects(BusProject busProject);
@Select("<script>select distinct code from bus_project</script>")
@ResultType(String.class)
......
......@@ -30,6 +30,17 @@ public class Result {
return result;
}
public static Result builder(PersistModel dataModel){
Result result = new Result();
result.setMessage(dataModel.getInfluenceReason());
if(dataModel.isSuccessBySinglePersist()){
result.setCode(200);
} else{
result.setCode(500);
}
return result;
}
public void setErrorMessage(String message, Object data) {
......
......@@ -19,6 +19,8 @@
<result column="BLD_YEAR" jdbcType="TIMESTAMP" property="bldYear"/>
<result column="DEVICE_YEAR" jdbcType="TIMESTAMP" property="deviceYear"/>
<result column="ENERGY_POTENTIAL" jdbcType="DECIMAL" property="energyPotential"/>
<result column="TOPOLOGY" jdbcType="VARCHAR" property="topology"/>
<result column="SHUT_POWER" jdbcType="DECIMAL" property="shutPower"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
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