Commit 25af9768 authored by jianqian's avatar jianqian

新增

parent 1bfba0f4
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
<artifactId>dcit-authority</artifactId> <artifactId>dcit-authority</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.hikvision.ga/artemis-http-client -->
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
...@@ -56,7 +62,17 @@ ...@@ -56,7 +62,17 @@
</arguments> </arguments>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<!-- 自动生成代码的配置文件地址 -->
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
package com.dcit.danger.controller;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 海康视频接口
*/
@RestController
@RequestMapping("artemis")
@Slf4j
public class ArtemisController {
/**
* 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
* 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443 或者10.33.25.22:80
* appKey和appSecret请按照或得到的appKey和appSecret更改.
*/
static {
// 代理API网关nginx服务器ip端口
ArtemisConfig.host = "222.223.203.154:1443";
// 秘钥appkey
ArtemisConfig.appKey = "24786595";
// 秘钥appSecret
ArtemisConfig.appSecret = "AxzrQTvNWvSVKjKbYGOn";
}
/**
* 能力开放平台的网站路径
*/
private static final String ARTEMIS_PATH = "/artemis";
/**
* 获取监控点预览取流URL
*/
private static final String GET_PREVIEWURLS = ARTEMIS_PATH + "/api/video/v1/cameras/previewURLs";
/**
* 分页获取监控点资源
*/
private static final String GET_CAMERAS = ARTEMIS_PATH + "/api/resource/v1/cameras";
private static final String VEDIO_CONTROLLING = ARTEMIS_PATH + "/api/video/v1/ptzs/controlling";
/**
* 获取监控点预览取流URL
* @return
*/
@GetMapping("/getPreviewURLs")
public Object getPreviewURLs(@RequestParam(value = "cameraIndexCode") String cameraIndexCode){
/**
* 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
* ArtemisHttpUtil工具类提供了doPostStringArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
* 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
* 传入的contentType为application/json,accept不指定为null
* header没有额外参数可不传,指定为null
*
*/
Map<String, String> path = new HashMap<String, String>(2) {
{
//根据现场环境部署确认是http还是https
put("https://", GET_PREVIEWURLS);
}
};
JSONObject jsonBody = new JSONObject();
//jsonBody.put("cameraIndexCode", "2a9891a194c24747b277f3ea4836d433");
jsonBody.put("cameraIndexCode", cameraIndexCode);
jsonBody.put("streamType", 0);
jsonBody.put("protocol", "hls");
jsonBody.put("transmode", 0);
String body = jsonBody.toJSONString();
// post请求application/json类型参数
String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
return JSONObject.parseObject(result);
}
/**
* 分页获取监控点资源
* @param pageNo 页码
* @param pageSize 每页条数
* @return
*/
@GetMapping("/getCameras")
public Object getCameras(@RequestParam("pageNo") int pageNo,@RequestParam("pageSize") int pageSize){
Map<String, String> path = new HashMap<String, String>(2) {
{
//根据现场环境部署确认是http还是https
put("https://", GET_CAMERAS);
}
};
JSONObject jsonBody = new JSONObject();
jsonBody.put("pageNo", pageNo);
jsonBody.put("pageSize", pageSize);
jsonBody.put("treeCode", 0);
String body = jsonBody.toJSONString();
// post请求application/json类型参数
String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
return JSONObject.parseObject(result);
}
/**
* 云控操作
* @param cameraIndexCode
* @param command
* @param action
* @return
*/
@RequestMapping("/videoControlling")
public Object videoControlling(@RequestParam("cameraIndexCode") String cameraIndexCode,@RequestParam("command") String command,@RequestParam("action") String action){
Map<String, String> path = new HashMap<String, String>(2) {
{
//根据现场环境部署确认是http还是https
put("https://", VEDIO_CONTROLLING);
}
};
JSONObject jsonBody = new JSONObject();
jsonBody.put("cameraIndexCode", cameraIndexCode);
jsonBody.put("action", action);
jsonBody.put("command", command);
jsonBody.put("speed", 40);
String body = jsonBody.toJSONString();
// post请求application/json类型参数
String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
return JSONObject.parseObject(result);
}
}
...@@ -50,6 +50,8 @@ public class DataStatisticsController { ...@@ -50,6 +50,8 @@ public class DataStatisticsController {
@Autowired @Autowired
private AlarmInfoService alarmInfoService; private AlarmInfoService alarmInfoService;
@Autowired
private HarmPlaceService harmPlaceService;
@ApiOperation(value = "管理端数据统计") @ApiOperation(value = "管理端数据统计")
...@@ -124,6 +126,10 @@ public class DataStatisticsController { ...@@ -124,6 +126,10 @@ public class DataStatisticsController {
alarmInfoCriteria.andAlarmStatusEqualTo("0"); alarmInfoCriteria.andAlarmStatusEqualTo("0");
long alarmingNum = alarmInfoService.countByExample(alarmInfoExample); long alarmingNum = alarmInfoService.countByExample(alarmInfoExample);
List<Map<String,Object>> harmPlace = harmPlaceService.selectByEnterpriseId(null);
map.put("harmPlace",harmPlace);
map.put("harmNum",harmPlace.size());
map.put("enterpriseRegNum", regNum); map.put("enterpriseRegNum", regNum);
map.put("enterpriseCheckIngNum", checkIngNum); map.put("enterpriseCheckIngNum", checkIngNum);
map.put("dangerNum", dangerNum); map.put("dangerNum", dangerNum);
...@@ -230,4 +236,37 @@ public class DataStatisticsController { ...@@ -230,4 +236,37 @@ public class DataStatisticsController {
return ResultVOUtil.success(map); return ResultVOUtil.success(map);
} }
@ApiOperation(value = "一企一档详情管理")
@GetMapping("/enterpriseDatainfo/{enterpriseId}")
public ResultVO<Object> enterpriseDatainfo(@PathVariable String enterpriseId){
Map<String, Object> map = new HashMap<String, Object>();
//id
List<String> strlist = new ArrayList<>();
strlist.add(enterpriseId);
//监控
SafetyDeviceInfoExample safetyDeviceInfoExample = new SafetyDeviceInfoExample();
com.dcit.danger.model.SafetyDeviceInfoExample.Criteria safetyDeviceCriteria = safetyDeviceInfoExample.createCriteria();
safetyDeviceCriteria.andDataTypeEqualTo("1").andIsDelEqualTo("0");
safetyDeviceCriteria.andEnterpriseIdIn(strlist);
List<SafetyDeviceInfo> cameraList = safetyDeviceInfoService.selectByExample(safetyDeviceInfoExample);
//隐患
THiddenTroubleExample tHiddenTroubleExample = new THiddenTroubleExample();
tHiddenTroubleExample.createCriteria().andEnterpriseIdIn(strlist);
List<THiddenTrouble> troubleList = tHiddenTroubleService.selectByExample(tHiddenTroubleExample);
//危险源
EnterpriseGoodsInfoExample example = new EnterpriseGoodsInfoExample();
Criteria criteria = example.createCriteria();
//criteria.andIsBigDangerEqualTo("1");
criteria.andEnterpriseIdIn(strlist);
long dangerNum = enterpriseGoodsService.countByExample(example);
List<EnterpriseGoodsInfo> goodsList = enterpriseGoodsService.selectByExample(example);
//职业危害场所
List<Map<String,Object>> harmPlace = harmPlaceService.selectByEnterpriseId(enterpriseId);
map.put("cameraList",cameraList);
map.put("troubleList",troubleList);
map.put("goodsList",goodsList);
map.put("harmPlace",harmPlace);
return ResultVOUtil.success(map);
}
} }
...@@ -2,16 +2,13 @@ package com.dcit.danger.controller; ...@@ -2,16 +2,13 @@ package com.dcit.danger.controller;
import java.util.*; import java.util.*;
import com.dcit.danger.service.AccidentStatisticsService;
import com.dcit.danger.service.AlarmInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dcit.authority.dto.UserRolesInfoDTO; import com.dcit.authority.dto.UserRolesInfoDTO;
import com.dcit.authority.model.SysUser; import com.dcit.authority.model.SysUser;
...@@ -53,6 +50,10 @@ public class EnterpriseInfoController { ...@@ -53,6 +50,10 @@ public class EnterpriseInfoController {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired
private AlarmInfoService alarmInfoService;
@Autowired
private AccidentStatisticsService accidentStatisticsService;
@Autowired @Autowired
private ProjectPath projectPath; private ProjectPath projectPath;
...@@ -300,4 +301,22 @@ public class EnterpriseInfoController { ...@@ -300,4 +301,22 @@ public class EnterpriseInfoController {
return ResultVOUtil.success(map); return ResultVOUtil.success(map);
} }
@ApiOperation(value = "查询企业事故,预警柱状图信息")
@PostMapping("/enterpriseHistogram")
public ResultVO<Object> enterpriseHistogram(@RequestBody Map<String,Object> request ){
String enterpriseId =(String) request.get("enterpriseId");
String fromdate =(String) request.get("fromdate");
Map<String,Object> map = new HashMap<>();
try {
Map<String,Object> accident = accidentStatisticsService.selectByYear( enterpriseId, fromdate);
Map<String,Object> alarm = alarmInfoService.selectAlarmByYear( enterpriseId, fromdate);
map.put("accident",accident);
map.put("alarm",alarm);
} catch (Exception e) {
e.printStackTrace();
log.error("【查询企业事故,预警柱状图信息】操作出错,error={}",e.getMessage());
throw new IOCException(ResultEnum.OPERATION_FAIL);
}
return ResultVOUtil.success(map);
}
} }
package com.dcit.danger.dao;
import com.dcit.danger.model.AccidentStatistics;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AccidentStatisticsMapper {
int deleteByPrimaryKey(String id);
int insert(AccidentStatistics record);
int insertSelective(AccidentStatistics record);
AccidentStatistics selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(AccidentStatistics record);
int updateByPrimaryKeyWithBLOBs(AccidentStatistics record);
int updateByPrimaryKey(AccidentStatistics record);
List<Map<String,Object>> selectByYear(@Param("enterpriseId")String enterpriseId,
@Param("fromdate")String fromdate);
}
\ No newline at end of file
...@@ -32,4 +32,7 @@ public interface AlarmInfoMapper { ...@@ -32,4 +32,7 @@ public interface AlarmInfoMapper {
int updateByPrimaryKey(AlarmInfo record); int updateByPrimaryKey(AlarmInfo record);
List<AlarmInfoDTO> selectAlarmInfoList(Map<String, Object> map); List<AlarmInfoDTO> selectAlarmInfoList(Map<String, Object> map);
List<Map<String,Object>> selectByYear(@Param("enterpriseId")String enterpriseId,
@Param("fromdate")String fromdate);
} }
\ No newline at end of file
package com.dcit.danger.dao;
import com.dcit.danger.model.ControlRisk;
public interface ControlRiskMapper {
int deleteByPrimaryKey(String id);
int insert(ControlRisk record);
int insertSelective(ControlRisk record);
ControlRisk selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(ControlRisk record);
int updateByPrimaryKey(ControlRisk record);
}
\ No newline at end of file
package com.dcit.danger.dao;
import com.dcit.danger.model.HarmPlace;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface HarmPlaceMapper {
int deleteByPrimaryKey(String id);
int insert(HarmPlace record);
int insertSelective(HarmPlace record);
HarmPlace selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(HarmPlace record);
int updateByPrimaryKey(HarmPlace record);
List<Map<String,Object>> selectByEnterpriseId(@Param("enterpriseId") String enterpriseId);
Integer harmplaceCount();
}
\ No newline at end of file
package com.dcit.danger.model;
import java.util.Date;
public class AccidentStatistics {
private String id;
private String enterpriseId;
private String deviceId;
private String accidentLevel;
private String accidentReason;
private Integer month;
private Date accidentTime;
private Date createTime;
private String accidentText;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId == null ? null : enterpriseId.trim();
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId == null ? null : deviceId.trim();
}
public String getAccidentLevel() {
return accidentLevel;
}
public void setAccidentLevel(String accidentLevel) {
this.accidentLevel = accidentLevel == null ? null : accidentLevel.trim();
}
public String getAccidentReason() {
return accidentReason;
}
public void setAccidentReason(String accidentReason) {
this.accidentReason = accidentReason == null ? null : accidentReason.trim();
}
public Integer getMonth() {
return month;
}
public void setMonth(Integer month) {
this.month = month;
}
public Date getAccidentTime() {
return accidentTime;
}
public void setAccidentTime(Date accidentTime) {
this.accidentTime = accidentTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getAccidentText() {
return accidentText;
}
public void setAccidentText(String accidentText) {
this.accidentText = accidentText == null ? null : accidentText.trim();
}
}
\ No newline at end of file
...@@ -54,6 +54,8 @@ public class AlarmInfo implements Serializable { ...@@ -54,6 +54,8 @@ public class AlarmInfo implements Serializable {
*/ */
private String alarmStatus; private String alarmStatus;
private Integer alarmMonth;
/** /**
* 处理类型,0未处理,1自动消警,2手动消警 * 处理类型,0未处理,1自动消警,2手动消警
*/ */
......
package com.dcit.danger.model;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class ControlRisk {
private String id;
private String enterpriseId;
private String riskName;
private String riskType;
private String riskLevel;
private String address;
private BigDecimal longitude;
private BigDecimal latitude;
private Date updateTime;
private Date createTime;
private String remarks;
}
\ No newline at end of file
package com.dcit.danger.model;
import java.math.BigDecimal;
import java.util.Date;
public class HarmPlace {
private String id;
private String enterpriseId;
private String placeName;
private String placeType;
private String harmLevel;
private String address;
private BigDecimal longitude;
private BigDecimal latitude;
private Date updateTime;
private Date createTime;
private String remarks;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId == null ? null : enterpriseId.trim();
}
public String getPlaceName() {
return placeName;
}
public void setPlaceName(String placeName) {
this.placeName = placeName == null ? null : placeName.trim();
}
public String getPlaceType() {
return placeType;
}
public void setPlaceType(String placeType) {
this.placeType = placeType == null ? null : placeType.trim();
}
public String getHarmLevel() {
return harmLevel;
}
public void setHarmLevel(String harmLevel) {
this.harmLevel = harmLevel == null ? null : harmLevel.trim();
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}
}
\ No newline at end of file
package com.dcit.danger.service;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AccidentStatisticsService {
Map<String,Object> selectByYear(String enterpriseId, String fromdate);
}
...@@ -33,4 +33,6 @@ public interface AlarmInfoService { ...@@ -33,4 +33,6 @@ public interface AlarmInfoService {
List<AlarmInfoDTO> selectAlarmInfoList(Map<String, Object> map); List<AlarmInfoDTO> selectAlarmInfoList(Map<String, Object> map);
Map<String,Object> selectAlarmByYear(String enterpriseId, String fromdate );
} }
package com.dcit.danger.service;
import java.util.List;
import java.util.Map;
public interface HarmPlaceService {
public List<Map<String,Object>> selectByEnterpriseId(String enterpriseId);
public Integer harmplaceCount();
}
package com.dcit.danger.service.impl;
import com.dcit.danger.dao.AccidentStatisticsMapper;
import com.dcit.danger.service.AccidentStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class AccidentStatisticsServiceImpl implements AccidentStatisticsService{
@Autowired
private AccidentStatisticsMapper accidentStatisticsMapper;
@Override
public Map<String,Object> selectByYear(String enterpriseId, String fromdate){
Map<String,Object> map = new HashMap<>();
String[] month = {"1","2","3","4","5","6","7","8","9","10","11","12"};
map.put("month",month);
Integer[] num = {0,0,0,0,0,0,0,0,0,0,0,0};
List<Map<String,Object>> list = accidentStatisticsMapper.selectByYear(enterpriseId,fromdate);
long totalNum = 0;
for(Map<String,Object> m:list){
int a = (Integer) m.get("month");
totalNum += (long)m.get("num");
num[a-1] = Integer.parseInt(m.get("num").toString());
}
map.put("num",num);
map.put("totalNum",totalNum);
return map;
}
}
package com.dcit.danger.service.impl; package com.dcit.danger.service.impl;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -90,4 +91,21 @@ public class AlarmInfoServiceImpl implements AlarmInfoService{ ...@@ -90,4 +91,21 @@ public class AlarmInfoServiceImpl implements AlarmInfoService{
return alarmInfoMapper.selectAlarmInfoList(map); return alarmInfoMapper.selectAlarmInfoList(map);
} }
@Override
public Map<String,Object> selectAlarmByYear(String enterpriseId, String fromdate){
Map<String,Object> map = new HashMap<>();
String[] month = {"1","2","3","4","5","6","7","8","9","10","11","12"};
map.put("month",month);
Integer[] num = {0,0,0,0,0,0,0,0,0,0,0,0};
List<Map<String,Object>> list = alarmInfoMapper.selectByYear(enterpriseId,fromdate);
long totalNum =0;
for(Map<String,Object> m:list){
int a = (Integer) m.get("alarmMonth");
totalNum += (long)m.get("num");
num[a-1] = Integer.parseInt(m.get("num").toString());
}
map.put("totalNum",totalNum);
map.put("num",num);
return map;
}
} }
package com.dcit.danger.service.impl;
import com.dcit.danger.dao.HarmPlaceMapper;
import com.dcit.danger.service.HarmPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class HarmPlaceServiceImpl implements HarmPlaceService{
@Autowired
private HarmPlaceMapper harmPlaceMapper;
@Override
public List<Map<String,Object>> selectByEnterpriseId(String enterpriseId){
return harmPlaceMapper.selectByEnterpriseId(enterpriseId);
}
@Override
public Integer harmplaceCount(){
return harmPlaceMapper.harmplaceCount();
}
}
<?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="com.dcit.danger.dao.AccidentStatisticsMapper" >
<resultMap id="BaseResultMap" type="com.dcit.danger.model.AccidentStatistics" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR" />
<result column="device_id" property="deviceId" jdbcType="VARCHAR" />
<result column="accident_level" property="accidentLevel" jdbcType="VARCHAR" />
<result column="accident_reason" property="accidentReason" jdbcType="VARCHAR" />
<result column="month" property="month" jdbcType="INTEGER" />
<result column="accident_time" property="accidentTime" jdbcType="TIMESTAMP" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.dcit.danger.model.AccidentStatistics" extends="BaseResultMap" >
<result column="accident_text" property="accidentText" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, enterprise_id, device_id, accident_level, accident_reason, month, accident_time,
create_time
</sql>
<sql id="Blob_Column_List" >
accident_text
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from accident_statistics
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from accident_statistics
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.dcit.danger.model.AccidentStatistics" >
insert into accident_statistics (id, enterprise_id, device_id,
accident_level, accident_reason, month,
accident_time, create_time, accident_text
)
values (#{id,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{deviceId,jdbcType=VARCHAR},
#{accidentLevel,jdbcType=VARCHAR}, #{accidentReason,jdbcType=VARCHAR}, #{month,jdbcType=INTEGER},
#{accidentTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{accidentText,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.dcit.danger.model.AccidentStatistics" >
insert into accident_statistics
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="enterpriseId != null" >
enterprise_id,
</if>
<if test="deviceId != null" >
device_id,
</if>
<if test="accidentLevel != null" >
accident_level,
</if>
<if test="accidentReason != null" >
accident_reason,
</if>
<if test="month != null" >
month,
</if>
<if test="accidentTime != null" >
accident_time,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="accidentText != null" >
accident_text,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null" >
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="deviceId != null" >
#{deviceId,jdbcType=VARCHAR},
</if>
<if test="accidentLevel != null" >
#{accidentLevel,jdbcType=VARCHAR},
</if>
<if test="accidentReason != null" >
#{accidentReason,jdbcType=VARCHAR},
</if>
<if test="month != null" >
#{month,jdbcType=INTEGER},
</if>
<if test="accidentTime != null" >
#{accidentTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="accidentText != null" >
#{accidentText,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.dcit.danger.model.AccidentStatistics" >
update accident_statistics
<set >
<if test="enterpriseId != null" >
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="deviceId != null" >
device_id = #{deviceId,jdbcType=VARCHAR},
</if>
<if test="accidentLevel != null" >
accident_level = #{accidentLevel,jdbcType=VARCHAR},
</if>
<if test="accidentReason != null" >
accident_reason = #{accidentReason,jdbcType=VARCHAR},
</if>
<if test="month != null" >
month = #{month,jdbcType=INTEGER},
</if>
<if test="accidentTime != null" >
accident_time = #{accidentTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="accidentText != null" >
accident_text = #{accidentText,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.dcit.danger.model.AccidentStatistics" >
update accident_statistics
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
device_id = #{deviceId,jdbcType=VARCHAR},
accident_level = #{accidentLevel,jdbcType=VARCHAR},
accident_reason = #{accidentReason,jdbcType=VARCHAR},
month = #{month,jdbcType=INTEGER},
accident_time = #{accidentTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
accident_text = #{accidentText,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.dcit.danger.model.AccidentStatistics" >
update accident_statistics
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
device_id = #{deviceId,jdbcType=VARCHAR},
accident_level = #{accidentLevel,jdbcType=VARCHAR},
accident_reason = #{accidentReason,jdbcType=VARCHAR},
month = #{month,jdbcType=INTEGER},
accident_time = #{accidentTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByYear" resultType="java.util.HashMap" >
SELECT `month`,COUNT(id) AS num FROM accident_statistics
WHERE enterprise_id =#{enterpriseId}
and accident_time like concat('%',#{fromdate},'%')
GROUP BY `month`
ORDER BY `month`
</select>
</mapper>
\ No newline at end of file
...@@ -154,6 +154,9 @@ ...@@ -154,6 +154,9 @@
<if test="alarmStatus != null"> <if test="alarmStatus != null">
alarm_status, alarm_status,
</if> </if>
<if test="alarmMonth != null">
alarm_month,
</if>
<if test="handleType != null"> <if test="handleType != null">
handle_type, handle_type,
</if> </if>
...@@ -204,6 +207,9 @@ ...@@ -204,6 +207,9 @@
<if test="alarmStatus != null"> <if test="alarmStatus != null">
#{alarmStatus,jdbcType=VARCHAR}, #{alarmStatus,jdbcType=VARCHAR},
</if> </if>
<if test="alarmMonth != null">
#{alarmMonth,jdbcType=VARCHAR},
</if>
<if test="handleType != null"> <if test="handleType != null">
#{handleType,jdbcType=VARCHAR}, #{handleType,jdbcType=VARCHAR},
</if> </if>
...@@ -411,4 +417,11 @@ ...@@ -411,4 +417,11 @@
AND t.alarm_status = #{alarmStatus,jdbcType=VARCHAR} AND t.alarm_status = #{alarmStatus,jdbcType=VARCHAR}
</if> </if>
</select> </select>
<select id="selectByYear" resultType="java.util.HashMap" >
SELECT `alarm_month` AS alarmMonth,COUNT(id) AS num FROM t_alarm_info
WHERE enterprise_id =#{enterpriseId}
and alarm_time like concat('%',#{fromdate},'%')
GROUP BY `alarm_month`
ORDER BY `alarm_month`
</select>
</mapper> </mapper>
\ No newline at end of file
<?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="com.dcit.danger.dao.ControlRiskMapper" >
<resultMap id="BaseResultMap" type="com.dcit.danger.model.ControlRisk" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR" />
<result column="risk_name" property="riskName" jdbcType="VARCHAR" />
<result column="risk_type" property="riskType" jdbcType="VARCHAR" />
<result column="risk_level" property="riskLevel" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="longitude" property="longitude" jdbcType="DECIMAL" />
<result column="latitude" property="latitude" jdbcType="DECIMAL" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="remarks" property="remarks" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, enterprise_id, risk_name, risk_type, risk_level, address, longitude, latitude,
update_time, create_time, remarks
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from t_control_risk
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from t_control_risk
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.dcit.danger.model.ControlRisk" >
insert into t_control_risk (id, enterprise_id, risk_name,
risk_type, risk_level, address,
longitude, latitude, update_time,
create_time, remarks)
values (#{id,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{riskName,jdbcType=VARCHAR},
#{riskType,jdbcType=VARCHAR}, #{riskLevel,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{longitude,jdbcType=DECIMAL}, #{latitude,jdbcType=DECIMAL}, #{updateTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.dcit.danger.model.ControlRisk" >
insert into t_control_risk
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="enterpriseId != null" >
enterprise_id,
</if>
<if test="riskName != null" >
risk_name,
</if>
<if test="riskType != null" >
risk_type,
</if>
<if test="riskLevel != null" >
risk_level,
</if>
<if test="address != null" >
address,
</if>
<if test="longitude != null" >
longitude,
</if>
<if test="latitude != null" >
latitude,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="remarks != null" >
remarks,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null" >
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="riskName != null" >
#{riskName,jdbcType=VARCHAR},
</if>
<if test="riskType != null" >
#{riskType,jdbcType=VARCHAR},
</if>
<if test="riskLevel != null" >
#{riskLevel,jdbcType=VARCHAR},
</if>
<if test="address != null" >
#{address,jdbcType=VARCHAR},
</if>
<if test="longitude != null" >
#{longitude,jdbcType=DECIMAL},
</if>
<if test="latitude != null" >
#{latitude,jdbcType=DECIMAL},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
#{remarks,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.dcit.danger.model.ControlRisk" >
update t_control_risk
<set >
<if test="enterpriseId != null" >
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="riskName != null" >
risk_name = #{riskName,jdbcType=VARCHAR},
</if>
<if test="riskType != null" >
risk_type = #{riskType,jdbcType=VARCHAR},
</if>
<if test="riskLevel != null" >
risk_level = #{riskLevel,jdbcType=VARCHAR},
</if>
<if test="address != null" >
address = #{address,jdbcType=VARCHAR},
</if>
<if test="longitude != null" >
longitude = #{longitude,jdbcType=DECIMAL},
</if>
<if test="latitude != null" >
latitude = #{latitude,jdbcType=DECIMAL},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
remarks = #{remarks,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.dcit.danger.model.ControlRisk" >
update t_control_risk
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
risk_name = #{riskName,jdbcType=VARCHAR},
risk_type = #{riskType,jdbcType=VARCHAR},
risk_level = #{riskLevel,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
longitude = #{longitude,jdbcType=DECIMAL},
latitude = #{latitude,jdbcType=DECIMAL},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
<?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="com.dcit.danger.dao.HarmPlaceMapper" >
<resultMap id="BaseResultMap" type="com.dcit.danger.model.HarmPlace" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR" />
<result column="place_name" property="placeName" jdbcType="VARCHAR" />
<result column="place_type" property="placeType" jdbcType="VARCHAR" />
<result column="harm_level" property="harmLevel" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="longitude" property="longitude" jdbcType="DECIMAL" />
<result column="latitude" property="latitude" jdbcType="DECIMAL" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="remarks" property="remarks" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, enterprise_id, place_name, place_type, harm_level, address, longitude, latitude,
update_time, create_time, remarks
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from t_harm_place
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from t_harm_place
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.dcit.danger.model.HarmPlace" >
insert into t_harm_place (id, enterprise_id, place_name,
place_type, harm_level, address,
longitude, latitude, update_time,
create_time, remarks)
values (#{id,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{placeName,jdbcType=VARCHAR},
#{placeType,jdbcType=VARCHAR}, #{harmLevel,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{longitude,jdbcType=DECIMAL}, #{latitude,jdbcType=DECIMAL}, #{updateTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.dcit.danger.model.HarmPlace" >
insert into t_harm_place
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="enterpriseId != null" >
enterprise_id,
</if>
<if test="placeName != null" >
place_name,
</if>
<if test="placeType != null" >
place_type,
</if>
<if test="harmLevel != null" >
harm_level,
</if>
<if test="address != null" >
address,
</if>
<if test="longitude != null" >
longitude,
</if>
<if test="latitude != null" >
latitude,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="remarks != null" >
remarks,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null" >
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="placeName != null" >
#{placeName,jdbcType=VARCHAR},
</if>
<if test="placeType != null" >
#{placeType,jdbcType=VARCHAR},
</if>
<if test="harmLevel != null" >
#{harmLevel,jdbcType=VARCHAR},
</if>
<if test="address != null" >
#{address,jdbcType=VARCHAR},
</if>
<if test="longitude != null" >
#{longitude,jdbcType=DECIMAL},
</if>
<if test="latitude != null" >
#{latitude,jdbcType=DECIMAL},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
#{remarks,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.dcit.danger.model.HarmPlace" >
update t_harm_place
<set >
<if test="enterpriseId != null" >
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="placeName != null" >
place_name = #{placeName,jdbcType=VARCHAR},
</if>
<if test="placeType != null" >
place_type = #{placeType,jdbcType=VARCHAR},
</if>
<if test="harmLevel != null" >
harm_level = #{harmLevel,jdbcType=VARCHAR},
</if>
<if test="address != null" >
address = #{address,jdbcType=VARCHAR},
</if>
<if test="longitude != null" >
longitude = #{longitude,jdbcType=DECIMAL},
</if>
<if test="latitude != null" >
latitude = #{latitude,jdbcType=DECIMAL},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
remarks = #{remarks,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.dcit.danger.model.HarmPlace" >
update t_harm_place
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
place_name = #{placeName,jdbcType=VARCHAR},
place_type = #{placeType,jdbcType=VARCHAR},
harm_level = #{harmLevel,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
longitude = #{longitude,jdbcType=DECIMAL},
latitude = #{latitude,jdbcType=DECIMAL},
update_time = #{updateTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByEnterpriseId" resultType="java.util.HashMap">
SELECT id,enterprise_id as enterpriseId,place_name as placeName,place_type as placeType,harm_level as harmLevel,remarks,contacts,phone,
address,longitude,latitude,update_time as updateTime,create_time as createTime from t_harm_place
<if test="enterpriseId!=null">
WHERE enterprise_id =#{enterpriseId}
</if>
</select>
<select id="harmplaceCount" resultType="java.lang.Integer">
SELECT COUNT(id) FROM t_harm_place
</select>
</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