Commit 29f23585 authored by gaoliwei's avatar gaoliwei

Merge branch 'develop' of ssh://103.249.252.28:10022/wangxiahui/zhny into develop

parents 790fd9e1 c0f1a84e
package org.rcisoft.business.device.maintenance.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.device.maintenance.entity.BusDevService;
import org.rcisoft.business.device.maintenance.service.MaintenanceService;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @author: WangXinYu
* @describe: 设备————养护计划Controller
* @create: 2018年04月20日 15:10
**/
@RestController
@RequestMapping("maintenance")
public class MaintenanceController {
@Autowired
MaintenanceService maintenanceService;
@ApiOperation(value = "添加维护记录", notes = "添加维护记录")
@PostMapping(value = "/add")
public Result add(@Valid BusDevService busDevService, BindingResult bindingResult) {
int i = maintenanceService.saveBusDevService(busDevService);
if (i > 0) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDevService);
}
return null;
}
@ApiOperation(value = "删除维护记录", notes = "删除维护记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "serId", value = "serId", required = true, paramType = "query", dataType = "varchar"),
})
@PostMapping(value = "/delete")
public Result delete(@RequestParam String serId) {
int i = maintenanceService.deleteBusDevServiceById(serId);
if (i > 0) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
serId);
}
return null;
}
@ApiOperation(value = "查询所有的设备种类", notes = "查询所有的设备种类")
@GetMapping(value = "/listDeviceCategory")
public Result listDeviceCategory() {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
maintenanceService.listDeviceCategory());
}
@ApiOperation(value = "根据设备种类id查询该种类的设备", notes = "根据设备种类id查询该种类的设备")
@ApiImplicitParams({
@ApiImplicitParam(name = "tpId", value = "tpId", required = true, paramType = "query", dataType = "varchar"),
})
@GetMapping(value = "/listDeviceByTpId")
public Result listDeviceByTpId(@RequestParam String tpId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
maintenanceService.listDeviceByTpId(tpId));
}
@ApiOperation(value = "根据日期(YYYY-mm-dd格式) 查询维修记录", notes = "根据日期(YYYY-mm-dd格式) 查询维修记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "date", value = "date", required = true, paramType = "query", dataType = "varchar"),
})
@GetMapping(value = "/listBusDevServiceByDate")
public Result listBusDevServiceByDate(@RequestParam String date) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
maintenanceService.listBusDevServiceByDate(date));
}
@ApiOperation(value = "根据年份 查询维修记录", notes = "根据年份 查询维修记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "year", value = "year", required = true, paramType = "query", dataType = "varchar"),
})
@GetMapping(value = "/listBusDevServiceByYear")
public Result listBusDevServiceByYear(@RequestParam String year) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
maintenanceService.listBusDevServiceByYear(year));
}
}
package org.rcisoft.business.device.maintenance.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.device.maintenance.entity.BusDevService;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.BaseMapper;
import java.util.List;
import java.util.Map;
/**
* The interface Maintenance repository.
*
* @author: WangXinYu
* @describe: TODO
* @create: 2018年04月20日 15:14
*/
@Repository
public interface MaintenanceRepository extends BaseMapper<BusDevService> {
/**
* List device category list.
* 查询设备种类名
*
* @return the list
*/
@Select("SELECT * FROM `bus_device_tp` ")
List<Map<String,Object>> listDeviceCategory();
/**
* List device by tp id list.
* 根据类型id 查询设备
*
* @param tpID the tp id
* @return the list
*/
@Select("SELECT * FROM bus_device WHERE DEV_TP_ID = #{tpID}")
List<Map<String,Object>> listDeviceByTpId(@Param("tpID") String tpID);
/**
* List device inspect by date list.
* 根据日期(YYYY-mm-dd格式) 查询维修记录
*
* @param date the date
* @return the list
*/
@Select("SELECT * FROM `bus_dev_service` WHERE DATE_FORMAT(SER_TM,'%Y-%m-%d') = #{date}")
List<Map<String,Object>> listBusDevServiceByDate(@Param("date") String date);
/**
* List bus dev service by year list.
* 根据年份 查询维修记录
* @param year the year
* @return the list
*/
@Select("SELECT ds.*,d.DEV_NM,tp.DEV_TP_NM FROM bus_dev_service ds INNER JOIN bus_device d on d.DEV_NUM = ds.DEV_NUM INNER JOIN bus_device_tp tp ON tp.DEV_TP_ID=d.DEV_TP_ID WHERE DATE_FORMAT(SER_TM,'%Y') = #{year}")
List<Map<String,Object>> listBusDevServiceByYear(@Param("year") String year);
/**
* Delete device inspect int.
* 删除设备维修记录
*
* @param id the id
* @return the int
*/
@Delete("DELETE FROM bus_dev_service WHERE SER_ID = #{id}")
int deleteBusDevServiceById(@Param("id") String id);
}
package org.rcisoft.business.device.maintenance.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* @author WangXinYu
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_dev_service")
public class BusDevService {
@Id
private String serId;
private String serPrincipal;
private String devNum;
private Date serTm;
private String serContent;
private String note;
public String getSerId() {
return serId;
}
public void setSerId(String serId) {
this.serId = serId;
}
public String getSerPrincipal() {
return serPrincipal;
}
public void setSerPrincipal(String serPrincipal) {
this.serPrincipal = serPrincipal;
}
public String getDevNum() {
return devNum;
}
public void setDevNum(String devNum) {
this.devNum = devNum;
}
public Date getSerTm() {
return serTm;
}
public void setSerTm(Date serTm) {
this.serTm = serTm;
}
public String getSerContent() {
return serContent;
}
public void setSerContent(String serContent) {
this.serContent = serContent;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
}
package org.rcisoft.business.device.maintenance.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* The type Bus device inspect.
* @author WangXinYu
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_device_inspect")
public class BusDeviceInspect {
@Id
private String insId;
private String devNum;
private String inspector;
private String inspPrincipal;
private Date inspTm;
private String inspContent;
private String flag;
public String getInsId() {
return insId;
}
public void setInsId(String insId) {
this.insId = insId;
}
public String getDevNum() {
return devNum;
}
public void setDevNum(String devNum) {
this.devNum = devNum;
}
public String getInspector() {
return inspector;
}
public void setInspector(String inspector) {
this.inspector = inspector;
}
public String getInspPrincipal() {
return inspPrincipal;
}
public void setInspPrincipal(String inspPrincipal) {
this.inspPrincipal = inspPrincipal;
}
public Date getInspTm() {
return inspTm;
}
public void setInspTm(Date inspTm) {
this.inspTm = inspTm;
}
public String getInspContent() {
return inspContent;
}
public void setInspContent(String inspContent) {
this.inspContent = inspContent;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}
package org.rcisoft.business.device.maintenance.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* @author WangXinYu
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_device_tp")
public class BusDeviceTp implements Serializable {
@Id
private String devTpId;
private String devTpNm;
public String getDevTpId() {
return devTpId;
}
public void setDevTpId(String devTpId) {
this.devTpId = devTpId;
}
public String getDevTpNm() {
return devTpNm;
}
public void setDevTpNm(String devTpNm) {
this.devTpNm = devTpNm;
}
}
package org.rcisoft.business.device.maintenance.service;
import org.rcisoft.business.device.maintenance.entity.BusDevService;
import java.util.List;
import java.util.Map;
/**
* The interface Maintenance service.
*
* @author: WangXinYu
* @describe: TODO
* @create: 2018年04月20日 15:31
*/
public interface MaintenanceService {
/**
* Save bus dev service int.
* 新增 维修记录
*
* @param busDevService the bus dev service
* @return the int
*/
int saveBusDevService(BusDevService busDevService);
/**
* Delete bus dev service by id int.
* 删除维修记录
*
* @param id the id
* @return the int
*/
int deleteBusDevServiceById(String id);
/**
* List device category list.
* 查询所有的设备种类
*
* @return the list
*/
List<Map<String,Object>> listDeviceCategory();
/**
* List device by tp id list.
* 根据设备种类id查询该种类的设备
*
* @param tpID the tp id
* @return the list
*/
List<Map<String,Object>> listDeviceByTpId(String tpID);
/**
* List bus device service by date list.
* 根据日期(YYYY-mm-dd格式) 查询维修记录
*
* @param date the date
* @return the list
*/
List<Map<String,Object>> listBusDevServiceByDate(String date);
/**
* List bus dev service by year list.
* 根据年份 查询维修记录
* @param year the year
* @return the list
*/
List<Map<String,Object>> listBusDevServiceByYear(String year);
}
package org.rcisoft.business.device.maintenance.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.device.maintenance.dao.MaintenanceRepository;
import org.rcisoft.business.device.maintenance.entity.BusDevService;
import org.rcisoft.business.device.maintenance.service.MaintenanceService;
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 java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @author: WangXinYu
* @describe: TODO
* @create: 2018年04月20日 15:32
**/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class MaintenanceServiceImpl implements MaintenanceService {
@Autowired
MaintenanceRepository maintenanceRepository;
/**
* 插入维修记录
* @param busDevService
* @return
*/
@Override
public int saveBusDevService(BusDevService busDevService) {
busDevService.setSerTm(new Date());
busDevService.setSerId(UUID.randomUUID().toString().replaceAll("-","").toUpperCase());
int i= 0;
try {
i = maintenanceRepository.insertSelective(busDevService);
} catch (Exception e) {
e.printStackTrace();
}
return i;
}
/**
* 删除设备维修记录
* @param id
* @return
*/
@Override
public int deleteBusDevServiceById(String id) {
int i = maintenanceRepository.deleteBusDevServiceById(id);
return i;
}
/**
* 查询所有设备种类
* @return busDeviceTps
*/
@Override
public List<Map<String,Object>> listDeviceCategory() {
List<Map<String,Object>> busDeviceTps=maintenanceRepository.listDeviceCategory();
return busDeviceTps;
}
/**
* 根据设备种类id查询该种类所有的设备
* @param tpID the tp id
* @return busDevices
*/
@Override
public List<Map<String,Object>> listDeviceByTpId(String tpID) {
List<Map<String,Object>> busDevices = maintenanceRepository.listDeviceByTpId(tpID);
return busDevices;
}
/**
* 根据日期(YYYY-mm-dd格式) 查询维修记录
* @param date the date
* @return
*/
@Override
public List<Map<String,Object>> listBusDevServiceByDate(String date) {
List<Map<String,Object>> busDevServices = maintenanceRepository.listBusDevServiceByDate(date);
return busDevServices;
}
/**
* 根据 年份查询维修记录
* @param year the year
* @return
*/
@Override
public List<Map<String,Object>> listBusDevServiceByYear(String year) {
List<Map<String,Object>> busDevServices = maintenanceRepository.listBusDevServiceByYear(year);
return busDevServices;
}
}
......@@ -16,17 +16,17 @@ import java.util.List;
@Repository
public interface BusProjectAreaRepository extends BaseMapper<BusProjectArea> {
/**
* 查询水电气的用量标准信息、建筑面积
* @param busProjectArea
* @return
*/
@Select("<script>select * from bus_project_area b where b.PRO_ID=#{proId}</script>")
@ResultMap(value = "BaseResultMap")
List<BusProjectArea> queryBusProjectAreas(BusProjectArea busProjectArea);
@Select("<script>select SUM(IF(b.TYPE=1, b.AREA, 0)) as WATER_AREA,SUM(IF(b.TYPE=2, b.AREA, 0)) as ELEC_AREA,SUM(IF(b.TYPE=3, b.AREA, 0)) as GAS_AREA from bus_project_area b where b.PRO_ID=#{proId}</script>")
@ResultMap(value = "vo")
BusProjectAreaVo classifyProjectArea(String proId);
// /**
// * 查询水电气的用量标准信息、建筑面积
// * @param busProjectArea
// * @return
// */
// @Select("<script>select * from bus_project_area b where b.PRO_ID=#{proId}</script>")
// @ResultMap(value = "BaseResultMap")
// List<BusProjectArea> queryBusProjectAreas(BusProjectArea busProjectArea);
//
// @Select("<script>select SUM(IF(b.TYPE=1, b.AREA, 0)) as WATER_AREA,SUM(IF(b.TYPE=2, b.AREA, 0)) as ELEC_AREA,SUM(IF(b.TYPE=3, b.AREA, 0)) as GAS_AREA from bus_project_area b where b.PRO_ID=#{proId}</script>")
// @ResultMap(value = "vo")
// BusProjectAreaVo classifyProjectArea(String proId);
}
......@@ -26,8 +26,8 @@ public class BusProjectArea implements Serializable {
private String proId;
private Float area;
// private Float area;
//
private String type;
private Float industryStd;
......
......@@ -2,12 +2,10 @@ package org.rcisoft.business.overview.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.rcisoft.business.overview.dao.*;
import org.rcisoft.business.overview.entity.*;
import org.rcisoft.business.overview.service.OverViewService;
import org.rcisoft.business.overview.vo.BusEnergyPlanVo;
import org.rcisoft.business.overview.vo.BusProjectAreaVo;
import org.rcisoft.business.overview.vo.EnergyCountMVo;
import org.rcisoft.business.overview.vo.EnergyPriceVo;
import org.rcisoft.core.model.PersistModel;
......@@ -359,7 +357,7 @@ public class OverViewServiceImpl implements OverViewService {
public Map<String, Object> getStandard(String proId) {
BusProjectArea b = new BusProjectArea();
b.setProId(proId);
List<BusProjectArea> list = busProjectAreaRepository.queryBusProjectAreas(b);
List<BusProjectArea> list = busProjectAreaRepository.select(b);
//返回值
Map<String, Object> result = new HashMap<String, Object>();
Iterator<BusProjectArea> it = list.iterator();
......@@ -465,14 +463,15 @@ public class OverViewServiceImpl implements OverViewService {
if(calendar.get(Calendar.MONTH) == 1) year -= 1;
String yearS = String.valueOf(year);
//1.得到所有的项目
List<BusProject> busProjectList = busProjectRepository.queryBusProjects();
List<BusProject> busProjectList = busProjectRepository.selectAll();
//2.循环所有的项目,查询对应项目的统计信息
Iterator<BusProject> busProjectIterator = busProjectList.iterator();
while (busProjectIterator.hasNext()) {
//得到项目主键
String proId = busProjectIterator.next().getProId();
//查询该项目的水电气面积
BusProjectAreaVo busProjectAreaVo = busProjectAreaRepository.classifyProjectArea(proId);
// BusProjectAreaVo busProjectAreaVo = busProjectAreaRepository.classifyProjectArea(proId);
Float area = busProjectIterator.next().getBldArea();
//3.查询对应项目的能源统计(按月份统计)
EnergyCountM e = new EnergyCountM();
e.setProId(proId);
......@@ -492,9 +491,9 @@ public class OverViewServiceImpl implements OverViewService {
gasSum += energyCountM.getGas();
}
//算出年度平均值
waterSum = waterSum * 12 / size / busProjectAreaVo.getWaterArea();
elecSum = elecSum * 12 / size / busProjectAreaVo.getElecArea();
gasSum = gasSum * 12 / size / busProjectAreaVo.getGasArea();
waterSum = waterSum * 12 / size / area;
elecSum = elecSum * 12 / size / area;
gasSum = gasSum * 12 / size / area;
//需要新增或更新的对象
resultList.add(new BusProjectAreaStat(proId, yearS, waterSum, elecSum, gasSum));
}
......@@ -597,7 +596,7 @@ public class OverViewServiceImpl implements OverViewService {
//昨天时间
Integer year = calendar.get(Calendar.YEAR), month = calendar.get(Calendar.MONTH) + 1, day = calendar.get(Calendar.DAY_OF_MONTH);
//1.得到所有的项目
List<BusProject> busProjectList = busProjectRepository.queryBusProjects();
List<BusProject> busProjectList = busProjectRepository.selectAll();
//2.循环所有的项目,查询对应项目的统计信息
Iterator<BusProject> busProjectIterator = busProjectList.iterator();
while (busProjectIterator.hasNext()) {
......@@ -634,13 +633,18 @@ public class OverViewServiceImpl implements OverViewService {
private Map<String, Object> getEnergyPlanResult(List<BigDecimal> planList, List<BigDecimal> realList) {
//达标月数,未达标月数
int standard = 0, excessive = 0;
BigDecimal planYear = new BigDecimal(0), realYear = new BigDecimal(0);
int size = realList.size();
for (int i = 0; i < size; i++) {
if(realList.get(i).compareTo(planList.get(i)) > 0){
BigDecimal real = realList.get(i);
BigDecimal plan = planList.get(i);
if(real.compareTo(plan) > 0){
excessive++;
}else{
standard++;
}
planYear = planYear.add(plan);
realYear = realYear.add(real);
}
//返回结果
Map<String, Object> result = new HashMap<String, Object>();
......@@ -649,6 +653,10 @@ public class OverViewServiceImpl implements OverViewService {
result.put("running", size);
result.put("standard", standard);
result.put("excessive", excessive);
if (size == 12) {
result.put("planYear", planYear);
result.put("realYear", realYear);
}
return result;
}
......
......@@ -9,6 +9,6 @@ import org.rcisoft.business.overview.entity.BusProjectArea;
@Data
public class BusProjectAreaVo extends BusProjectArea {
private Float waterArea, elecArea, gasArea;
// private Float waterArea, elecArea, gasArea;
}
......@@ -4,18 +4,18 @@
<resultMap id="BaseResultMap" type="org.rcisoft.business.overview.entity.BusProjectArea">
<id column="ID" jdbcType="VARCHAR" property="id"/>
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>
<result column="AREA" jdbcType="FLOAT" property="area"/>
<!--<result column="AREA" jdbcType="FLOAT" property="area"/>-->
<result column="TYPE" jdbcType="CHAR" property="type"/>
<result column="INDUSTRY_STD" jdbcType="FLOAT" property="industryStd"/>
<result column="SUGGEST_STD" jdbcType="FLOAT" property="suggestStd"/>
<result column="COUNTRY_STD" jdbcType="FLOAT" property="countryStd"/>
</resultMap>
<resultMap id="vo" type="org.rcisoft.business.overview.vo.BusProjectAreaVo">
<result column="WATER_AREA" jdbcType="FLOAT" property="waterArea"/>
<result column="ELEC_AREA" jdbcType="FLOAT" property="elecArea"/>
<result column="GAS_AREA" jdbcType="FLOAT" property="gasArea"/>
</resultMap>
<!--<resultMap id="vo" type="org.rcisoft.business.overview.vo.BusProjectAreaVo">-->
<!--<result column="WATER_AREA" jdbcType="FLOAT" property="waterArea"/>-->
<!--<result column="ELEC_AREA" jdbcType="FLOAT" property="elecArea"/>-->
<!--<result column="GAS_AREA" jdbcType="FLOAT" property="gasArea"/>-->
<!--</resultMap>-->
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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