New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 区域枚举 |
| | | * |
| | | */ |
| | | @Getter |
| | | public enum AreaDeptEnum { |
| | | ZLJQ("自流井区", "510302", 201), |
| | | GJQ("贡井区", "510303", 202), |
| | | DAQ("大安区", "510304",102), |
| | | YTQ("沿滩区", "510311",211), |
| | | RX("荣县", "510321",203), |
| | | FSX("富顺县", "510322",101), |
| | | GXQ("高新区", "510399",210), |
| | | ; |
| | | |
| | | private final String name; |
| | | |
| | | private final String code; |
| | | |
| | | private final Integer deptId; |
| | | |
| | | AreaDeptEnum(String name, String code,Integer deptId) { |
| | | this.name = name; |
| | | this.code = code; |
| | | this.deptId = deptId; |
| | | } |
| | | } |
New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 重点点位标签 |
| | | * |
| | | */ |
| | | @Getter |
| | | public enum ImportantTagEnum { |
| | | |
| | | Important("important", "重点点位"), |
| | | Normal("normal", "普通点位"), |
| | | ; |
| | | |
| | | @EnumValue // 标明该字段存入数据库 |
| | | @JsonValue // 标明在转JSON时使用该字段,即响应时 |
| | | private final String code; |
| | | |
| | | private final String desc; |
| | | |
| | | ImportantTagEnum(String code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package enumeration.general; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 省厅点位标签 |
| | | * |
| | | */ |
| | | @Getter |
| | | public enum ProvinceTagEnum { |
| | | Province("province", "省厅点位"), |
| | | Normal("normal", "普通点位"), |
| | | ; |
| | | |
| | | @EnumValue // 标明该字段存入数据库 |
| | | @JsonValue // 标明在转JSON时使用该字段,即响应时 |
| | | private final String code; |
| | | |
| | | private final String desc; |
| | | |
| | | ProvinceTagEnum(String code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ycl.platform.base.AbsEntity; |
| | | import enumeration.general.ImportantTagEnum; |
| | | import enumeration.general.ProvinceTagEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @TableField("dept_id") |
| | | private Long deptId; |
| | | |
| | | @TableField("point_tag") |
| | | private String pointTag; |
| | | @ApiModelProperty("重点点位标签") |
| | | @TableField("important_tag") |
| | | private ImportantTagEnum importantTag; |
| | | |
| | | @ApiModelProperty("省厅点位标签") |
| | | @TableField("province_tag") |
| | | private ProvinceTagEnum provinceTag; |
| | | |
| | | @TableField("serial_number") |
| | | private String serialNumber; |
| | |
| | | import com.ycl.system.domain.group.Add; |
| | | import com.ycl.platform.base.AbsForm; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import enumeration.general.ImportantTagEnum; |
| | | import enumeration.general.ProvinceTagEnum; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import org.springframework.beans.BeanUtils; |
| | | import jakarta.validation.constraints.NotBlank; |
| | |
| | | @ApiModelProperty("监管部门") |
| | | private Long deptId; |
| | | |
| | | @NotEmpty(message = "点位标签不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("点位标签") |
| | | private List<String> pointTag; |
| | | |
| | | @ApiModelProperty("省厅点位标签") |
| | | private ProvinceTagEnum provinceTag; |
| | | @ApiModelProperty("重点点位标签") |
| | | private ImportantTagEnum importantTag; |
| | | @ApiModelProperty("运维状态") |
| | | private String status; |
| | | |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import enumeration.general.ImportantTagEnum; |
| | | import enumeration.general.ProvinceTagEnum; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import lombok.Data; |
| | |
| | | private List<Long> deptIds; |
| | | private String deptName; |
| | | |
| | | /** 点位标签 */ |
| | | private String [] pointTags; |
| | | private String pointTagString; |
| | | /** 重点点位标签 */ |
| | | private ImportantTagEnum importantTag; |
| | | /** 省厅点位标签 */ |
| | | private ProvinceTagEnum provinceTag; |
| | | |
| | | public static YwPointVO getVoByEntity(@NonNull YwPoint entity, YwPointVO vo) { |
| | | if(vo == null) { |
| | |
| | | YwPoint entity = baseMapper.selectById(form.getId()); |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | entity.setPointTag(form.getPointTag().stream().collect(Collectors.joining(","))); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | |
| | | public Result page(YwPointQuery query) { |
| | | IPage<YwPointVO> page = PageUtil.getPage(query, YwPointVO.class); |
| | | baseMapper.page(page, query); |
| | | page.getRecords().stream().forEach(point -> { |
| | | if (StringUtils.hasText(point.getPointTagString())) { |
| | | point.setPointTags(point.getPointTagString().split(",")); |
| | | } |
| | | }); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | YwPoint entity = baseMapper.selectById(id); |
| | | Assert.notNull(entity, "记录不存在"); |
| | | YwPointVO vo = YwPointVO.getVoByEntity(entity, null); |
| | | if (StringUtils.hasText(entity.getPointTag())) { |
| | | vo.setPointTags(entity.getPointTag().split(",")); |
| | | } |
| | | if (Objects.nonNull(entity.getDeptId())) { |
| | | vo.setDeptIds(sysDeptMapper.selectParents(entity.getDeptId())); |
| | | } |
| | |
| | | |
| | | import com.alibaba.druid.support.json.JSONUtils; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ycl.platform.domain.entity.TMonitor; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.result.UY.OneMachineFileResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import com.ycl.platform.service.YwPointService; |
| | | import com.ycl.system.entity.SysDictData; |
| | | import com.ycl.system.service.ISysDictDataService; |
| | | import com.ycl.utils.DateUtils; |
| | |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private ISysDictDataService dictDataService; |
| | | @Autowired |
| | | private YwPointService ywPointService; |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | //同步mongodb一机一档到数据库 |
| | | public void synchronize() { |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | List<OneMachineFileResult> oneMachineFileResults = mongoTemplate.find(query, OneMachineFileResult.class); |
| | | //数据库monitor表数据 |
| | | List<String> serialNumberInBase = monitorService.selectTMonitorList(null).stream().map(TMonitorVO::getSerialNumber).collect(Collectors.toList()); |
| | | //准备插入数据库的数据 |
| | | List<TMonitor> monitorList = new ArrayList<>(); |
| | | //新的数据,原数据库中不存在的数据 |
| | | Set<TMonitor> newMonitorList = new HashSet<>(); |
| | | |
| | | //点位数据 |
| | | Map<String, YwPoint> pointMap = ywPointService.list(new QueryWrapper<YwPoint>()).stream().collect(Collectors.toMap(YwPoint::getSerialNumber, Function.identity())); |
| | | //TODO:插入点位表 |
| | | //TODO:解析区域、补充deptId |
| | | List<SysDictData> areaCodeList = new ArrayList<>(); |
| | | //TODO:解析重点点位 |
| | | //重点点位集合字典(解析SXJCJQY字段) |
| | | SysDictData sysDictData = new SysDictData(); |
| | | sysDictData.setDictType("platform_important_site"); |
| | | List<SysDictData> DictDataList = dictDataService.selectDictDataList(sysDictData); |
| | | List<String> importantSite = DictDataList.stream().map(SysDictData::getDictValue).collect(Collectors.toList()); |
| | | |
| | | for (OneMachineFileResult result : oneMachineFileResults) { |
| | | TMonitor monitor = setMonitor(result); |
| | | TMonitor monitor = getMonitor(result); |
| | | YwPoint point = getPoint(result,pointMap,importantSite); |
| | | monitorList.add(monitor); |
| | | //比对筛选出新的数据 |
| | | if(!CollectionUtils.isEmpty(serialNumberInBase) && !serialNumberInBase.contains(result.getSBBM())){ |
| | | newMonitorList.add(monitor); |
| | | } |
| | | } |
| | | //插入数据库 |
| | | if(!CollectionUtils.isEmpty(monitorList)){ |
| | | monitorService.deleteTMonitorById(null); |
| | | monitorService.saveBatch(monitorList); |
| | | } |
| | | //新的数据放入Redis中等待考核指标任务使用 |
| | | redisTemplate.opsForValue().set(RedisConstant.New_Monitor_Set, JSONArray.toJSONString(newMonitorList)); |
| | | |
| | | |
| | | } |
| | | |
| | | private TMonitor setMonitor(OneMachineFileResult result) { |
| | | private YwPoint getPoint(OneMachineFileResult result, Map<String, YwPoint> pointMap,List<String> importantSite) { |
| | | YwPoint ywPoint = new YwPoint(); |
| | | if(pointMap.containsKey(result.getSBBM())){ |
| | | ywPoint = pointMap.get(result.getSBBM()); |
| | | } |
| | | //比对是否是重点点位 |
| | | if(importantSite.contains(result.getSBBM())){ |
| | | |
| | | } |
| | | |
| | | return ywPoint; |
| | | } |
| | | |
| | | private TMonitor getMonitor(OneMachineFileResult result) { |
| | | TMonitor monitor = new TMonitor(); |
| | | monitor.setSerialNumber(result.getSBBM()); |
| | | monitor.setName(result.getSBMC()); |
| | |
| | | <delete id="deleteTMonitorById" parameterType="Long"> |
| | | delete |
| | | from t_monitor |
| | | where id = #{id} |
| | | <where> |
| | | <if test="id !=null"> |
| | | id = #{id} |
| | | </if> |
| | | </where> |
| | | </delete> |
| | | |
| | | <delete id="deleteTMonitorByIds" parameterType="String"> |
| | |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="category" property="category" /> |
| | | <result column="point_tag" property="pointTagString" /> |
| | | <result column="province_tag" property="provinceTag" /> |
| | | <result column="important_tag" property="importantTag" /> |
| | | </resultMap> |
| | | |
| | | <select id="selectData" resultType="com.ycl.platform.base.BaseSelect"> |
| | |
| | | SELECT |
| | | typ.id, |
| | | typ.point_name, |
| | | typ.point_tag, |
| | | typ.start_time, |
| | | typ.end_time, |
| | | typ.unit_id, |
| | |
| | | typ.remark, |
| | | typ.create_time, |
| | | typ.update_time, |
| | | typ.point_tag, |
| | | typ.important_tag, |
| | | typ.province_tag, |
| | | typ.category |
| | | FROM |
| | | t_yw_point typ |
| | |
| | | select * from t_yw_point |
| | | <where> |
| | | <if test="important!=null and important!= '' "> |
| | | and point_tag like concat('%', #{important}, '%') |
| | | and important_tag = #{important} |
| | | </if> |
| | | <if test="province!=null and province!= '' "> |
| | | and point_tag like concat('%', #{province}, '%') |
| | | and province_tag = #{province} |
| | | </if> |
| | | </where> |
| | | </select> |