1.大数据统计接口

2.新增企业监控污染因子接口
This commit is contained in:
ly19960718 2021-08-11 11:38:51 +08:00
parent d80ee39789
commit 08fe8faf9d
25 changed files with 2315 additions and 9 deletions

View File

@ -0,0 +1,112 @@
package com.cm.tenlion.pollutantdata.controller.api.enterprisepoll;
import com.cm.common.annotation.CheckRequestBodyAnnotation;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO;
import com.cm.tenlion.pollutantdata.pojo.vos.enterprisepoll.EnterprisePollVO;
import com.cm.tenlion.pollutantdata.service.enterprisepoll.IEnterprisePollService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @ClassName: EnterprisePollController
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "企业监控污染因子接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/enterprisepoll")
public class EnterprisePollController extends AbstractController {
@Autowired
private IEnterprisePollService enterprisePollService;
@ApiOperation(value = "新增企业监控污染因子", notes = "新增企业监控污染因子接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save")
@CheckRequestBodyAnnotation
public SuccessResult save(@RequestBody EnterprisePollVO enterprisePollVO)throws Exception {
enterprisePollService.save(enterprisePollVO);
return new SuccessResult();
}
@ApiOperation(value = "删除企业监控污染因子", notes = "删除企业监控污染因子接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("remove/{ids}")
public SuccessResult remove(@PathVariable("ids") String ids) {
enterprisePollService.remove(Arrays.asList(ids.split("\\_")));
return new SuccessResult();
}
@ApiOperation(value = "修改企业监控污染因子", notes = "修改企业监控污染因子接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterprisePollId", value = "企业监控污染因子ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update/{enterprisePollId}")
@CheckRequestBodyAnnotation
public SuccessResult update(@PathVariable("enterprisePollId") String enterprisePollId, @RequestBody EnterprisePollVO enterprisePollVO) throws Exception {
enterprisePollService.update(enterprisePollId, enterprisePollVO);
return new SuccessResult();
}
@ApiOperation(value = "企业监控污染因子详情", notes = "企业监控污染因子详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterprisePollId", value = "企业监控污染因子ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{enterprisePollId}")
public EnterprisePollDTO get(@PathVariable("enterprisePollId") String enterprisePollId) {
return enterprisePollService.get(enterprisePollId);
}
@ApiOperation(value = "企业监控污染因子列表", notes = "企业监控污染因子列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list")
public List<EnterprisePollDTO> list() {
Map<String, Object> params = requestParams();
return enterprisePollService.list(params);
}
@ApiOperation(value = "企业监控污染因子分页列表", notes = "企业监控污染因子分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage")
public SuccessResultList<List<EnterprisePollDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return enterprisePollService.listPage(page);
}
@ApiOperation(value = "企业监控污染因子统计", notes = "企业监控污染因子统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count")
SuccessResultData<Integer> count() {
Map<String, Object> params = requestParams();
return new SuccessResultData<>(enterprisePollService.count(params));
}
}

View File

@ -0,0 +1,60 @@
package com.cm.tenlion.pollutantdata.controller.app.resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 大数据页面返回实体
*/
public class BigDataResult {
private Map<String, Object> data = new HashMap<String, Object>();
private List<Object> list = new ArrayList<Object>();
private String msg = "加载成功";
private String state = "200";
public static BigDataResult getInstance() {
return new BigDataResult();
}
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public List getList() {
if (list == null) {
return new ArrayList<>();
}
return list;
}
public void setList(List list) {
this.list = list;
}
public String getMsg() {
return msg == null ? "" : msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getState() {
return state == null ? "" : state;
}
public void setState(String state) {
this.state = state;
}
}

View File

@ -0,0 +1,152 @@
package com.cm.tenlion.pollutantdata.controller.app.resource.alarmlog;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.DateUtil;
import com.cm.tenlion.pollutantdata.controller.app.resource.BigDataResult;
import com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog.AlarmLogDTO;
import com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO;
import com.cm.tenlion.pollutantdata.pojo.dtos.poll.PollDTO;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.cm.tenlion.pollutantdata.service.enterprisepoll.IEnterprisePollService;
import com.cm.tenlion.pollutantdata.service.poll.IPollService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "报警日志接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/alarmlog/" + ISystemConstant.APP_RELEASE_SUFFIX)
public class AlarmlogAppResourceController extends AbstractController {
@Autowired
private IAlarmLogService alarmLogService;
@Autowired
private IEnterprisePollService enterprisePollService;
@Autowired
private IPollService pollService;
@ApiOperation(value = "获取当月报警数据", notes = "获取当月报警数据接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get-nowmonth")
public BigDataResult getNowMonth(){
BigDataResult result = new BigDataResult();
Map<String,Object> params = new HashMap<>();
params.put("month","month");
Integer count = alarmLogService.count(params);
params.clear();
params.put("value",count);
result.setData(params);
return result;
}
@ApiOperation(value = "警告日志分页列表", notes = "警告日志分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage")
public SuccessResultList<List<AlarmLogDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return alarmLogService.listPage(page);
}
@ApiOperation(value = "警告日志分页列表前五条", notes = "警告日志分页列表前五条接口")
@GetMapping("list-five")
public BigDataResult listFive() throws Exception{
BigDataResult result = new BigDataResult();
List<Map<String,Object>> list = new ArrayList<>();
/* {title:'新体路 测试企业1',date:'2021-06-03 22:00:52',content:'污水超标 , 当前 26 升/秒, 超标20%',level:3}*/
ListPage page = new ListPage();
page.setPage(1);
page.setRows(5);
SuccessResultList<List<AlarmLogDTO>> listSuccessResultList = alarmLogService.listPage(page);
for (AlarmLogDTO row : listSuccessResultList.getRows()) {
Map<String,Object> params = new HashMap<>();
params.put("title",row.getEnterpriseName());
params.put("date",row.getGmtCreate());
Double poll = countContent(row.getEnterpriseId(),row.getPollId(),row.getRtd());
String s = "污染因子超标,当前" +row.getRtd()+"超标" +poll+ "%";
params.put("content",row.getPollName()+s);
params.put("level",countLevel(poll));
list.add(params);
}
result.setList(list);
return result;
}
/**
* 计算超标百分比
* @param enterpriseId 企业ID
* @param pollId 污染因子ID
* @param rtd 实时值
* @return
*/
private final Double countContent(String enterpriseId,String pollId, Double rtd) throws Exception {
// 实际值 - 报警值 \ 报警值 * 100%
Double count = 0.0;
//根据编码查询污染因子
PollDTO pollDTO = pollService.getByNo(pollId);
if(pollDTO != null){
//查询企业绑定监控污染因子
Map<String,Object> params = new HashMap<>();
params.put("enterpriseId",enterpriseId);
params.put("pollId",pollDTO.getPollId());
EnterprisePollDTO enterprisePollDTO = enterprisePollService.get(params);
if(enterprisePollDTO != null){//按企业绑定报警值计算
double v = (rtd - enterprisePollDTO.getEnterprisePollBeyond()) / pollDTO.getAlarmValue();
count = v * 100;
}else{
double v = (rtd - pollDTO.getAlarmValue()) / pollDTO.getAlarmValue();
count = v * 100;
}
}
return count;
}
public final Integer countLevel(Double poll){
Integer level = 0;
if(poll == 0.0){
level = 1;
}
if(poll <= 20){
level = 2;
}
if(poll == 60){
level = 3;
}
if(poll == 90){
level = 4;
}
return level;
}
}

