Commit bfb9f430 authored by gaoliwei's avatar gaoliwei

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

parents 04491f4a 970cc8a4
package org.rcisoft.business.mainte.fault.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.mainte.fault.entity.BusDeviceFault;
import org.rcisoft.business.mainte.fault.service.BusDeviceFaultService;
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.web.bind.annotation.*;
import org.rcisoft.core.controller.PaginationController;
/**
* Created by on 2018-4-17 11:19:46.
*/
@RestController
@RequestMapping("busdevicefault")
public class BusDeviceFaultController extends PaginationController<BusDeviceFault> {
@Autowired
private BusDeviceFaultService busDeviceFaultServiceImpl;
@ApiOperation(value="故障次数", notes="返回日期、次数的json数组")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "year", value = "年份,如:2018", required = true, dataType = "字符串或数字"),
@ApiImplicitParam(name = "month", value = "月份,如:6", required = true, dataType = "字符串或数字")
})
@RequestMapping("/statFault")
public Result statFault(@RequestParam String proId, @RequestParam String year, @RequestParam String month) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busDeviceFaultServiceImpl.statFault(proId, year, month));
}
@ApiOperation(value="故障统计列表", notes="返回 时间、系统名称、设备名称、参数名称、故障内容")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "year", value = "年份,如:2018", required = true, dataType = "字符串或数字"),
@ApiImplicitParam(name = "month", value = "月份,如:6", required = true, dataType = "字符串或数字")
})
@RequestMapping("/queryFaultList")
public Result queryFaultList(@RequestParam String proId, @RequestParam String year, @RequestParam String month) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busDeviceFaultServiceImpl.queryFaultList(proId, year, month));
}
}
package org.rcisoft.business.mainte.fault.dao;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.mainte.fault.entity.BusDeviceFault;
import org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2018-4-17 11:19:46.
*/
@Repository
public interface BusDeviceFaultRepository extends BaseMapper<BusDeviceFault> {
/**
* 故障次数
* @param busDeviceFaultVo
* @return 日期,次数的list
*/
@Select("<script>select date_format(b.TM,'%e') `day`,count(*) NUM from bus_device_fault b where b.PRO_ID=#{proId} and date_format(b.TM,'%Y-%c')=#{date} group by date_format(b.TM,'%e')</script>")
@ResultMap(value = "vo")
List<BusDeviceFaultVo> statFault(BusDeviceFaultVo busDeviceFaultVo);
/**
* 故障统计列表
* @param busDeviceFaultVo
* @return
*/
@Select("<script>select date_format(f.TM,'%Y-%m-%d') `DATE`,f.CONTENT,d.DEV_NM,s.SYS_NM,p.PARAM_NM " +
"from bus_device_fault f,bus_device d,bus_param p,bus_system s " +
"where f.DEV_NUM=d.DEV_NUM and d.SYS_ID=s.SYS_ID and f.P_CODE=p.PARAM " +
"and f.PRO_ID=#{proId} and date_format(f.TM,'%Y-%c')=#{date}</script>")
@ResultMap(value = "faultList")
List<BusDeviceFaultVo> queryFaultList(BusDeviceFaultVo busDeviceFaultVo);
}
package org.rcisoft.business.mainte.fault.entity;
import lombok.*;
import org.rcisoft.core.entity.IdNotDataEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2018-4-17 11:19:46.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_device_fault")
public class BusDeviceFault implements Serializable {
@Id
private Integer id;
private String devNum;
private Date tm;
private String pCode;
private String content;
private String proId;
}
package org.rcisoft.business.mainte.fault.service;
import org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo;
import java.util.List;
/**
* Created by on 2018-4-17 11:19:46.
*/
public interface BusDeviceFaultService {
/**
* 故障次数
* @param proId
* @param year
* @param month
* @return
*/
List<Integer> statFault(String proId, String year, String month);
/**
* 故障统计列表
* @param proId
* @param year
* @param month
* @return
*/
List<BusDeviceFaultVo> queryFaultList(String proId, String year, String month);
}
package org.rcisoft.business.mainte.fault.service.impl;
import org.rcisoft.business.mainte.fault.dao.BusDeviceFaultRepository;
import org.rcisoft.business.mainte.fault.service.BusDeviceFaultService;
import org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by on 2018-4-17 11:19:46.
*/
@Service
public class BusDeviceFaultServiceImpl implements BusDeviceFaultService {
@Autowired
private BusDeviceFaultRepository busDeviceFaultRepository;
@Override
public List<Integer> statFault(String proId, String year, String month) {
List<Integer> resultList = new ArrayList<Integer>();
BusDeviceFaultVo b = new BusDeviceFaultVo();
b.setProId(proId);
b.setDate(year + "-" + month);
List<BusDeviceFaultVo> list = busDeviceFaultRepository.statFault(b);
if (list != null && list.size() > 0) {
int size = list.size();
int j = 1;
for (int i = 0; i < size; i++) {
BusDeviceFaultVo bb = list.get(i);
int day = bb.getDay();
while (day > j++){
resultList.add(0);
}
resultList.add(bb.getNum());
if(i == size - 1){
while (day++ < 31){
resultList.add(0);
}
}
}
} else {
for (int i = 0; i < 31; i++) {
resultList.add(0);
}
}
return resultList;
}
@Override
public List<BusDeviceFaultVo> queryFaultList(String proId, String year, String month) {
BusDeviceFaultVo busDeviceFaultVo = new BusDeviceFaultVo();
busDeviceFaultVo.setProId(proId);
busDeviceFaultVo.setDate(year + "-" + month);
return busDeviceFaultRepository.queryFaultList(busDeviceFaultVo);
}
}
package org.rcisoft.business.mainte.fault.vo;
import lombok.Data;
import org.rcisoft.business.mainte.fault.entity.BusDeviceFault;
/**
* Created by JiChao on 2018/4/17.
*/
@Data
public class BusDeviceFaultVo extends BusDeviceFault {
private Integer day;
private Integer num;
//日期
private String date;
//系统名称
private String sysNm;
//设备名称
private String devNm;
//参数名称
private String paramNm;
}
......@@ -52,12 +52,12 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountMVo
* @return
*/
@Select("<script>select e.DEV_ID," +
@Select("<script>select e.DEV_NUM," +
"<if test=\"type == 1\">sum(e.WATER)</if>" +
"<if test=\"type == 2\">sum(e.ELEC)</if>" +
"<if test=\"type == 3\">sum(e.GAS)</if>" +
" as ENERGY from ENERGY_COUNT_M e" +
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.DEV_ID</script>")
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.DEV_NUM</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countEnergySplit(EnergyCountMVo energyCountMVo);
......
......@@ -31,7 +31,7 @@ public class EnergyCountM implements Serializable {
@Id
private Integer id;
private String devId;
private String devNum;
private String proId;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.mainte.fault.dao.BusDeviceFaultRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.mainte.fault.entity.BusDeviceFault">
<id column="ID" jdbcType="INTEGER" property="id"/>
<result column="DEV_NUM" jdbcType="VARCHAR" property="devNum"/>
<result column="TM" jdbcType="TIMESTAMP" property="tm"/>
<result column="P_CODE" jdbcType="VARCHAR" property="pCode"/>
<result column="CONTENT" jdbcType="VARCHAR" property="content"/>
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>
</resultMap>
<resultMap id="vo" type="org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo">
<result column="DAY" jdbcType="INTEGER" property="day"/>
<result column="NUM" jdbcType="INTEGER" property="num"/>
</resultMap>
<resultMap id="faultList" type="org.rcisoft.business.mainte.fault.vo.BusDeviceFaultVo">
<result column="DATE" jdbcType="VARCHAR" property="date"/>
<result column="SYS_NM" jdbcType="VARCHAR" property="sysNm"/>
<result column="DEV_NM" jdbcType="VARCHAR" property="devNm"/>
<result column="PARAM_NM" jdbcType="VARCHAR" property="paramNm"/>
<result column="CONTENT" jdbcType="VARCHAR" property="content"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<mapper namespace="org.rcisoft.business.overview.dao.EnergyCountMRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.overview.entity.EnergyCountM">
<id column="ID" jdbcType="INTEGER" property="id"/>
<result column="DEV_ID" jdbcType="VARCHAR" property="devId"/>
<result column="DEV_NUM" jdbcType="VARCHAR" property="devNum"/>
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>
<result column="WATER" jdbcType="FLOAT" property="water"/>
<result column="ELEC" jdbcType="FLOAT" property="elec"/>
......
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