diff --git a/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGate.java b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGate.java new file mode 100644 index 0000000..4cd7586 --- /dev/null +++ b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGate.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.baseinfo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import org.springblade.core.mp.base.BaseEntity; + + +@Data +@TableName("irrbdgate") +public class IrrBDGate extends BaseEntity { + private String strobeCode; + + private String stcd; + + private String watergateCode; + + private String producingArea; + + private String factory; + + private String strobeType; + + private String strobeMaterial; + + private Double height; + + private Double width; + + private Double thickness; + + private String motivity; + + private String type; + + private Short velocity; + + private String areaCode; + + private String lrcd; + + private String szhldm; + + private Float dongj; + + private Float beiw; + + private Float discharge; +} diff --git a/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGateRefData.java b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGateRefData.java new file mode 100644 index 0000000..df07289 --- /dev/null +++ b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/IrrBDGateRefData.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.baseinfo.entity; + +import lombok.Data; + +@Data +public class IrrBDGateRefData { + private String strobeCode; + + private String refstcd; + + private String refqpoint; + + private String refzpoint; +} diff --git a/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrBsin.java b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrBsin.java new file mode 100644 index 0000000..1fccf8f --- /dev/null +++ b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrBsin.java @@ -0,0 +1,64 @@ +package com.hnac.hzims.baseinfo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.base.BaseEntity; + +import java.util.Date; + +/** + * 水库信息表 + */ +@Data +@TableName("st_rsr_bsin") +public class StRsrBsin extends BaseEntity { + @ApiModelProperty("水库代码") + private String rscd; + @ApiModelProperty("水库名称") + private String rtunm; + @ApiModelProperty("主管部门") + private String cmdp; + @ApiModelProperty("主管部门联系电话") + private String cmdptel; + @ApiModelProperty("河流名称") + private String rvcd; + @ApiModelProperty("水系名称") + private String hnnm; + @ApiModelProperty("流域名称") + private String ctcd; + @ApiModelProperty("东经") + private Double eslg; + @ApiModelProperty("北纬") + private Double nrlt; + @ApiModelProperty("站址") + private String stlc; + @ApiModelProperty("行政区划码") + private String addvcd; + @ApiModelProperty("基面名称") + private String dtmnm; + @ApiModelProperty("基面高程") + private Double dtmel; + @ApiModelProperty("基面修正值") + private Double dtpr; + @ApiModelProperty("报汛等级") + private String frgrd; + @ApiModelProperty("集水面积") + private Double drna; + @ApiModelProperty("拼音码") + private String phcd; + @ApiModelProperty("启用标志") + private String usfl; + @ApiModelProperty("备注") + private String comments; + @ApiModelProperty("建成时间") + private Date buildTime; + @ApiModelProperty("最大坝高") + private Double maxdmhg; + @ApiModelProperty("坝型") + private String dmtp; + @ApiModelProperty("库区GIS范围") + private String gisRange; + @ApiModelProperty("水库功能(可多选)") + private String rsfn; +} diff --git a/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrHych.java b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrHych.java new file mode 100644 index 0000000..8fd62bd --- /dev/null +++ b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/entity/StRsrHych.java @@ -0,0 +1,62 @@ +package com.hnac.hzims.baseinfo.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 水库防洪信息 + */ +@Data +@TableName("st_rsr_hych") +public class StRsrHych implements Serializable { + @ApiModelProperty("水库代码") + @TableId(type = IdType.INPUT) + private String rscd; + @ApiModelProperty("水库类型") + private String rsvrtp; + @ApiModelProperty("坝顶高程") + private Double damel; + @ApiModelProperty("控制流域面积") + private Double cnctar; + @ApiModelProperty("校核洪水位") + private Double chfl; + @ApiModelProperty("设计洪水位") + private Double dsfl; + @ApiModelProperty("正常高水位") + private Double normz; + @ApiModelProperty("死水位") + private Double ddwz; + @ApiModelProperty("汛限水位") + private Double mjfl; + @ApiModelProperty("兴利水位") + private Double actz; + @ApiModelProperty("总库容") + private Double ttcp; + @ApiModelProperty("防洪库容") + private Double fldcp; + @ApiModelProperty("兴利库容") + private Double actcp; + @ApiModelProperty("死库容") + private Double ddcp; + @ApiModelProperty("历史最高库水位") + private Double hhrz; + @ApiModelProperty("历史最大蓄水量") + private Double hmxw; + @ApiModelProperty("历史最高库水位(蓄水量)时间") + private Date maxleveltime; + @ApiModelProperty("低水位告警值") + private Double laz; + @ApiModelProperty("启动预报流量标准") + private Double sfq; + @ApiModelProperty("时间戳") + private Date moditime; + @ApiModelProperty("更新时间") + private Date dtuptm; + +} diff --git a/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/vo/StRsrBsinVo.java b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/vo/StRsrBsinVo.java new file mode 100644 index 0000000..97d49d0 --- /dev/null +++ b/hzims-service-api/base-info-api/src/main/java/com/hnac/hzims/baseinfo/vo/StRsrBsinVo.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.baseinfo.vo; + +import com.hnac.hzims.baseinfo.entity.StRsrBsin; + +public class StRsrBsinVo extends StRsrBsin { + + //行政区划名称 + private String addvcdnm; + /*** 水位*/ + private String waterLevel; + + /*** 库容*/ + private String capacity; + + public String getAddvcdnm() { + return addvcdnm; + } + + public void setAddvcdnm(String addvcdnm) { + this.addvcdnm = addvcdnm; + } + + public String getWaterLevel() { + return waterLevel; + } + + public void setWaterLevel(String waterLevel) { + this.waterLevel = waterLevel; + } + + public String getCapacity() { + return capacity; + } + + public void setCapacity(String capacity) { + this.capacity = capacity; + } +} diff --git a/hzims-service-api/digital-twin-display-api/pom.xml b/hzims-service-api/digital-twin-display-api/pom.xml new file mode 100644 index 0000000..0ca55dc --- /dev/null +++ b/hzims-service-api/digital-twin-display-api/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + com.hnac.hzims + hzims-service-api + 4.0.0-SNAPSHOT + + + + digital-twin-display-api + jar + ${hzims.project.version} + + + 8 + 8 + UTF-8 + + + \ No newline at end of file diff --git a/hzims-service-api/weather-api/README.md b/hzims-service-api/weather-api/README.md new file mode 100644 index 0000000..0dd908b --- /dev/null +++ b/hzims-service-api/weather-api/README.md @@ -0,0 +1,6 @@ +# 工程简介 + + + +# 延伸阅读 + diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/GateInfoController.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/GateInfoController.java new file mode 100644 index 0000000..2046359 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/GateInfoController.java @@ -0,0 +1,165 @@ +package com.hnac.hzims.baseinfo.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.baseinfo.entity.IrrBDGate; +import com.hnac.hzims.baseinfo.entity.IrrBDGateRefData; +import com.hnac.hzims.baseinfo.service.IGateInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +@RestController +@RequestMapping("/reservoirBaseInfo/gateInfo") +@AllArgsConstructor +@Api(value = "闸门信息", tags = "闸门信息接口") +public class GateInfoController { + private final IGateInfoService gateInfoService; + + + @RequestMapping(value = "save", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("添加闸门") + public R addGate(@RequestBody IrrBDGate irrBDGate) { + String deptId = AuthUtil.getDeptId(); + IrrBDGate tmp = new IrrBDGate(); + tmp.setStrobeCode(irrBDGate.getStrobeCode()); + tmp.setStcd(irrBDGate.getStcd()); + List page = gateInfoService.list(tmp); + if (page != null && !page.isEmpty()) { + return R.fail(500, "存在重复的闸门代码为:" + irrBDGate.getStrobeCode() + "的数据"); + } + return R.data(gateInfoService.addGate(irrBDGate)); + } + + @RequestMapping(value = "remove", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("删除闸门") + public R deleteGate(@ApiParam(value = "闸门id") @RequestParam Long id) { + boolean i = gateInfoService.removeById(id); + if (i) { + return R.data(true, "删除成功"); + } + return R.fail(500, "不存在此记录"); + } + + @RequestMapping(value = "updateGate", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("修改闸门") + public R updateGate(@RequestBody IrrBDGate irrBDGate) { + + irrBDGate.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); + int i = gateInfoService.updateGate(irrBDGate); + if (i>0) { + return R.data(true, "修改成功"); + } + return R.fail(500, "修改失败"); + } + + @RequestMapping(value = "pageList", method = {RequestMethod.GET}) + @ResponseBody + @ApiOperation("查询闸门") + public R pageList(@ModelAttribute IrrBDGate irrBDGate, HttpServletRequest request, Query query) { + String deptId=request.getHeader("dept-id"); + if(StringUtil.isEmpty(deptId)) { + deptId =AuthUtil.getDeptId(); + } + + if(StringUtil.isNotBlank(deptId)) { + irrBDGate.setCreateDept(Long.valueOf(deptId)); + } + + IPage page = gateInfoService.selectGate(irrBDGate, Condition.getPage(query)); + return R.data(page, "查询成功"); + } + + @RequestMapping(value = "list", method = {RequestMethod.GET}) + @ResponseBody + @ApiOperation("查询闸门") + public R list(@ModelAttribute IrrBDGate irrBDGate) { + + irrBDGate.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); + List list = gateInfoService.list(irrBDGate); + return R.data(list, "查询成功"); + + } + + + /** + * 修改闸门配置 + * + * @return + */ + @RequestMapping(value = "saveRef", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("修改闸门配置") + public R saveRef(@RequestBody IrrBDGateRefData irrBDGateRef) { + int i = gateInfoService.addGateRef(irrBDGateRef); + if (i > 0) { + return R.data(true, "修改成功"); + } + return R.fail(500, "修改失败"); + } + + /** + * 删除闸门配置 + * + * @return + */ + @RequestMapping(value = "removeRef", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("删除闸门配置") + public R deleteGateRef(@ApiParam(value = "闸门编码") @RequestParam String gateCode) { + int i = gateInfoService.deleteGateRef(gateCode); + if (i > 0) { + return R.data(true, "删除成功"); + } + return R.fail(500, "删除失败"); + + } + + /** + * 修改闸门配置 + * + * @return + */ + @RequestMapping(value = "updateRef", method = {RequestMethod.POST}) + @ResponseBody + @ApiOperation("修改闸门配置") + public R updateGateRef(@RequestBody IrrBDGateRefData irrBDGateRef) { + + + int i = gateInfoService.updateGateRef(irrBDGateRef); + if (i > 0) { + return R.data(true, "修改成功"); + } + return R.fail(500, "修改失败"); + + + } + + /** + * 查询闸门配置 + * + * @return + */ + @RequestMapping(value = "detailRef", method = {RequestMethod.GET}) + @ResponseBody + @ApiOperation("查询闸门配置") + public R listRef(@ApiParam(value = "闸门编码") @RequestParam String gateCode) { + + IrrBDGateRefData res = gateInfoService.detailRef(gateCode); + return R.data(res, "查询成功"); + + + } +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/StRsrBsinController.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/StRsrBsinController.java new file mode 100644 index 0000000..f03b79a --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/controller/StRsrBsinController.java @@ -0,0 +1,165 @@ +package com.hnac.hzims.baseinfo.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.baseinfo.entity.StRsrBsin; +import com.hnac.hzims.baseinfo.entity.StRsrHych; +import com.hnac.hzims.baseinfo.service.IStRsrBsinService; +import com.hnac.hzims.baseinfo.service.IStRsrHychService; +import com.hnac.hzims.baseinfo.vo.StRsrBsinVo; +import com.hnac.hzims.baseinfo.wrapper.StRsrBsinWrapper; +import io.swagger.annotations.*; +import lombok.AllArgsConstructor; +import org.springblade.common.cache.CacheNames; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/reservoir/stRsrBsin") +@AllArgsConstructor +@Api(value = "水库信息", tags = "水库信息接口") +public class StRsrBsinController extends BladeController implements CacheNames { + + private final IStRsrBsinService stRsrBsinService; + + + private final IStRsrHychService stRsrHychService; + + /** + * 分页 + */ + @GetMapping("/pageList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rscd", value = "水库代码", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "rtunm", value = "水库名称", paramType = "query", dataType = "string") + }) + @ApiOperationSupport(order = 1) + @ApiOperation(value = "分页", notes = "传入stRsrBsin") + public R> pageList(@ApiIgnore @RequestParam Map param, Query query, HttpServletRequest request) { + LambdaQueryWrapper wrapper=new LambdaQueryWrapper(); + if(param.get("rscd")!=null) { + wrapper.like(StRsrBsin::getRscd,param.get("rscd")); + } + if(param.get("rtunm")!=null) { + wrapper.like(StRsrBsin::getRtunm,param.get("rtunm")); + } + String deptId=request.getHeader("dept-id"); + if(StringUtil.isEmpty(deptId)) { + deptId =AuthUtil.getDeptId(); + } + if(StringUtil.isNotBlank(deptId)) { + wrapper.like(StRsrBsin::getCreateDept,deptId); + } + IPage pages = stRsrBsinService.page(Condition.getPage(query), wrapper); + return R.data(StRsrBsinWrapper.build().pageVO(pages)); + } + + /** + * 列表 + */ + @GetMapping("/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rscd", value = "水库代码", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "rtunm", value = "水库名称", paramType = "query", dataType = "string") + }) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "列表", notes = "传入stRsrBsin") + public R> list(@ApiIgnore @RequestParam Map param, HttpServletRequest request) { + LambdaQueryWrapper wrapper=new LambdaQueryWrapper(); + if(param.get("rscd")!=null) { + wrapper.like(StRsrBsin::getRscd,param.get("rscd")); + } + if(param.get("rtunm")!=null) { + wrapper.like(StRsrBsin::getRtunm,param.get("rtunm")); + } + String deptId = request.getHeader("dept-id"); + if (StringUtil.isEmpty(deptId)) { + deptId = AuthUtil.getDeptId(); + } + if (StringUtil.isNotBlank(deptId)) { + wrapper.like(StRsrBsin::getCreateDept, deptId); + } + List list = stRsrBsinService.list(wrapper); + return R.data(StRsrBsinWrapper.build().listVO(list)); + } + + + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "详情", notes = "传入stRsrBsin") + public R> detail(StRsrBsin stRsrBsin) { + Map data=new HashMap<>(); + StRsrBsin detail = stRsrBsinService.getOne(Condition.getQueryWrapper(stRsrBsin)); + data.put("stRsrBsin", StRsrBsinWrapper.build().entityVO(detail)); + //防洪信息 + StRsrHych param=new StRsrHych(); + param.setRscd(stRsrBsin.getRscd()); + StRsrHych stRsrHych=stRsrHychService.getOne(Condition.getQueryWrapper(param)); + data.put("stRsrHych",stRsrHych); + return R.data(data); + } + + /** + * 新增 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入stRsrBsin") + public R save(@RequestBody StRsrBsin stRsrBsin) { + if(stRsrBsin==null){ + return R.fail("水库信息不能为空"); + } + LambdaQueryWrapper wrapper=new LambdaQueryWrapper(); + wrapper.eq(StRsrBsin::getRscd,stRsrBsin.getRscd()); + List list =stRsrBsinService.list(wrapper); + if(list!=null && !list.isEmpty()){ + return R.fail("水库编码已存在"); + } + + wrapper=new LambdaQueryWrapper(); + wrapper.eq(StRsrBsin::getRtunm,stRsrBsin.getRtunm()); + list =stRsrBsinService.list(wrapper); + if(list!=null && !list.isEmpty()){ + return R.fail("水库名称已存在"); + } + + return R.status(stRsrBsinService.save(stRsrBsin)); + } + + /** + * 修改 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入stRsrBsin") + public R update(@RequestBody StRsrBsin stRsrBsin) { + return R.status(stRsrBsinService.updateById(stRsrBsin)); + } + + + @PostMapping("/remove") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "逻辑删除", notes = "ids") + public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { + boolean temp = stRsrBsinService.deleteLogic(Func.toLongList(ids)); + return R.status(temp); + } + +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.java new file mode 100644 index 0000000..0c02993 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.baseinfo.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.baseinfo.entity.IrrBDGate; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface IrrBDGateMapper extends BaseMapper { + + IPage selectByExample(@Param("example") IrrBDGate example, IPage page); + + + List selectByExample(@Param("example") IrrBDGate example); +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.xml b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.xml new file mode 100644 index 0000000..26c295f --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID,STROBE_CODE, WATERGATE_CODE, PRODUCING_AREA, FACTORY, STROBE_TYPE, STROBE_MATERIAL, + HEIGHT, WIDTH, THICKNESS, MOTIVITY, TYPE, VELOCITY, AREA_CODE, LRCD, SZHLDM, DONGJ, + BEIW, DISCHARGE,STCD + + + + + + \ No newline at end of file diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.java new file mode 100644 index 0000000..86832ca --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.baseinfo.mapper; + +import com.hnac.hzims.baseinfo.entity.IrrBDGateRefData; + + +public interface IrrBDGateRefDataMapper { + int insertSelective(IrrBDGateRefData record); + + int updateByPrimaryKeySelective(IrrBDGateRefData record); + + IrrBDGateRefData selectByPrimaryKey(String strobeCode); + + int deleteByPrimaryKey(String strobeCode); +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.xml b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.xml new file mode 100644 index 0000000..b30cf86 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/IrrBDGateRefDataMapper.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + STROBE_CODE, REFSTCD, REFQPOINT, REFZPOINT + + + + + insert into irrbdgate_refdata + + + STROBE_CODE, + + + REFSTCD, + + + REFQPOINT, + + + REFZPOINT, + + + + + #{strobeCode,jdbcType=CHAR}, + + + #{refstcd,jdbcType=CHAR}, + + + #{refqpoint,jdbcType=VARCHAR}, + + + #{refzpoint,jdbcType=CHAR}, + + + + + + update irrbdgate_refdata + + + REFSTCD = #{refstcd,jdbcType=CHAR}, + + + REFQPOINT = #{refqpoint,jdbcType=VARCHAR}, + + + REFZPOINT = #{refzpoint,jdbcType=CHAR}, + + + where STROBE_CODE = #{strobeCode,jdbcType=CHAR} + + + + + + + delete from irrbdgate_refdata + where STROBE_CODE = #{strobeCode,jdbcType=CHAR} + + + \ No newline at end of file diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.java new file mode 100644 index 0000000..f9e4e4f --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.baseinfo.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.baseinfo.entity.StRsrBsin; +import org.apache.ibatis.annotations.Param; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; +import java.util.Map; + +public interface StRsrBsinMapper extends UserDataScopeBaseMapper { + + IPage> selectByParam(IPage page, @Param("param") Map param); + List> selectByParam(@Param("param") Map param); +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.xml b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.xml new file mode 100644 index 0000000..4e7a270 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrBsinMapper.xml @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.java new file mode 100644 index 0000000..7d85dae --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.baseinfo.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.baseinfo.entity.StRsrHych; + +public interface StRsrHychMapper extends BaseMapper { +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.xml b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.xml new file mode 100644 index 0000000..7f54849 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/mapper/StRsrHychMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IGateInfoService.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IGateInfoService.java new file mode 100644 index 0000000..cd34d1e --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IGateInfoService.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.baseinfo.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.baseinfo.entity.IrrBDGate; +import com.hnac.hzims.baseinfo.entity.IrrBDGateRefData; + +import java.util.List; + +public interface IGateInfoService extends IService { + boolean addGate(IrrBDGate irrBDGate); + + int updateGate(IrrBDGate irrBDGate); + + IPage selectGate(IrrBDGate irrBDGate, IPage page); + + int addGateRef(IrrBDGateRefData irrBDGateRefdata); + + int deleteGateRef(String gateCode); + + int updateGateRef(IrrBDGateRefData irrBDGateRefdata); + + IrrBDGateRefData detailRef(String gateCode); + List list(IrrBDGate irrBDGate); +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrBsinService.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrBsinService.java new file mode 100644 index 0000000..f818bdc --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrBsinService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.baseinfo.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.baseinfo.entity.StRsrBsin; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; +import java.util.Map; + +public interface IStRsrBsinService extends BaseService { +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrHychService.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrHychService.java new file mode 100644 index 0000000..13a4aea --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/IStRsrHychService.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.baseinfo.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnac.hzims.baseinfo.entity.StRsrHych; + +public interface IStRsrHychService { + + StRsrHych getOne(QueryWrapper wrapper); + +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/GateInfoServiceImpl.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/GateInfoServiceImpl.java new file mode 100644 index 0000000..1557484 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/GateInfoServiceImpl.java @@ -0,0 +1,75 @@ +package com.hnac.hzims.baseinfo.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.baseinfo.entity.IrrBDGate; +import com.hnac.hzims.baseinfo.entity.IrrBDGateRefData; +import com.hnac.hzims.baseinfo.mapper.IrrBDGateMapper; +import com.hnac.hzims.baseinfo.mapper.IrrBDGateRefDataMapper; +import com.hnac.hzims.baseinfo.service.IGateInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class GateInfoServiceImpl extends ServiceImpl implements IGateInfoService { + + @Autowired + IrrBDGateMapper irrBDGateMapper; + + @Autowired + IrrBDGateRefDataMapper irrBDGateRefDataMapper; + + @Override + public boolean addGate(IrrBDGate irrBDGate) { + return this.save(irrBDGate); + } + + @Override + public int updateGate(IrrBDGate irrBDGate) { + //编辑时如果站点更换清除之前数据配置 + IrrBDGate judgeGate = this.getById(irrBDGate.getId()); + this.updateById(irrBDGate); + if (!irrBDGate.getCreateDept().equals(judgeGate.getCreateDept())) { + irrBDGateRefDataMapper.deleteByPrimaryKey(irrBDGate.getStrobeCode()); + } + return 1; + } + + @Override + public IPage selectGate(IrrBDGate irrBDGate, IPage page) { + IPage irrBDGates = irrBDGateMapper.selectByExample(irrBDGate, page); + return irrBDGates; + } + + @Override + public int addGateRef(IrrBDGateRefData irrBDGateRefdata) { + int i = irrBDGateRefDataMapper.insertSelective(irrBDGateRefdata); + return i; + } + + @Override + public int deleteGateRef(String gateCode) { + int i = irrBDGateRefDataMapper.deleteByPrimaryKey(gateCode); + return i; + } + + @Override + public int updateGateRef(IrrBDGateRefData irrBDGateRefdata) { + int i = irrBDGateRefDataMapper.updateByPrimaryKeySelective(irrBDGateRefdata); + return i; + } + + @Override + public IrrBDGateRefData detailRef(String gateCode) { + IrrBDGateRefData res = irrBDGateRefDataMapper.selectByPrimaryKey(gateCode); + return res; + } + + @Override + public List list(IrrBDGate irrBDGate) { + List irrBDGates = irrBDGateMapper.selectByExample(irrBDGate); + return irrBDGates; + } +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrBsinServiceImpl.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrBsinServiceImpl.java new file mode 100644 index 0000000..ab1f707 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrBsinServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.baseinfo.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.baseinfo.entity.StRsrBsin; +import com.hnac.hzims.baseinfo.mapper.StRsrBsinMapper; +import com.hnac.hzims.baseinfo.service.IStRsrBsinService; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class StRsrBsinServiceImpl extends BaseServiceImpl implements IStRsrBsinService { + +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrHychServiceImpl.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrHychServiceImpl.java new file mode 100644 index 0000000..603a75b --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/service/impl/StRsrHychServiceImpl.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.baseinfo.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnac.hzims.baseinfo.entity.StRsrHych; +import com.hnac.hzims.baseinfo.mapper.StRsrHychMapper; +import com.hnac.hzims.baseinfo.service.IStRsrHychService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class StRsrHychServiceImpl implements IStRsrHychService { + + @Resource + StRsrHychMapper stRsrHychMapper; + + + @Override + public StRsrHych getOne(QueryWrapper wrapper) { + return stRsrHychMapper.selectOne(wrapper); + } + +} diff --git a/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/wrapper/StRsrBsinWrapper.java b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/wrapper/StRsrBsinWrapper.java new file mode 100644 index 0000000..c6f3c26 --- /dev/null +++ b/hzims-service/base-info/src/main/java/com/hnac/hzims/baseinfo/wrapper/StRsrBsinWrapper.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.baseinfo.wrapper; + +import com.hnac.hzims.baseinfo.entity.StRsrBsin; +import com.hnac.hzims.baseinfo.vo.StRsrBsinVo; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.system.cache.RegionCache; +import org.springblade.system.entity.Region; + +import java.util.Objects; + +public class StRsrBsinWrapper extends BaseEntityWrapper { + public StRsrBsinWrapper() { + } + + public static StRsrBsinWrapper build() { + return new StRsrBsinWrapper(); + } + + @Override + public StRsrBsinVo entityVO(StRsrBsin entity) { + if(entity == null){ + return null; + } + StRsrBsinVo stRsrBsinVo = Objects.requireNonNull(BeanUtil.copy(entity, StRsrBsinVo.class)); + Region region=RegionCache.getByCode(entity.getAddvcd()); + if(region!=null) { + stRsrBsinVo.setAddvcdnm(region.getName()); + } + return stRsrBsinVo; + } +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmOreanizationController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmOreanizationController.java new file mode 100644 index 0000000..28cb9e5 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmOreanizationController.java @@ -0,0 +1,194 @@ +package com.hnac.hzims.equipment.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.entity.EmTreeNode; +import com.hnac.hzims.equipment.service.IEmInfoService; +import io.swagger.annotations.*; +import lombok.AllArgsConstructor; + +import javax.validation.Valid; + +import org.apache.commons.lang3.StringUtils; +import org.springblade.core.boot.ctrl.BladeController; +import com.hnac.hzims.common.constant.CommonConstant; + +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.node.ForestNodeMerger; +import org.springblade.core.tool.node.INode; +import org.springblade.core.tool.node.TreeNode; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.web.bind.annotation.*; +import com.baomidou.mybatisplus.core.metadata.IPage; +import springfox.documentation.annotations.ApiIgnore; + +import com.hnac.hzims.equipment.entity.EmOreanizationEntity; +import com.hnac.hzims.equipment.vo.EmOreanizationVO; +import com.hnac.hzims.equipment.wrapper.EmOreanizationWrapper; +import com.hnac.hzims.equipment.service.IEmOreanizationService; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * 设备组织控制器 + * + * @author moze + */ +@RestController +@AllArgsConstructor +@RequestMapping("/em/oreanization") +@Api(value = "设备组织结构", tags = "设备组织结构") +public class EmOreanizationController extends BladeController { + + private final IEmOreanizationService em_oreanizationService; + + private final IEmInfoService emInfoService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入ID") + public R detail(@ApiParam(value = "主键", required = true) @RequestParam String id) { + EmOreanizationEntity detail = em_oreanizationService.getById(Func.toLong(id)); + return R.data(detail); + } + + /** + * 加载当前站点设备的组织结构 + */ + /*@GetMapping("/initLoad") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "初始化加载", notes = "加载当前站点设备的组织结构") + public R> init() { + return R.data(em_oreanizationService.initLoad(AuthUtil.getTenantId())); + }*/ + @ApiOperation("获取目录树形结构") + @GetMapping("/initLoad") + public R> getStructTree() { + return em_oreanizationService.groupTree(); + } + + /** + * 新增 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "新增", notes = "传入em_oreanization") + public R save(@Valid @RequestBody EmOreanizationEntity em_oreanization) { + if (StringUtil.isNotBlank(em_oreanization.getPid() + "")) { + List emOreanizationEntities = em_oreanizationService.list(new QueryWrapper() {{ + //eq("PID", em_oreanization.getPid()); + eq("NAME", em_oreanization.getName()); + }}); + if (CollectionUtil.isNotEmpty(emOreanizationEntities)) { + return R.fail("名称已存在!"); + } + } + em_oreanization.setSort(em_oreanizationService.sort(em_oreanization.getPid())); + return R.status(em_oreanizationService.save(em_oreanization)); + } + + + + /** + * 修改 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "修改", notes = "传入em_oreanization") + public R update(@Valid @RequestBody EmOreanizationEntity em_oreanization) { + List list = em_oreanizationService.list(new QueryWrapper() {{ + eq("ID", em_oreanization.getId()); + eq("NAME", em_oreanization.getName()); + }}); + if (CollectionUtil.isEmpty(list)) { + List emOreanizationEntities = em_oreanizationService.list(new QueryWrapper() {{ + eq("PID", em_oreanization.getPid()); + eq("NAME", em_oreanization.getName()); + }}); + if (CollectionUtil.isNotEmpty(emOreanizationEntities)) { + return R.fail("同级名称已存在!"); + } + + } + return R.status(em_oreanizationService.updateOrg(em_oreanization)); + } + + /** + * 备用-新增或修改 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "新增或修改", notes = "传入em_oreanization") + public R submit(@Valid @RequestBody EmOreanizationEntity em_oreanization) { + if (StringUtil.isNotBlank(em_oreanization.getPid() + "")) { + List emOreanizationEntities = em_oreanizationService.list(new QueryWrapper() {{ + eq("NAME", em_oreanization.getName()); + eq("PID", em_oreanization.getPid()); + }}); + if (CollectionUtil.isNotEmpty(emOreanizationEntities)) { + return R.fail("同级名称已存在!"); + } + } + return R.status(em_oreanizationService.saveOrUpdate(em_oreanization)); + } + + + /** + * 删除 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + String[] split = ids.split(","); + for (String id : split) { + List isThere = em_oreanizationService.list(new QueryWrapper() {{ + eq("PID", id); + }}); + if (CollectionUtil.isNotEmpty(isThere)) { + return R.fail("请先删除子组织"); + } + List refOreanization = emInfoService.list(new QueryWrapper() {{ + eq("REF_OREANIZATION", id); + }}); + if (CollectionUtil.isNotEmpty(refOreanization)) { + return R.fail("请先删除设备信息"); + } + + } + return R.status(em_oreanizationService.deleteLogic(Func.toLongList(ids))); + } + + /** + * 下移 + */ + @PostMapping("/down") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "下移", notes = "传入ID") + public R down(@ApiParam(value = "主键", required = true) @RequestParam String id1, @ApiParam(value = "主键", required = true) @RequestParam String id2) { + return R.status(em_oreanizationService.translocation(Func.toLong(id1), Func.toLong(id2))); + } + + /** + * 上移 + */ + @PostMapping("/up") + @ApiOperationSupport(order = 8) + @ApiOperation(value = "上移", notes = "传入ID") + public R up(@ApiParam(value = "主键", required = true) @RequestParam String id1, @ApiParam(value = "主键", required = true) @RequestParam String id2) { + return R.status(em_oreanizationService.translocation(Func.toLong(id1), Func.toLong(id2))); + } + + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.java new file mode 100644 index 0000000..31d9dfd --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.equipment.mapper; + +import org.springblade.core.datascope.annotation.UserDataAuth; +import com.hnac.hzims.equipment.entity.EmOreanizationEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +import org.springblade.core.tool.node.TreeNode; + +import java.util.List; + +/** + * Mapper 接口 + * + * @author Chill + */ +public interface EmOreanizationMapper extends UserDataScopeBaseMapper { + + @UserDataAuth + List selectTreeList(String tenantId); + + int selectMaxSort(Long pid); +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.xml new file mode 100644 index 0000000..4b0865e --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmOreanizationMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_attach.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_attach.sql new file mode 100644 index 0000000..edddd14 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_attach.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563307857514502', 0, 'equipment', 'em_attach', 'menu', '/equipment/em_attach', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563307857514503', '1369563307857514502', 'em_attach_add', '新增', 'add', '/equipment/em_attach/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563307857514504', '1369563307857514502', 'em_attach_edit', '修改', 'edit', '/equipment/em_attach/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563307857514505', '1369563307857514502', 'em_attach_delete', '删除', 'delete', '/api/equipment/em_attach/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563307857514506', '1369563307857514502', 'em_attach_view', '查看', 'view', '/equipment/em_attach/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_info.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_info.sql new file mode 100644 index 0000000..4342899 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_info.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306376925191', 0, 'equipment', 'em_info', 'menu', '/equipment/em_info', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306376925192', '1369563306376925191', 'em_info_add', '新增', 'add', '/equipment/em_info/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306376925193', '1369563306376925191', 'em_info_edit', '修改', 'edit', '/equipment/em_info/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306376925194', '1369563306376925191', 'em_info_delete', '删除', 'delete', '/api/equipment/em_info/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306376925195', '1369563306376925191', 'em_info_view', '查看', 'view', '/equipment/em_info/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model.sql new file mode 100644 index 0000000..657afd2 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369816257129451526', 0, 'equipment', 'em_model', 'menu', '/equipment/em_model', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369816257129451527', '1369816257129451526', 'em_model_add', '新增', 'add', '/equipment/em_model/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369816257129451528', '1369816257129451526', 'em_model_edit', '修改', 'edit', '/equipment/em_model/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369816257129451529', '1369816257129451526', 'em_model_delete', '删除', 'delete', '/api/equipment/em_model/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369816257129451530', '1369816257129451526', 'em_model_view', '查看', 'view', '/equipment/em_model/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model_param.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model_param.sql new file mode 100644 index 0000000..8748279 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_model_param.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563308268556289', 0, 'equipment', 'em_model_param', 'menu', '/equipment/em_model_param', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563308268556290', '1369563308268556289', 'em_model_param_add', '新增', 'add', '/equipment/em_model_param/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563308268556291', '1369563308268556289', 'em_model_param_edit', '修改', 'edit', '/equipment/em_model_param/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563308268556292', '1369563308268556289', 'em_model_param_delete', '删除', 'delete', '/api/equipment/em_model_param/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563308268556293', '1369563308268556289', 'em_model_param_view', '查看', 'view', '/equipment/em_model_param/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_oreanization.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_oreanization.sql new file mode 100644 index 0000000..ca77bda --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_oreanization.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563305466761217', 0, 'equipment', 'em_oreanization', 'menu', '/equipment/em_oreanization', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563305466761218', '1369563305466761217', 'em_oreanization_add', '新增', 'add', '/equipment/em_oreanization/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563305466761219', '1369563305466761217', 'em_oreanization_edit', '修改', 'edit', '/equipment/em_oreanization/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563305466761220', '1369563305466761217', 'em_oreanization_delete', '删除', 'delete', '/api/equipment/em_oreanization/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563305466761221', '1369563305466761217', 'em_oreanization_view', '查看', 'view', '/equipment/em_oreanization/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_param.sql b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_param.sql new file mode 100644 index 0000000..4bcfd1a --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/em_param.sql @@ -0,0 +1,10 @@ +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306804744193', 0, 'equipment', 'em_param', 'menu', '/equipment/em_param', NULL, 1, 1, 0, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306804744194', '1369563306804744193', 'em_param_add', '新增', 'add', '/equipment/em_param/add', 'plus', 1, 2, 1, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306804744195', '1369563306804744193', 'em_param_edit', '修改', 'edit', '/equipment/em_param/edit', 'form', 2, 2, 2, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306804744196', '1369563306804744193', 'em_param_delete', '删除', 'delete', '/api/equipment/em_param/remove', 'delete', 3, 2, 3, 1, NULL, 0); +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) +VALUES ('1369563306804744197', '1369563306804744193', 'em_param_view', '查看', 'view', '/equipment/em_param/view', 'file-text', 4, 2, 2, 1, NULL, 0); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmOreanizationService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmOreanizationService.java new file mode 100644 index 0000000..1d7d458 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmOreanizationService.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.equipment.service; + +import com.hnac.hzims.equipment.entity.EmTreeNode; +import com.hnac.hzims.equipment.vo.EmOreanizationVO; +import org.springblade.core.mp.base.BaseService; +import com.hnac.hzims.equipment.entity.EmOreanizationEntity; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.node.INode; +import org.springblade.core.tool.node.TreeNode; + +import javax.validation.Valid; +import java.util.List; + +/** + * 服务类 + * + * @author moze + */ +public interface IEmOreanizationService extends BaseService { + + List initLoad(String tenantId); + + boolean translocation(long id1, long id2); + + boolean updateOrg(@Valid EmOreanizationEntity em_oreanization); + + boolean saveOrg(@Valid EmOreanizationEntity em_oreanization); + + R> groupTree(); + + Integer sort(Long id); +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmOreanizationServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmOreanizationServiceImpl.java new file mode 100644 index 0000000..45f9291 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmOreanizationServiceImpl.java @@ -0,0 +1,162 @@ +package com.hnac.hzims.equipment.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnac.hzims.equipment.entity.EmTreeNode; +import org.springblade.core.mp.base.BaseServiceImpl; +import com.hnac.hzims.equipment.entity.EmOreanizationEntity; +import com.hnac.hzims.equipment.mapper.EmOreanizationMapper; +import com.hnac.hzims.equipment.service.IEmOreanizationService; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.node.ForestNodeMerger; +import org.springblade.core.tool.node.TreeNode; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * 服务实现类 + * + * @author Chill + */ +@Service +public class EmOreanizationServiceImpl extends BaseServiceImpl implements IEmOreanizationService { + + @Autowired + private EmOreanizationMapper oreanizationMapper; + @Override + public List initLoad(String tenantId) { + List treeList = oreanizationMapper.selectTreeList(tenantId); + return ForestNodeMerger.merge(treeList); + } + + @Override + public boolean translocation(long id1, long id2) { + EmOreanizationEntity org1 = this.getById(id1); + EmOreanizationEntity org2 = this.getById(id2); + boolean flag = false; + if(Func.isNotEmpty(org1) && Func.isNotEmpty(org2)){ + Integer sort = org1.getSort(); + org1.setSort(org2.getSort()); + org2.setSort(sort); + List rows = new ArrayList(); + rows.add(org1); + rows.add(org2); + flag = this.updateBatchById(rows); + }else { + flag = false; + } + return flag; + } + + @Override + public boolean updateOrg(@Valid EmOreanizationEntity em_oreanization) { + EmOreanizationEntity temp = this.getById(em_oreanization.getId()); + // 处理序号问题 + if(Func.isNotEmpty(temp) + && temp.getPid() != null + && em_oreanization.getPid() != null + && temp.getPid().longValue() != em_oreanization.getPid().longValue()){ + int maxSort = oreanizationMapper.selectMaxSort(em_oreanization.getPid()) + 1; + em_oreanization.setSort(maxSort); + return this.updateById(em_oreanization); + }else { + return this.updateById(em_oreanization); + } + } + + @Override + public boolean saveOrg(EmOreanizationEntity em_oreanization) { + + int maxSort = oreanizationMapper.selectMaxSort(em_oreanization.getPid()) + 1; + em_oreanization.setSort(maxSort); + int cnt = oreanizationMapper.insert(em_oreanization); + return cnt > 0; + } + + + + + + + @Override + public R> groupTree() { + + QueryWrapper queryWrapper = new QueryWrapper() {{ + eq("PID",0); + }}; + queryWrapper.orderByAsc("PID","SORT"); + //数据库里所有pid为空的为根节点组织 + List structs = oreanizationMapper.selectList(queryWrapper); + //查询所有数据 ListAll + QueryWrapper queryWrapper2 = new QueryWrapper() {{ + }}; + queryWrapper2.orderByAsc("PID","SORT"); + List resultList = oreanizationMapper.selectList(queryWrapper2); + //把组织信息换成节点 + List rootNodes = new ArrayList<>(); + for (EmOreanizationEntity struct : structs) { + EmTreeNode treeNode = new EmTreeNode(); + treeNode.setId(struct.getId()); + treeNode.setParentId(struct.getPid()); + treeNode.setTitle(struct.getName()); + treeNode.setLevel(1); + rootNodes.add(groupToNode(treeNode)); + } + //生成树 + List nodeList = createGroupAndStationTree(resultList, rootNodes); + return R.data(nodeList); + } + + @Override + public Integer sort(Long id) { + return oreanizationMapper.selectMaxSort(id) + 1; + } + + private EmTreeNode groupToNode(EmTreeNode treeNode) { + if (Objects.isNull(treeNode)) { + return null; + } + return treeNode; + } + + public List createGroupAndStationTree(List resultList, List rootNodes) { + if (rootNodes == null || rootNodes.size() < 1) { + return null; + } + //遍历根节点 + for (EmTreeNode rootNode : rootNodes) { + //找到子节点 + List childNodes = listGroupNodeByPid(resultList,rootNode.getId()+"",rootNode.getLevel()); + //如果没有数据了,就跳出循环 + if (childNodes == null || childNodes.size() == 0) { + continue; + } + //遍历子节点 + rootNode.setChildren(createGroupAndStationTree(resultList, childNodes)); + } + return rootNodes; + } + + public List listGroupNodeByPid(List resultList, String id,Integer level){ + List childNodes = new ArrayList<>(); + level = level+1; + for (EmOreanizationEntity struct : resultList) { + EmTreeNode treeNode = new EmTreeNode(); + + if(id.equals(struct.getPid()+"")){ + treeNode.setId(struct.getId()); + treeNode.setParentId(struct.getPid()); + treeNode.setTitle(struct.getName()); + treeNode.setLevel(level); + childNodes.add(treeNode); + } + } + return childNodes; + } +} diff --git a/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/mqtt/MessageFlowWranConsumer.java b/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/mqtt/MessageFlowWranConsumer.java new file mode 100644 index 0000000..0512d60 --- /dev/null +++ b/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/mqtt/MessageFlowWranConsumer.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.message_alarm.mqtt; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.message_alarm.entity.MessageResponseData; +import com.hnac.hzims.message_alarm.strategy.FactoryStrategy; +import com.hnac.hzims.message_alarm.strategy.Strategy; +import lombok.extern.slf4j.Slf4j; +import org.springblade.mqtt.customer.IMqttReceive; +import org.springblade.mqtt.customer.annotation.MqttReceive; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +//告警消费主题 +@Service +@MqttReceive(topicName = "message_alarm_center/handleFlowWarn") +@Slf4j +public class MessageFlowWranConsumer implements IMqttReceive {//消费(flowAlarm)json数据 + + @Autowired + FactoryStrategy factoryForStrategy; + + @Override + public void handlerMessage(String message) { + log.info("收到告警消息: "+message); + //解析消息 发送消息 + MessageResponseData responseData= JSONObject.parseObject(message,MessageResponseData.class); + //获取对应策略 + Strategy strategy=factoryForStrategy.getStrategy(responseData.getBodyType()); + if(strategy!=null) {//执行 + strategy.handleJson(responseData); + } + } +} diff --git a/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/strategy/FlowWarnStrategy.java b/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/strategy/FlowWarnStrategy.java new file mode 100644 index 0000000..d002db3 --- /dev/null +++ b/hzims-service/message-alarm-service/src/main/java/com/hnac/hzims/message_alarm/strategy/FlowWarnStrategy.java @@ -0,0 +1,191 @@ +package com.hnac.hzims.message_alarm.strategy; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.message_alarm.dto.MessageDTO; +import com.hnac.hzims.message_alarm.entity.MessageMonitorObjAttr; +import com.hnac.hzims.message_alarm.entity.MessageResponseData; +import com.hnac.hzims.message_alarm.entity.MessageSendInfo; +import com.hnac.hzims.message_alarm.enums.PushTypeEnum; +import com.hnac.hzims.message_alarm.enums.TemplateTypeEnum; +import com.hnac.hzims.message_alarm.mapper.MessageMonitorObjAttrMapper; +import com.hnac.hzims.message_alarm.service.IMessageStrategyService; +import com.hnac.hzims.message_alarm.util.CheckDataRationalUtil; +import com.hnac.hzims.message_alarm.vo.MessageObjTemplateVo; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.flow.core.entity.BladeFlow; +import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.system.user.entity.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +//告警解析策略 +@Component("flowWarn") +@Slf4j +public class FlowWarnStrategy implements Strategy { + @Autowired + IMessageStrategyService messageStrategyService; + + @Autowired + IFlowClient flowClient; + + @Resource + private MessageMonitorObjAttrMapper messageMonitorObjAttrMapper; + + @Override + public void handleJson(MessageResponseData responseData) { + log.info("入参responseData:{}", responseData); + //可执行模板 + List executableTemplate = null; + + //解析属性列表数据 + List> attrListByObject = CheckDataRationalUtil.parseAttrListByObject(responseData.getData()); + if (attrListByObject == null || attrListByObject.isEmpty()) { + return; + } + + //查找符合条件的模板 + List list = messageStrategyService.queryMessageObjTemplateVo(responseData.getSchemeId(), + responseData.getDeviceCode(), TemplateTypeEnum.FLOW_WARN.getCode()); + log.info("告警模板总个数:" + list.size()); + + //筛选出可执行的模板 + if (list != null && !list.isEmpty()) { + executableTemplate = new ArrayList<>(); + + //获取数据中的最高级 + int highLevel = CheckDataRationalUtil.getHighLevel(attrListByObject); + + for (MessageObjTemplateVo vo : list) { + //校验模板与数据属性吻合度 + boolean checkAttr = CheckDataRationalUtil.checkAttr(vo, responseData); + if (!checkAttr) { + continue; + } + //对象有属性的 针对自己的等级评价 + // 对象不包含属性的 已字段中的最高等级评价 + boolean checkObj = CheckDataRationalUtil.checkAlarmObj(vo, attrListByObject, highLevel); + if (!checkObj) {//筛选出可执行的模板 + continue; + } + // 替换模板content + String templateContent = buildContent(responseData.getData(), vo.getTemplateContent()); + vo.setTemplateContent(templateContent); + executableTemplate.add(vo); + } + log.info("告警模板符合个数:" + executableTemplate.size()); + + //发送消息+存储消息 + for (MessageObjTemplateVo vo : executableTemplate) { + //解析模板内容 + String message = CheckDataRationalUtil.parseContent(vo.getTemplateContent(), responseData); + log.info("模板:" + vo.getTemplateTitle() + ",发送告警消息:" + message); + + //组装消息 +// // 造假数据 +// MessageSendInfo info = new MessageSendInfo(); +// HashMap map = new HashMap<>(); +// map.put(1710229795322830849L, "绿色小水电"); +// info.setPerson(map); +// info.setTenantId("20000"); +// info.setObjectSource("111"); +// info.setPhones("13107280912"); +// info.setMessage(message); +// info.setTitle("title"); +// info.setObjectCode("JSCZ001"); +// info.setSchemeId(1769602788549591042L); + MessageSendInfo info = messageStrategyService.getSendMessageInfo(vo, message); + if (info == null) { + continue; + } + //发送消息 + if (PushTypeEnum.SMS.getCode().equals(info.getPushType())) { + // todo 短信配置 +// 高板岩一站 电站生态流量预警:核定流量0.02(m³/s),当前日均流量0.017(m³/s),建议生态流量后续9小时的实时流量值不低于0.054(m³/s) + messageStrategyService.sendFlowWarnMessage(message, info.getPhones()); + } else { +// messageStrategyService.sendInfo(info); + } + + + //启动流程实例 + if (vo.getProcessKey() != null && !"".equals(vo.getProcessKey().trim())) {//I II III IV 启动流程 + Map variables = new HashMap<>(); + variables.put("alarm_msg", message); + + String processInstanceId = null; + if (vo.getAutoStartProcess() != null && vo.getAutoStartProcess().intValue() == 1) {//自动触发 + R bladeFlowR = flowClient.startProcessInstanceByKey(vo.getProcessKey(), "message_alarm_center", variables); + processInstanceId = bladeFlowR.getData().getProcessInstanceId(); + } + //保存信息 + messageStrategyService.saveFlowWarnMessage(info, processInstanceId, vo.getProcessKey(), vo.getAlarmLevel(), JSON.toJSONString(responseData)); + } else {//V无需启动流程 需要相关人员确认一下 + messageStrategyService.saveFlowWarnMessage(info, null, null, vo.getAlarmLevel(), JSON.toJSONString(responseData)); + } + } + } + } + + private final static String JOIN_CODE = "、"; + + /** + * 组装消息模板 + * + * @param templateContent 模板 + * @param responseData 数据 + * @return + */ + private MessageDTO messageMake(String phones, String templateContent, MessageResponseData responseData, List> list) { + MessageDTO messageDto = new MessageDTO(); + messageDto.setStation(responseData.getObjectName()); + messageDto.setTime(responseData.getCreateDate()); + messageDto.setPhone(phones); + Map keyToAttr = messageMonitorObjAttrMapper.selectList(new LambdaQueryWrapper() {{ + eq(MessageMonitorObjAttr::getInstanceCode, responseData.getDeviceCode()); + }}).stream().collect(Collectors.toMap(MessageMonitorObjAttr::getAttrCode, MessageMonitorObjAttr::getAttrName)); + //拼接所有属性key值 + List keyList = CheckDataRationalUtil.getAttrList(templateContent); + //获取对应value值 + StringBuilder valueStr = new StringBuilder(); + StringBuilder keyStr = new StringBuilder(); + for (String key : keyList) { + String tmpKey = key.replaceAll("\\{", "").replaceAll("}", ""); + Object value = CheckDataRationalUtil.getDataByKey(tmpKey, list); + if (value != null) { + keyStr.append(getKeyName(keyToAttr, tmpKey)); + valueStr.append(value.toString()); + valueStr.append(JOIN_CODE); + keyStr.append(JOIN_CODE); + } + } + valueStr.deleteCharAt(valueStr.length() - 1); + keyStr.deleteCharAt(keyStr.length() - 1); + messageDto.setNum(valueStr.toString()); + messageDto.setType(keyStr.toString()); + log.info("messageMake {}", messageDto); + return messageDto; + } + + //获取当前key对应名称 + private String getKeyName(Map objAttr, String key) { + return StringUtils.isEmpty(objAttr.get(key)) ? "-" : objAttr.get(key); + } + + private String buildContent(String data, String templateContent) { + JSONArray array = JSON.parseArray(data); + Map map = JSON.parseObject(array.get(0).toString(), Map.class); + return map.get("suggest").toString(); + } +} diff --git a/hzims-service/safeproduct/README.md b/hzims-service/safeproduct/README.md new file mode 100644 index 0000000..56d6e40 --- /dev/null +++ b/hzims-service/safeproduct/README.md @@ -0,0 +1,9 @@ +## 部署说明 +* 視頻監控告警 模块需要跳过token权限校验,视频识别模块python不调用登录 +* 視頻監控告警 模块的minio图片链接需要设置文件夹为public。例: +``` +# 使用minio client +mc policy set public minio/ims-monitor +``` + +