View File

@ -0,0 +1,78 @@
package com.cm.tenlion.pollutantdata.controller.app.resource.poll;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.result.ErrorResult;
import com.cm.tenlion.pollutantdata.controller.app.resource.BigDataResult;
import com.cm.tenlion.pollutantdata.pojo.dtos.poll.PollDTO;
import com.cm.tenlion.pollutantdata.service.poll.IPollService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "污染因子接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/poll/" + ISystemConstant.APP_RELEASE_SUFFIX)
public class PollAppResourceController extends AbstractController {
@Autowired
private IPollService pollService;
@ApiOperation(value = "污染因子超标企业统计", notes = "污染因子超标企业统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listExcessiveCompany")
public BigDataResult listExcessiveCompany(){
BigDataResult result = new BigDataResult();
List<String[]> list =new ArrayList<>();
List<Map<String, Object>> listMaps = pollService.listExcessiveCompany(new HashMap<>());
//分装数据
for (Map<String, Object> map : listMaps) {
String[] arr = new String[3];
arr[0] = map.get("pollName").toString();
arr[1] = map.get("companyNum").toString();
arr[2] = map.get("unitConcentration").toString();
list.add(arr);
}
result.setList(list);
return result;
}
@ApiOperation(value = "污染因子列表", notes = "污染因子列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listPoll")
public BigDataResult listPoll(){
/* {id:'1',name:'选择污染因子'}*/
BigDataResult result = new BigDataResult();
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> params = new HashMap<>();
List<PollDTO> pollList = pollService.list(params);
for (PollDTO pollDTO : pollList) {
Map<String,Object> params1 = new HashMap<>();
params1.put("id",pollDTO.getPollId());
params1.put("name",pollDTO.getPollName());
list.add(params1);
}
result.setList(list);
return result;
}
}

View File

@ -0,0 +1,42 @@
package com.cm.tenlion.pollutantdata.controller.route.enterprisepoll;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @ClassName: EnterprisePollController
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "企业监控污染因子路由")
@RestController
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/enterprisepoll")
public class EnterprisePollRouteController extends AbstractController {
@GetMapping("save")
public ModelAndView save() {
return new ModelAndView("enterprisepoll/save");
}
@GetMapping("update")
public ModelAndView update() {
return new ModelAndView("enterprisepoll/update");
}
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("enterprisepoll/list");
}
}

View File

