Commit 668f0290 authored by duanruiming's avatar duanruiming

[add] 诱导屏文字编辑功能新增

parent f2520cc0
package net.wanji.opt.controller.induce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.ValidationGroups;
import net.wanji.opt.entity.InduceFontHist;
import net.wanji.opt.service.induce.InduceFontHistService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* @author duanruiming
* @date 2025/01/21 14:37
*/
@Api(value = "InduceFontHistController", description = "诱导屏-文字下发历史信息")
@RestController
@RequestMapping("/induceFontHist")
@Slf4j
public class InduceFontHistController {
@Resource
private InduceFontHistService induceFontHistService;
@ApiOperation(value = "获取所有诱导文字下发记录", notes = "获取所有诱导文字下发记录",
response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON)
@GetMapping(value = "/byAll", produces = MediaType.APPLICATION_JSON)
public JsonViewObject getAll() {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
List<InduceFontHist> list = induceFontHistService.getAll();
jsonViewObject.success(list);
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(value = "诱导屏文字编辑新增修改", notes = "诱导屏文字编辑新增修改",
response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON)
@PostMapping(value = "/editor", produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON)
public JsonViewObject editor(@ApiParam(value = "查询条件", required = true)
@RequestBody @Validated({ValidationGroups.Query.class})
InduceFontHist induceFontHist) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
induceFontHistService.editor(induceFontHist);
jsonViewObject.success("编辑成功");
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("POST_FAILED_MSG"));
log.error("{} editor error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(value = "通过编号获取诱导屏最新文字", notes = "通过编号获取诱导屏最新文字",
response = JsonViewObject.class, produces = MediaType.APPLICATION_JSON)
@GetMapping(value = "/byLastOne", produces = MediaType.APPLICATION_JSON)
public JsonViewObject getLastOne(@RequestParam("equipCode") String equipCode) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
InduceFontHist induceFontHist = induceFontHistService.getLastOne(equipCode);
jsonViewObject.success(induceFontHist);
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} byLastOne error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
}
package net.wanji.opt.dao.mapper.induce;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.InduceFontHist;
/**
* @author duanruiming
* @date 2025/01/21 14:40
*/
public interface InduceFontHistMapper extends BaseMapper<InduceFontHist> {
}
package net.wanji.opt.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author duanruiming
* @date 2025/01/21 14:29
*/
@Data
@TableName("t_induce_font_hist_log")
public class InduceFontHist {
@ApiModelProperty(value = "唯一ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "诱导屏编码")
@TableField("equip_code")
private String equipCode;
@ApiModelProperty(value = "文字大小")
@TableField("font_size")
private String fontSize;
@ApiModelProperty(value = "文字颜色")
@TableField("font_color")
private String fontColor;
@ApiModelProperty(value = "字体行间距")
@TableField("line_spacing")
private String lineSpacing;
@ApiModelProperty(value = "文字内容")
@TableField("content")
private String content;
@ApiModelProperty(value = "绿波编号")
@TableField("green_id")
private Integer greenId;
@ApiModelProperty(value = "创建时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("gmt_create")
private Date gmtCreate;
@ApiModelProperty(value = "修改时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("gmt_modified")
private Date gmtModified;
}
package net.wanji.opt.service.induce;
import net.wanji.opt.entity.InduceFontHist;
import java.util.List;
/**
* @author duanruiming
* @date 2025/01/21 14:38
*/
public interface InduceFontHistService {
/**
* 获取诱导屏所有文字下发记录
* @return
*/
List<InduceFontHist> getAll();
/**
* 诱导屏文字编辑
* @param induceFontHist
*/
void editor(InduceFontHist induceFontHist);
/**
* 通过诱导屏编码获取最新编辑文字
* @param equipCode
* @return
*/
InduceFontHist getLastOne(String equipCode);
}
package net.wanji.opt.service.induce.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.opt.dao.mapper.induce.InduceFontHistMapper;
import net.wanji.opt.entity.InduceFontHist;
import net.wanji.opt.service.induce.InduceFontHistService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @author duanruiming
* @date 2025/01/21 14:39
*/
@Service
@Slf4j
public class InduceFontHistServiceImpl implements InduceFontHistService {
@Resource
private InduceFontHistMapper induceFontHistMapper;
@Override
public List<InduceFontHist> getAll() {
List<InduceFontHist> induceFontHists = induceFontHistMapper.selectList(new LambdaQueryWrapper<InduceFontHist>());
return induceFontHists;
}
@Override
public void editor(InduceFontHist induceFontHist) {
if (Objects.nonNull(induceFontHist)) {
Long id = induceFontHist.getId();
if (Objects.isNull(id)) {
induceFontHistMapper.insert(induceFontHist);
} else {
induceFontHist.setGmtModified(new Date());
induceFontHistMapper.updateById(induceFontHist);
}
}
}
@Override
public InduceFontHist getLastOne(String equipCode) {
if (StringUtils.isNotBlank(equipCode)) {
LambdaQueryWrapper<InduceFontHist> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InduceFontHist::getEquipCode, equipCode);
queryWrapper.orderByDesc(InduceFontHist::getGmtModified);
queryWrapper.last("limit 1");
InduceFontHist induceFontHist = induceFontHistMapper.selectOne(queryWrapper);
return induceFontHist;
}
return null;
}
}
......@@ -29,6 +29,7 @@ import net.wanji.opt.synthesis.pojo.vo.*;
import net.wanji.opt.synthesis.service.PushStrategyControlService;
import net.wanji.opt.synthesis.service.StrategyControlService;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -184,21 +185,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if (Objects.isNull(groupType)) {
groupType = 1;
}
// LocalDateTime localDateTime = Objects.equals(0, groupType) ? DateUtil.getPlusHour(-1) : DateUtil.getMidNight();
LocalDateTime localDateTime = null;
switch (groupType) {
case 0:
localDateTime = DateUtil.getPlusHour(-1);
break;
case 1:
localDateTime = DateUtil.getMidNight();
break;
case 2:
localDateTime = DateUtil.getPlusSecond(-5);
break;
default:
localDateTime = DateUtil.getMidNight();
}
LocalDateTime localDateTime = getLocalDateTime(groupType);
// 查询干线和路口
if (Objects.isNull(strategyType)) {
......@@ -220,6 +207,25 @@ public class StrategyControlServiceImpl implements StrategyControlService {
return JsonViewObject.newInstance().success(sorted);
}
@NotNull
private static LocalDateTime getLocalDateTime(Integer groupType) {
LocalDateTime localDateTime = null;
switch (groupType) {
case 0:
localDateTime = DateUtil.getPlusHour(-1);
break;
case 1:
localDateTime = DateUtil.getMidNight();
break;
case 2:
localDateTime = DateUtil.getPlusSecond(-5);
break;
default:
localDateTime = DateUtil.getMidNight();
}
return localDateTime;
}
private void setCrossOptHist(List<StrategyControlHistVO> results, LocalDateTime midnight, Integer resultType) {
LambdaQueryWrapper<StrategyCrossResultEntity> queryWrapper = new LambdaQueryWrapper<>();
if (Objects.nonNull(midnight)) {
......
<?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="net.wanji.opt.dao.mapper.induce.InduceFontHistMapper">
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment