fix:1.探测器页面bug修复2.Web模块页面bug修复

This commit is contained in:
nieziyan 2024-01-10 20:15:42 +08:00
parent e4b802ce95
commit 4e2313945a
8 changed files with 66 additions and 67 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@Data
@ -22,14 +23,14 @@ public class GardsDetectors implements Serializable {
* 探测器id
*/
@TableId(value = "DETECTOR_ID")
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
@NotNull(message = "The detector id cannot be empty", groups = {InsertGroup.class, UpdateGroup.class})
private Integer detectorId;
/**
* 探测器编码
*/
@TableField(value = "DETECTOR_CODE")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
@NotBlank(message = "The detector code cannot be empty", groups = {InsertGroup.class, UpdateGroup.class})
private String detectorCode;
/**
@ -100,7 +101,6 @@ public class GardsDetectors implements Serializable {
* 操作时间
*/
@TableField(value = "MODDATE")
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date moddate;
@ -110,5 +110,4 @@ public class GardsDetectors implements Serializable {
*/
@TableField(value = "STATION_ID")
private Integer stationId;
}

View File

@ -0,0 +1,12 @@
package org.jeecg.modules.base.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum DetectorStatus {
ON("Operating"), OFF("Unoperating");
private final String value;
}

View File

@ -71,4 +71,8 @@ public class GardsDetectorsController {
return gardsDetectorsService.findStationDetectors(stationIds);
}
@GetMapping("duplicateCheck")
public Result<?> duplicateCheck(String field, String value){
return gardsDetectorsService.duplicateCheck(field, value);
}
}

View File

@ -22,6 +22,4 @@ public interface GardsDetectorsMapper extends BaseMapper<GardsDetectorsSystem> {
* @return
*/
List<String> findType();
List<GardsDetectorsSystem> list(Integer stationId, String status);
}

View File

@ -23,30 +23,19 @@
CONFIGURATION.GARDS_DETECTORS
<where>
<if test="gardsDetectors.detectorCode != '' and gardsDetectors.detectorCode != null">
and DETECTOR_CODE like CONCAT('%',#{gardsDetectors.detectorCode},'%')
DETECTOR_CODE LIKE CONCAT(CONCAT('%', #{gardsDetectors.detectorCode}), '%')
</if>
<if test="gardsDetectors.type != '' and gardsDetectors.type != null">
and TYPE = #{gardsDetectors.type}
AND TYPE = #{gardsDetectors.type}
</if>
<if test="gardsDetectors.status != '' and gardsDetectors.status != null">
and RTRIM(STATUS, ' ') = #{gardsDetectors.status}
AND RTRIM(STATUS, ' ') = #{gardsDetectors.status}
</if>
</where>
order by DETECTOR_ID asc
Order By DETECTOR_ID ASC
</select>
<select id="findType" resultType="java.lang.String">
SELECT DISTINCT TYPE FROM CONFIGURATION.GARDS_DETECTORS
</select>
<select id="list" resultType="org.jeecg.modules.system.entity.GardsDetectorsSystem">
SELECT
*
FROM
CONFIGURATION.GARDS_DETECTORS det
<where>
det.STATION_ID = #{stationId} AND TRIM(det.STATUS) = #{status}
</where>
ORDER BY det.DETECTOR_ID ASC
</select>
</mapper>

View File

@ -36,14 +36,14 @@ public interface IGardsDetectorsService extends IService<GardsDetectorsSystem> {
* @param gardsDetectors
* @return
*/
Result create(GardsDetectorsSystem gardsDetectors);
Result<?> create(GardsDetectorsSystem gardsDetectors);
/**
* 修改监测器信息
* @param gardsDetectors
* @return
*/
Result update(GardsDetectorsSystem gardsDetectors);
Result<?> update(GardsDetectorsSystem gardsDetectors);
/**
* 删除监测器信息
@ -65,4 +65,5 @@ public interface IGardsDetectorsService extends IService<GardsDetectorsSystem> {
*/
Map<String, List<GardsDetectorsSystem>> findStationDetectors(List<String> stationIds);
Result<?> duplicateCheck(String field, String value);
}

View File

@ -17,6 +17,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.Prompt;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.enums.DetectorStatus;
import org.jeecg.modules.system.entity.GardsDetectorsSystem;
import org.jeecg.modules.system.mapper.GardsDetectorsMapper;
import org.jeecg.modules.system.service.IGardsDetectorsService;
@ -31,6 +32,7 @@ import java.util.stream.Collectors;
@Service("gardsDetectorsService")
@DS("ora")
public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper, GardsDetectorsSystem> implements IGardsDetectorsService {
@Autowired
private RedisUtil redisUtil;
@ -76,25 +78,23 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
@Override
public List<String> findType() {
List<String> type = this.baseMapper.findType();
return type;
return this.baseMapper.findType();
}
@Override
@Transactional
public Result<?> create(GardsDetectorsSystem detector) {
Integer detectorId = detector.getDetectorId();
String detectorCode = detector.getDetectorCode();
LambdaQueryWrapper<GardsDetectorsSystem> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsDetectors::getDetectorId, detectorId);
wrapper.or().eq(GardsDetectors::getDetectorCode, detectorCode);
if (CollUtil.isNotEmpty(this.list(wrapper)))
return Result.error("The detector id or code cannot be repeated");
Integer stationId = detector.getStationId();
if (ObjectUtil.isNull(stationId))
return Result.error("Station id of the detector cannot be empty");
return Result.error("Station Id Of The Detector Cannot Be Empty");
// 查询相同台站下所有工作的探测器 按照探测器Id升序排序
List<GardsDetectorsSystem> detectors = this.baseMapper.list(stationId, "Operating");
LambdaQueryWrapper<GardsDetectorsSystem> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsDetectors::getStationId, stationId);
List<GardsDetectorsSystem> detectors = this.list(wrapper);
detectors = detectors.stream()
.filter(item -> StrUtil.equals(StrUtil.trim(item.getStatus()), DetectorStatus.ON.getValue()))
.sorted(Comparator.comparingInt(GardsDetectorsSystem::getDetectorId))
.collect(Collectors.toList());
// 如果相同台站下没有工作探测器
if (CollUtil.isEmpty(detectors)){
boolean success = this.save(detector);
@ -106,7 +106,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
}
// 如果相同台站下有工作探测器 将Id最小的探测器状态置为 Unoperating
GardsDetectorsSystem detectorMin = detectors.get(0);
detectorMin.setStatus("Unoperating");
detectorMin.setStatus(DetectorStatus.OFF.getValue());
detectors = ListUtil.toList(detectorMin, detector);
boolean success = this.saveOrUpdateBatch(detectors);
if (success){
@ -117,41 +117,23 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
}
@Override
public Result update(GardsDetectorsSystem gardsDetectors) {
Result result = new Result();
LambdaQueryWrapper<GardsDetectorsSystem> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsDetectorsSystem::getDetectorId, gardsDetectors.getDetectorId());
GardsDetectorsSystem stations = this.baseMapper.selectOne(wrapper);
if (Objects.isNull(stations)) {
result.error500("The current data does not existModification failure");
return result;
public Result<?> update(GardsDetectorsSystem detector) {
boolean success = this.updateById(detector);
if (success){
this.findDetectors();
return Result.OK(Prompt.UPDATE_SUCC);
}
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectorsSystem> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectorsSystem::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectorsSystem detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) {
result.error500("Current data "+gardsDetectors.getDetectorCode()+" Already existModification failure");
return result;
}
}
LambdaQueryWrapper<GardsDetectorsSystem> detectorsQueryWrapper = new LambdaQueryWrapper<>();
detectorsQueryWrapper.eq(GardsDetectorsSystem::getDetectorId, gardsDetectors.getDetectorId());
this.baseMapper.update(gardsDetectors, detectorsQueryWrapper);
result.success("Modified successfully");
this.findDetectors();
return result;
return Result.error(Prompt.UPDATE_ERR);
}
@Override
public Result deleteById(Integer id) {
Result result = new Result();
LambdaQueryWrapper<GardsDetectorsSystem> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectorsSystem::getDetectorId, id);
this.baseMapper.delete(queryWrapper);
result.success("Successfully deleted");
this.findDetectors();
return result;
public Result<?> deleteById(Integer id) {
boolean success = this.removeById(id);
if (success){
this.findDetectors();
return Result.OK(Prompt.DELETE_SUCC);
}
return Result.error(Prompt.DELETE_ERR);
}
@Override
@ -180,4 +162,17 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
return map;
}
@Override
public Result<?> duplicateCheck(String field, String value) {
LambdaQueryWrapper<GardsDetectorsSystem> wrapper = new LambdaQueryWrapper<>();
if (StrUtil.equals(field, "DETECTOR_ID")){
wrapper.eq(GardsDetectors::getDetectorId, value);
return this.list(wrapper).isEmpty() ? Result.OK() : Result.error("Id Cannot Be Repeated");
}else if (StrUtil.equals(field, "DETECTOR_CODE")){
wrapper.eq(GardsDetectors::getDetectorCode, value);
return this.list(wrapper).isEmpty() ? Result.OK() : Result.error("Code Cannot Be Repeated");
}else {
return Result.OK();
}
}
}

View File

@ -73,7 +73,8 @@
INNER JOIN RNMAN.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID
<where>
sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss')
and sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss')
AND sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss')
AND ana.REPORT_PAHT IS NOT NULL
<if test="stationIdList.size ==0 and stationIdList != null">
and sam.STATION_ID in ('')
</if>