@ -0,0 +1,121 @@
package com.cm.tenlion.pollutantdata.dao.enterprisepoll;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.tenlion.pollutantdata.pojo.bos.enterprisepoll.EnterprisePollBO;
import com.cm.tenlion.pollutantdata.pojo.pos.enterprisepoll.EnterprisePollPO;
import com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @ClassName: IEnterprisePollDao
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@Repository
public interface IEnterprisePollDao {
/**
* 新增企业监控污染因子
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 删除企业监控污染因子
*
* @param params
* @throws RemoveException
*/
void remove(Map<String, Object> params) throws RemoveException;
/**
* 删除企业监控污染因子物理
*
* @param params
* @throws RemoveException
*/
void delete(Map<String, Object> params) throws RemoveException;
/**
* 修改企业监控污染因子
*
* @param params
* @throws UpdateException
*/
void update(Map<String, Object> params) throws UpdateException;
/**
* 企业监控污染因子详情
*
* @param params
* @return
* @throws SearchException
*/
EnterprisePollDTO get(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子详情
*
* @param params
* @return
* @throws SearchException
*/
EnterprisePollBO getBO(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子详情
*
* @param params
* @return
* @throws SearchException
*/
EnterprisePollPO getPO(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子列表
*
* @param params
* @return
* @throws SearchException
*/
List<EnterprisePollDTO> list(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子列表
*
* @param params
* @return
* @throws SearchException
*/
List<EnterprisePollBO> listBO(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子列表
*
* @param params
* @return
* @throws SearchException
*/
List<EnterprisePollPO> listPO(Map<String, Object> params) throws SearchException;
/**
* 企业监控污染因子统计
*
* @param params
* @return
* @throws SearchException
*/
Integer count(Map<String, Object> params) throws SearchException;
}

View File

@ -22,6 +22,15 @@ import java.util.Map;
@Repository
public interface IPollDao {
/**
* 污染因子超标企业统计
* @param params
* @return
*/
List<Map<String,Object>> listExcessiveCompany(Map<String,Object> params);
/**
* 新增污染因子
*

View File

@ -0,0 +1,96 @@
package com.cm.tenlion.pollutantdata.pojo.bos.enterprisepoll;
/**
*
* @ClassName: EnterprisePollBO
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
public class EnterprisePollBO {
private String enterprisePollId;
private String enterpriseId;
private String pollId;
private String enterprisePollBeyond;
private String gmtCreate;
private String creator;
private String gmtModified;
private String modifier;
private Integer isDelete;
public String getEnterprisePollId() {
return enterprisePollId == null ? "" : enterprisePollId.trim();
}
public void setEnterprisePollId(String enterprisePollId) {
this.enterprisePollId = enterprisePollId;
}
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId.trim();
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPollId() {
return pollId == null ? "" : pollId.trim();
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public String getEnterprisePollBeyond() {
return enterprisePollBeyond == null ? "" : enterprisePollBeyond.trim();
}
public void setEnterprisePollBeyond(String enterprisePollBeyond) {
this.enterprisePollBeyond = enterprisePollBeyond;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getCreator() {
return creator == null ? "" : creator.trim();
}
public void setCreator(String creator) {
this.creator = creator;
}
public String getGmtModified() {
return gmtModified == null ? "" : gmtModified.trim();
}
public void setGmtModified(String gmtModified) {
this.gmtModified = gmtModified;
}
public String getModifier() {
return modifier == null ? "" : modifier.trim();
}
public void setModifier(String modifier) {
this.modifier = modifier;
}
public Integer getIsDelete() {
return isDelete == null ? 0 : isDelete;
}
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
}

View File

@ -24,6 +24,8 @@ public class EnterpriseDTO {
private String enterpriseLat;
@ApiModelProperty(name = "gmtCreate", value = "添加时间")
private String gmtCreate;
@ApiModelProperty(name = "enterprisePollCount", value = "监控污染因子个数")
private Integer enterprisePollCount;
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId.trim();
@ -65,5 +67,11 @@ public class EnterpriseDTO {
this.gmtCreate = gmtCreate;
}
public Integer getEnterprisePollCount() {
return enterprisePollCount;
}
public void setEnterprisePollCount(Integer enterprisePollCount) {
this.enterprisePollCount = enterprisePollCount;
}
}

View File

@ -0,0 +1,88 @@
package com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @ClassName: EnterprisePollDTO
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@ApiModel
public class EnterprisePollDTO {
@ApiModelProperty(name = "enterprisePollId", value = "主键")
private String enterprisePollId;
@ApiModelProperty(name = "enterpriseId", value = "企业ID")
private String enterpriseId;
@ApiModelProperty(name = "enterpriseName", value = "企业名称")
private String enterpriseName;
@ApiModelProperty(name = "pollId", value = "污染因子ID")
private String pollId;
@ApiModelProperty(name = "pollName", value = "污染因子名称")
private String pollName;
@ApiModelProperty(name = "enterprisePollBeyond", value = "报警值")
private Double enterprisePollBeyond;
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
private String gmtCreate;
public String getEnterprisePollId() {
return enterprisePollId;
}
public void setEnterprisePollId(String enterprisePollId) {
this.enterprisePollId = enterprisePollId;
}
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId.trim();
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPollId() {
return pollId == null ? "" : pollId.trim();
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public Double getEnterprisePollBeyond() {
return enterprisePollBeyond;
}
public void setEnterprisePollBeyond(Double enterprisePollBeyond) {
this.enterprisePollBeyond = enterprisePollBeyond;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getPollName() {
return pollName;
}
public void setPollName(String pollName) {
this.pollName = pollName;
}
}

View File

@ -0,0 +1,96 @@
package com.cm.tenlion.pollutantdata.pojo.pos.enterprisepoll;
/**
*
* @ClassName: EnterprisePollPO
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
public class EnterprisePollPO {
private String enterprisePollId;
private String enterpriseId;
private String pollId;
private String enterprisePollBeyond;
private String gmtCreate;
private String creator;
private String gmtModified;
private String modifier;
private Integer isDelete;
public String getEnterprisePollId() {
return enterprisePollId == null ? "" : enterprisePollId.trim();
}
public void setEnterprisePollId(String enterprisePollId) {
this.enterprisePollId = enterprisePollId;
}
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId.trim();
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPollId() {
return pollId == null ? "" : pollId.trim();
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public String getEnterprisePollBeyond() {
return enterprisePollBeyond == null ? "" : enterprisePollBeyond.trim();
}
public void setEnterprisePollBeyond(String enterprisePollBeyond) {
this.enterprisePollBeyond = enterprisePollBeyond;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getCreator() {
return creator == null ? "" : creator.trim();
}
public void setCreator(String creator) {
this.creator = creator;
}
public String getGmtModified() {
return gmtModified == null ? "" : gmtModified.trim();
}
public void setGmtModified(String gmtModified) {
this.gmtModified = gmtModified;
}
public String getModifier() {
return modifier == null ? "" : modifier.trim();
}
public void setModifier(String modifier) {
this.modifier = modifier;
}
public Integer getIsDelete() {
return isDelete == null ? 0 : isDelete;
}
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
}

View File

@ -0,0 +1,48 @@
package com.cm.tenlion.pollutantdata.pojo.vos.enterprisepoll;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @ClassName: EnterprisePollVO
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@ApiModel
public class EnterprisePollVO {
@ApiModelProperty(name = "enterpriseId", value = "企业ID")
private String enterpriseId;
@ApiModelProperty(name = "pollId", value = "污染因子ID")
private String pollId;
@ApiModelProperty(name = "enterprisePollBeyond", value = "报警值")
private Double enterprisePollBeyond;
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId.trim();
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPollId() {
return pollId == null ? "" : pollId.trim();
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public Double getEnterprisePollBeyond() {
return enterprisePollBeyond;
}
public void setEnterprisePollBeyond(Double enterprisePollBeyond) {
this.enterprisePollBeyond = enterprisePollBeyond;
}
}

View File

@ -0,0 +1,189 @@
package com.cm.tenlion.pollutantdata.service.enterprisepoll;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO;
import com.cm.tenlion.pollutantdata.pojo.vos.enterprisepoll.EnterprisePollVO;
import com.cm.tenlion.pollutantdata.pojo.bos.enterprisepoll.EnterprisePollBO;
import com.cm.tenlion.pollutantdata.pojo.pos.enterprisepoll.EnterprisePollPO;
import java.util.List;
import java.util.Map;
/**
* @ClassName: IEnterprisePollService
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
public interface IEnterprisePollService {
/**
* 新增企业监控污染因子
*
* @param enterprisePollVO
* @return
*/
void save(EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 新增企业监控污染因子
*
* @param token
* @param enterprisePollVO
* @return
*/
void save(String token, EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 新增企业监控污染因子
*
* @param enterprisePollVO
* @return enterprisePollId
*/
String saveReturnId(EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 新增企业监控污染因子
*
* @param token
* @param enterprisePollVO
* @return enterprisePollId
*/
String saveReturnId(String token, EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 删除企业监控污染因子
*
* @param ids id列表
* @return
*/
void remove(List<String> ids);
/**
* 删除企业监控污染因子
*
* @param token
* @param ids id列表
* @return
*/
void remove(String token, List<String> ids);
/**
* 删除企业监控污染因子物理删除
*
* @param ids id列表
*/
void delete(List<String> ids);
/**
* 修改企业监控污染因子
*
* @param enterprisePollId
* @param enterprisePollVO
* @return
*/
void update(String enterprisePollId, EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 修改企业监控污染因子
*
* @param token
* @param enterprisePollId
* @param enterprisePollVO
* @return
*/
void update(String token, String enterprisePollId, EnterprisePollVO enterprisePollVO) throws Exception;
/**
* 企业监控污染因子详情
*
* @param params 参数Map
* @return
*/
EnterprisePollDTO get(Map<String, Object> params) throws Exception;
/**
* 企业监控污染因子详情
*
* @param enterprisePollId
* @return
*/
EnterprisePollDTO get(String enterprisePollId);
/**
* 企业监控污染因子详情
*
* @param params 参数Map
* @return
*/
EnterprisePollBO getBO(Map<String, Object> params);
/**
* 企业监控污染因子详情
*
* @param enterprisePollId
* @return
*/
EnterprisePollBO getBO(String enterprisePollId);
/**
* 企业监控污染因子详情
*
* @param params 参数Map
* @return
*/
EnterprisePollPO getPO(Map<String, Object> params);
/**
* 企业监控污染因子详情
*
* @param enterprisePollId
* @return
*/
EnterprisePollPO getPO(String enterprisePollId);
/**
* 企业监控污染因子列表
*
* @param params
* @return
*/
List<EnterprisePollDTO> list(Map<String, Object> params);
/**
* 企业监控污染因子列表
*
* @param params
* @return
*/
List<EnterprisePollBO> listBO(Map<String, Object> params);
/**
* 企业监控污染因子列表
*
* @param params
* @return
*/
List<EnterprisePollPO> listPO(Map<String, Object> params);
/**
* 企业监控污染因子分页列表
*
* @param page
* @return
*/
SuccessResultList<List<EnterprisePollDTO>> listPage(ListPage page);
/**
* 企业监控污染因子统计
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
}

View File

@ -0,0 +1,182 @@
package com.cm.tenlion.pollutantdata.service.enterprisepoll.impl;
import com.cm.common.base.AbstractService;
import com.cm.common.exception.SaveException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.tenlion.pollutantdata.dao.enterprisepoll.IEnterprisePollDao;
import com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO;
import com.cm.tenlion.pollutantdata.pojo.vos.enterprisepoll.EnterprisePollVO;
import com.cm.tenlion.pollutantdata.pojo.bos.enterprisepoll.EnterprisePollBO;
import com.cm.tenlion.pollutantdata.pojo.pos.enterprisepoll.EnterprisePollPO;
import com.cm.tenlion.pollutantdata.service.enterprisepoll.IEnterprisePollService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @ClassName: EnterprisePollServiceImpl
* @Description: 企业监控污染因子
* @Author: CodeFactory
* @Date: 2021-08-06 14:19:31
* @Version: 3.0
**/
@Service
public class EnterprisePollServiceImpl extends AbstractService implements IEnterprisePollService {
@Autowired
private IEnterprisePollDao enterprisePollDao;
@Override
public void save(EnterprisePollVO enterprisePollVO) throws Exception {
saveReturnId(enterprisePollVO);
}
@Override
public void save(String token, EnterprisePollVO enterprisePollVO) throws Exception{
saveReturnId(token, enterprisePollVO);
}
@Override
public String saveReturnId(EnterprisePollVO enterprisePollVO) throws Exception{
return saveReturnId(null, enterprisePollVO);
}
@Override
public String saveReturnId(String token, EnterprisePollVO enterprisePollVO) throws Exception{
Map<String,Object> countParams = new HashMap<>();
countParams.put("pollId",enterprisePollVO.getPollId());
countParams.put("enterpriseId",enterprisePollVO.getEnterpriseId());
Integer count = this.count(countParams);
if(count > 0){
throw new SaveException("请勿重复添加");
}
String enterprisePollId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(enterprisePollVO);
params.put("enterprisePollId", enterprisePollId);
if (StringUtils.isBlank(token)) {
setSaveInfo(params);
} else {
setSaveInfo(token, params);
}
enterprisePollDao.save(params);
return enterprisePollId;
}
@Override
public void remove(List<String> ids) {
remove(null, ids);
}
@Override
public void remove(String token, List<String> ids) {
Map<String, Object> params = getHashMap(2);
params.put("enterprisePollIds", ids);
if (StringUtils.isBlank(token)) {
setUpdateInfo(params);
} else {
setUpdateInfo(token, params);
}
enterprisePollDao.remove(params);
}
@Override
public void delete(List<String> ids) {
Map<String, Object> params = getHashMap(2);
params.put("enterprisePollIds", ids);
enterprisePollDao.delete(params);
}
@Override
public void update(String enterprisePollId, EnterprisePollVO enterprisePollVO) throws Exception{
update(null, enterprisePollId, enterprisePollVO);
}
@Override
public void update(String token, String enterprisePollId, EnterprisePollVO enterprisePollVO)throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(enterprisePollVO);
params.put("enterprisePollId", enterprisePollId);
if (StringUtils.isBlank(token)) {
setUpdateInfo(params);
} else {
setUpdateInfo(token, params);
}
enterprisePollDao.update(params);
}
@Override
public EnterprisePollDTO get(Map<String, Object> params) {
return enterprisePollDao.get(params);
}
@Override
public EnterprisePollDTO get(String enterprisePollId) {
Map<String, Object> params = super.getHashMap(2);
params.put("enterprisePollId", enterprisePollId);
return get(params);
}
@Override
public EnterprisePollBO getBO(Map<String, Object> params) {
return enterprisePollDao.getBO(params);
}
@Override
public EnterprisePollBO getBO(String enterprisePollId) {
Map<String, Object> params = super.getHashMap(2);
params.put("enterprisePollId", enterprisePollId);
return getBO(params);
}
@Override
public EnterprisePollPO getPO(Map<String, Object> params) {
return enterprisePollDao.getPO(params);
}
@Override
public EnterprisePollPO getPO(String enterprisePollId) {
Map<String, Object> params = super.getHashMap(2);
params.put("enterprisePollId", enterprisePollId);
return getPO(params);
}
@Override
public List<EnterprisePollDTO> list(Map<String, Object> params) {
return enterprisePollDao.list(params);
}
@Override
public List<EnterprisePollBO> listBO(Map<String, Object> params) {
return enterprisePollDao.listBO(params);
}
@Override
public List<EnterprisePollPO> listPO(Map<String, Object> params) {
return enterprisePollDao.listPO(params);
}
@Override
public SuccessResultList<List<EnterprisePollDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<EnterprisePollDTO> enterprisePollDTOs = list(page.getParams());
PageInfo<EnterprisePollDTO> pageInfo = new PageInfo<>(enterprisePollDTOs);
return new SuccessResultList<>(enterprisePollDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public Integer count(Map<String, Object> params) {
Integer count = enterprisePollDao.count(params);
return count == null ? 0 : count;
}
}

View File

@ -19,6 +19,13 @@ import java.util.Map;
**/
public interface IPollService {
/**
* 污染因子超标企业
* @param params
* @return
*/
List<Map<String,Object>> listExcessiveCompany(Map<String,Object> params);
/**
* 新增污染因子
*

View File

@ -34,6 +34,15 @@ public class PollServiceImpl extends AbstractService implements IPollService {
@Autowired
private IPollDao pollDao;
public List<Map<String,Object>> listExcessiveCompany(Map<String,Object> params){
return pollDao.listExcessiveCompany(params);
}
@Override
public void save(PollVO pollVO) throws Exception {
saveReturnId(pollVO);

View File

@ -1,6 +1,6 @@
server:
port: 7004
url: http://192.168.0.103:7004/pollutant
port: 8080
url: http://192.168.0.120:8080/pollutant
title: 污染物上报系统
servlet:
context-path: /pollutant
@ -22,11 +22,11 @@ spring:
max-request-size: 1GB
datasource:
druid:
url: jdbc:mysql://192.168.0.151:3306/db_pollutant_data?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC
url: jdbc:mysql://localhost:3306/db_pollutant_data?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
password: 123456
initial-size: 2
min-idle: 2
max-active: 10
@ -60,8 +60,8 @@ security:
oauth-server: http://192.168.0.152:7001/usercenter
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
client:
client-id: 2a347bba1dc54def83a47493c7578ae2
client-secret: TEdsOHlnTnc4T2JwTXM3alZldzRSM1ROKzhaQkZaQ24vSWJxREd0TWVLMG1ac2wwZTJHWk5NbXh3L3h3U2c4Rg==
client-id: 74e4b55ad48840f9b4de86ce5da58b53
client-secret: VjlWbUFFbkJKMmZ3U29lekROb2x3M3Q1SmEzOGlwV3NzT3ZqSDByQVZoWW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg==
user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize
access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token
grant-type: authorization_code
@ -75,7 +75,7 @@ security:
api-path:
user-center: ${security.oauth2.oauth-server}
inspection: http://192.168.0.103:7006/inspection
inspection: http://124.67.110.246:8081/inspection
system:
# 预警通知上限
alarm-notice-limit: 5
@ -95,7 +95,7 @@ logging:
swagger:
title: 接口文档
description: 隐患排查系统接口文档
service-url: http://192.168.0.103:7004/pollutant
service-url: http://106.12.218.237:8001/pollutant
version: 1.0
swagger-base-package: com.cm

View File

@ -125,6 +125,10 @@
AND
enterprise_id = #{enterpriseId}
</if>
<if test="month != null and month != ''">
AND
DATE_FORMAT( LEFT(gmt_create, 19), '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</if>
</select>
<!-- 统计企业报警次数 -->

View File

@ -8,6 +8,7 @@
<result column="enterprise_lng" property="enterpriseLng"/>
<result column="enterprise_lat" property="enterpriseLat"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="enterprise_poll_count" property="enterprisePollCount"/>
</resultMap>
<resultMap id="enterpriseBO" type="com.cm.tenlion.pollutantdata.pojo.bos.enterprise.EnterpriseBO">
@ -177,7 +178,15 @@
t1.enterprise_name,
t1.enterprise_lng,
t1.enterprise_lat,
LEFT(t1.gmt_create, 19) gmt_create
LEFT(t1.gmt_create, 19) gmt_create,
(
SELECT
count(*)
FROM
pollute_enterprise_poll t2
WHERE t2.is_delete = 0
AND t1.enterprise_id = t2.enterprise_id
) AS enterprise_poll_count
FROM
pollute_enterprise t1
WHERE

View File

@ -0,0 +1,312 @@
<?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.cm.tenlion.pollutantdata.dao.enterprisepoll.IEnterprisePollDao">
<resultMap id="enterprisePollDTO" type="com.cm.tenlion.pollutantdata.pojo.dtos.enterprisepoll.EnterprisePollDTO">
<result column="enterprise_poll_id" property="enterprisePollId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="enterprise_name" property="enterpriseName"/>
<result column="poll_id" property="pollId"/>
<result column="poll_name" property="pollName"/>
<result column="enterprise_poll_beyond" property="enterprisePollBeyond"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<resultMap id="enterprisePollBO" type="com.cm.tenlion.pollutantdata.pojo.bos.enterprisepoll.EnterprisePollBO">
<result column="enterprise_poll_id" property="enterprisePollId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="poll_id" property="pollId"/>
<result column="enterprise_poll_beyond" property="enterprisePollBeyond"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="modifier" property="modifier"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="enterprisePollPO" type="com.cm.tenlion.pollutantdata.pojo.pos.enterprisepoll.EnterprisePollPO">
<result column="enterprise_poll_id" property="enterprisePollId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="poll_id" property="pollId"/>
<result column="enterprise_poll_beyond" property="enterprisePollBeyond"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="modifier" property="modifier"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增企业监控污染因子 -->
<insert id="save" parameterType="map">
INSERT INTO pollute_enterprise_poll(
enterprise_poll_id,
enterprise_id,
poll_id,
enterprise_poll_beyond,
gmt_create,
creator,
gmt_modified,
modifier,
is_delete
) VALUES(
#{enterprisePollId},
#{enterpriseId},
#{pollId},
#{enterprisePollBeyond},
#{gmtCreate},
#{creator},
#{gmtModified},
#{modifier},
#{isDelete}
)
</insert>
<!-- 删除企业监控污染因子 -->
<update id="remove" parameterType="map">
UPDATE
pollute_enterprise_poll
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
enterprise_poll_id IN
<foreach collection="enterprisePollIds" index="index" open="(" separator="," close=")">
#{enterprisePollIds[${index}]}
</foreach>
</update>
<!-- 删除企业监控污染因子(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
pollute_enterprise_poll
WHERE
enterprise_poll_id IN
<foreach collection="enterprisePollIds" index="index" open="(" separator="," close=")">
#{enterprisePollIds[${index}]}
</foreach>
</update>
<!-- 修改企业监控污染因子 -->
<update id="update" parameterType="map">
UPDATE
pollute_enterprise_poll
SET
<if test="enterpriseId != null and enterpriseId != ''">
enterprise_id = #{enterpriseId},
</if>
<if test="pollId != null">
poll_id = #{pollId},
</if>
<if test="enterprisePollBeyond != null and enterprisePollBeyond != ''">
enterprise_poll_beyond = #{enterprisePollBeyond},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
enterprise_poll_id = enterprise_poll_id
WHERE
enterprise_poll_id = #{enterprisePollId}
</update>
<!-- 企业监控污染因子详情 -->
<select id="get" parameterType="map" resultMap="enterprisePollDTO">
SELECT
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
t1.enterprise_poll_id,
t2.poll_name,
t3.enterprise_name
FROM
pollute_enterprise_poll t1
LEFT JOIN pollute_poll t2
ON t1.poll_id = t2.poll_id
LEFT JOIN pollute_enterprise t3
ON t1.enterprise_id = t3.enterprise_id
WHERE
t1.is_delete = 0
<if test="enterprisePollId != null and enterprisePollId != ''">
AND
t1.enterprise_poll_id = #{enterprisePollId}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
AND
t1.enterprise_id = #{enterpriseId}
</if>
<if test="pollId != null and pollId != ''">
AND
t1.poll_id = #{pollId}
</if>
</select>
<!-- 企业监控污染因子详情 -->
<select id="getBO" parameterType="map" resultMap="enterprisePollBO">
SELECT
t1.enterprise_poll_id,
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
pollute_enterprise_poll t1
WHERE
t1.is_delete = 0
<if test="enterprisePollId != null and enterprisePollId != ''">
AND
t1.enterprise_poll_id = #{enterprisePollId}
</if>
</select>
<!-- 企业监控污染因子详情 -->
<select id="getPO" parameterType="map" resultMap="enterprisePollPO">
SELECT
t1.enterprise_poll_id,
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
pollute_enterprise_poll t1
WHERE
t1.is_delete = 0
<if test="enterprisePollId != null and enterprisePollId != ''">
AND
t1.enterprise_poll_id = #{enterprisePollId}
</if>
</select>
<!-- 企业监控污染因子列表 -->
<select id="list" parameterType="map" resultMap="enterprisePollDTO">
SELECT
t1.enterprise_poll_id,
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
LEFT(t1.gmt_create, 19) AS gmt_create,
t2.poll_name,
t3.enterprise_name
FROM
pollute_enterprise_poll t1
LEFT JOIN pollute_poll t2
ON t1.poll_id = t2.poll_id
LEFT JOIN pollute_enterprise t3
ON t1.enterprise_id = t3.enterprise_id
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t2.poll_name LIKE CONCAT('%', #{keywords}, '%')
OR
t3.enterprise_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="enterpriseId != null and enterpriseId != ''">
AND t1.enterprise_id = #{enterpriseId}
</if>
ORDER BY t1.gmt_create DESC
</select>
<!-- 企业监控污染因子列表 -->
<select id="listBO" parameterType="map" resultMap="enterprisePollBO">
SELECT
t1.enterprise_poll_id,
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
pollute_enterprise_poll t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="enterprisePollIds != null and enterprisePollIds.size > 0">
AND
t1.enterprise_poll_id IN
<foreach collection="enterprisePollIds" index="index" open="(" separator="," close=")">
#{enterprisePollIds[${index}]}
</foreach>
</if>
</select>
<!-- 企业监控污染因子列表 -->
<select id="listPO" parameterType="map" resultMap="enterprisePollPO">
SELECT
t1.enterprise_poll_id,
t1.enterprise_id,
t1.poll_id,
t1.enterprise_poll_beyond,
t1.gmt_create,
t1.creator,
t1.gmt_modified,
t1.modifier,
t1.is_delete
FROM
pollute_enterprise_poll t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="enterprisePollIds != null and enterprisePollIds.size > 0">
AND
t1.enterprise_poll_id IN
<foreach collection="enterprisePollIds" index="index" open="(" separator="," close=")">
#{enterprisePollIds[${index}]}
</foreach>
</if>
</select>
<!-- 企业监控污染因子统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
pollute_enterprise_poll t1
WHERE
t1.is_delete = 0
<if test="pollId != null and pollId != ''">
AND t1.poll_id = #{pollId}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
AND t1.enterprise_id = #{enterpriseId}
</if>
</select>
</mapper>

View File

@ -306,4 +306,26 @@
1 = 1
</select>
<!--污染因子超标企业-->
<select id="listExcessiveCompany" parameterType="map" resultType="java.util.Map">
SELECT
t1.poll_name AS pollName,
t1.unit_concentration AS unitConcentration,
(SELECT
count(DISTINCT t2.enterprise_id)
FROM
pollute_alarm_log t2
WHERE
(
t2.poll_id = t1.poll_no
OR
t2.poll_id = t1.poll_no_old
)
) AS companyNum
FROM
pollute_poll t1
HAVING companyNum > 0
</select>
</mapper>

View File

@ -115,6 +115,12 @@
return rowData;
}
},
{field: 'cz', width: 180, title: '操作', align:'center',
templet: function(row) {
var enterprisePollCount = row['enterprisePollCount'];
return '<button type="button" class="layui-btn layui-btn-sm" lay-event="enterprisePollEvent">监控污染因子【'+enterprisePollCount+'个】</button>';
}
},
]
],
page: true,
@ -271,6 +277,14 @@
height: '500px',
onClose: function() {}
});
}else if(event === 'enterprisePollEvent'){
top.dialog.open({
url: top.restAjax.path('route/enterprisepoll/list?enterpriseId={enterpriseId}', [data.enterpriseId]),
title: '【'+ data.enterpriseName +'】的监控污染因子数据',
width: '80%',
height: '80%',
onClose: function() {}
});
}
});
});

View File

@ -0,0 +1,247 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<!-- <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>-->
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/enterprisepoll/listpage';
var enterpriseId = top.restAjax.params(window.location.href).enterpriseId;
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, []),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
where:{
enterpriseId:enterpriseId
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'enterpriseName', width: 250, title: '企业名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'pollName', width: 180, title: '污染因子', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'enterprisePollBeyond', width: 180, title: '报警值', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'gmtCreate', width: 180, title: '创建时间', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, []),
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
height: $win.height() - 90,
});
}
// 初始化日期
function initDate() {
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/enterprisepoll/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['500px', '500px'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/enterprisepoll/save?enterpriseId={enterpriseId}', [enterpriseId]),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['500px', '500px'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/enterprisepoll/update?enterprisePollId={enterprisePollId}', [checkDatas[0].enterprisePollId]),
end: function() {
reloadTable();
}
});
}
} else if(layEvent === 'removeEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item['enterprisePollId'];
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,189 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">污染因子ID</label>
<div class="layui-input-block layui-form" id="pollIdSelectTemplateBox" lay-filter="pollIdSelectTemplateBox"></div>
<script id="pollIdSelectTemplate" type="text/html">
<select id="pollId" name="pollId" lay-verify="required">
<option value="">请选择污染因子ID</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.pollId}}">{{item.pollName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item">
<label class="layui-form-label">报警值</label>
<div class="layui-input-block">
<input type="number" lay-verify="required" id="enterprisePollBeyond" name="enterprisePollBeyond" class="layui-input" value="" placeholder="请输入报警值" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var wangEditor = window.wangEditor;
var wangEditorObj = {};
var viewerObj = {};
var enterpriseId = top.restAjax.params(window.location.href).enterpriseId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化视频
function initVideo(fileName, data) {
for(var i = 0, item; item = data[i++];) {
var player = new ckplayer({
container: '#'+ fileName + i,
variable: 'player',
flashplayer: false,
video: {
file: 'route/file/download/true/'+ item.fileId,
type: 'video/mp4'
}
});
}
}
// 初始化污染因子ID下拉选择
function initPollIdSelect() {
top.restAjax.get(top.restAjax.path('api/poll/list', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('pollIdSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('pollIdSelectTemplateBox').innerHTML = html;
});
form.render('select', 'pollIdSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化内容
function initData() {
initPollIdSelect();
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
formData.field.enterpriseId = enterpriseId;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/enterprisepoll/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,212 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">企业ID</label>
<div class="layui-input-block">
<input type="text" id="enterpriseId" name="enterpriseId" class="layui-input" value="" placeholder="请输入企业ID" maxlength="36">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">污染因子ID</label>
<div class="layui-input-block layui-form" id="pollIdSelectTemplateBox" lay-filter="pollIdSelectTemplateBox"></div>
<script id="pollIdSelectTemplate" type="text/html">
<select id="pollId" name="pollId">
<option value="">请选择污染因子ID</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.pollId}}">{{item.pollName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item">
<label class="layui-form-label">报警值</label>
<div class="layui-input-block">
<input type="number" id="enterprisePollBeyond" name="enterprisePollBeyond" class="layui-input" value="" placeholder="请输入报警值" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var enterprisePollId = top.restAjax.params(window.location.href).enterprisePollId;
var wangEditor = window.wangEditor;
var wangEditorObj = {};
var viewerObj = {};
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化视频
function initVideo(fileName, data) {
for(var i = 0, item; item = data[i++];) {
var player = new ckplayer({
container: '#'+ fileName + i,
variable: 'player',
flashplayer: false,
video: {
file: 'route/file/download/true/'+ item.fileId,
type: 'video/mp4'
}
});
}
}
// 初始化污染因子ID下拉选择
function initPollIdSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/poll/list', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('pollIdSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('pollIdSelectTemplateBox').innerHTML = html;
});
form.render('select', 'pollIdSelectTemplateBox');
var selectObj = {};
selectObj['pollId'] = selectValue;
form.val('dataForm', selectObj);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/enterprisepoll/get/{enterprisePollId}', [enterprisePollId]), {}, null, function(code, data) {
var dataFormData = {};
for(var i in data) {
dataFormData[i] = data[i] +'';
}
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initPollIdSelect(data['pollId']);
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/enterprisepoll/update/{enterprisePollId}', [enterprisePollId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>