Commit f8481957 authored by hanbing's avatar hanbing

系统管理-设备管理-接口管理,枚举替换为返回字符

parent d51d5428
......@@ -12,5 +12,14 @@ public class BasicEnum {
private Integer id;
private String nick;
private String code;
public static String getNickById(Integer id) {
for (ManufacturerEnum value : values()) {
if (value.getId().equals(id)) {
return value.getNick();
}
}
return null;
}
}
}
......@@ -3,6 +3,8 @@ package net.wanji.utc.common.typeenum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Objects;
/**
* @author Kent HAN
* @date 2022/11/24 14:16
......@@ -25,4 +27,13 @@ public enum ManufacturerApiInfoTypeEnum {
}
return null;
}
public static String getMsgByCode(Integer code) {
for (ManufacturerApiInfoTypeEnum value : values()) {
if (Objects.equals(value.getCode(), code)) {
return value.getMsg();
}
}
return null;
}
}
......@@ -11,6 +11,7 @@ import net.wanji.utc.service.systemadmin.ManufacturerApiInfoService;
import net.wanji.utc.vo.systemadmin.DeleteByIntegerIdListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoOutVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -41,11 +42,11 @@ public class ManufacturerApiController {
@ApiResponse(code = 200, message = "OK", response = ManufacturerApiInfoPO.class),
})
public JsonViewObject list(@RequestBody ManufacturerApiInfoListInVO manufacturerApiInfoListInVO) {
PageInfo<ManufacturerApiInfoPO> manufacturerApiInfoPOPageInfo =
PageInfo<ManufacturerApiInfoOutVO> manufacturerApiInfoOutVOPageInfo =
manufacturerApiInfoService.list(manufacturerApiInfoListInVO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(manufacturerApiInfoPOPageInfo);
return jsonViewObject.success(manufacturerApiInfoOutVOPageInfo);
}
@ApiOperation(value = "接口添加或修改", notes = "接口添加或修改", consumes = MediaType.APPLICATION_JSON)
......
......@@ -50,7 +50,7 @@ public class TManufacturerApiInfo implements Serializable {
private Integer type;
/**
* 请求方式:get、post
* 请求方式:GET、POST
*/
@TableField("method")
private String method;
......
......@@ -23,8 +23,8 @@ public class ManufacturerApiInfoPO {
/** 接口类型:1、静态;2、动态;3、控制 */
@ApiModelProperty(value = "接口类型:1、静态;2、动态;3、控制",notes = "")
private Integer type ;
/** 请求方式:get、post */
@ApiModelProperty(value = "请求方式:get、post",notes = "")
/** 请求方式:GET、POST */
@ApiModelProperty(value = "请求方式:GET、POST",notes = "")
private String method ;
/** 接口地址 */
@ApiModelProperty(value = "接口地址",notes = "")
......
......@@ -8,6 +8,7 @@ import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.common.Result;
import net.wanji.utc.common.baseentity.BaseCrossInfo;
import net.wanji.utc.common.commonentity.HttpRequest;
import net.wanji.utc.common.exception.ControlException;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.entity.SignalRunring;
......@@ -26,6 +27,7 @@ import net.wanji.utc.vo.schedulesend.ScheduleSendVO;
import net.wanji.utc.vo.timeplan.Phase;
import net.wanji.utc.vo.timeplan.Ring;
import net.wanji.utc.vo.timeplan.TimePlanVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -43,6 +45,9 @@ import static net.wanji.utc.common.constant.Constants.*;
@Service("hkControlCommandService")
public class HKControlCommandServiceImpl implements ControlCommandService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
@Resource
private HkLightsStatusService hkLightsStatusService;
......@@ -85,6 +90,13 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
}
}
private Map<String, String> getPathMapByApiCode(String apiCode) {
Map<String, String> res = new HashMap<>();
HttpRequest httpRequest = new HttpRequest(BasicEnum.ManufacturerEnum.HK.getCode(), apiCode);
res.put("http://", artemisPath + httpRequest.getUrl());
return res;
}
@Override
public <T> Result<T> scheduleSend(ScheduleSendVO param) throws Exception {
CrossInfoPO crossInfoPo = crossInfoMapper.selectByCode(param.getCode());
......@@ -92,7 +104,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
throw new ControlException(BODY_NOT_MATCH.getResultCode(), "参数错误,信号机ID不正确。");
}
Integer manufacturerId = crossInfoPo.getManufacturerId();
param.setManufacturerAbbr(String.valueOf(manufacturerId));
param.setManufacturerCode(String.valueOf(manufacturerId));
if (manufacturerId.equals(BasicEnum.ManufacturerEnum.HK.getCode())) {
return downloadSchedule(param);
} else {
......@@ -322,7 +334,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
//开启适配服务
for (TimePlanVO timePlanVo : timePlans) {
timePlanVo.setCode(crossInfoPo.getCode());
timePlanVo.setManufacturerAbbr(crossInfoPo.getManufacturerId() + "");
timePlanVo.setManufacturerCode(crossInfoPo.getManufacturerId() + "");
}
Integer manufacturerId = crossInfoPo.getManufacturerId();
if (manufacturerId.equals(BasicEnum.ManufacturerEnum.HK.getCode())) {
......@@ -459,7 +471,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
List<BaseCrossInfo> baseSignals = new ArrayList<>();
BaseCrossInfo baseSignal = new BaseCrossInfo();
baseSignal.setCode(code);
baseSignal.setManufacturerAbbr(BasicEnum.ManufacturerEnum.HK.getAbbr());
baseSignal.setManufacturerCode(BasicEnum.ManufacturerEnum.HK.getCode());
baseSignals.add(baseSignal);
LightsStatusVO lightsStatusVO = hkLightsStatusService.getHkLightsStatus(baseSignals).get(0);
//如果当前模式已经是定周期,就不在执行恢复时间表方案指令
......@@ -495,7 +507,7 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
List<BaseCrossInfo> baseSignals = new ArrayList<>();
BaseCrossInfo baseSignal = new BaseCrossInfo();
baseSignal.setCode(code);
baseSignal.setManufacturerAbbr(BasicEnum.ManufacturerEnum.HK.getAbbr());
baseSignal.setManufacturerCode(BasicEnum.ManufacturerEnum.HK.getCode());
baseSignals.add(baseSignal);
return hkLightsStatusService.getHkLightsStatus(baseSignals);
}
......
......@@ -8,6 +8,6 @@ import java.util.List;
* @author Kent HAN
* @date 2022/11/15 13:18
*/
public interface HkStaticInfoService {
public interface HkCrossInfoService {
List<CrossInfoPO> hkCrossBasicInfo();
}
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.common.commonentity.HttpRequest;
import net.wanji.utc.common.constant.Constants;
......@@ -14,7 +15,7 @@ import net.wanji.utc.mapper.CrossInfoMapper;
import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.CrossInfoPO;
import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.staticinfo.HkStaticInfoService;
import net.wanji.utc.service.staticinfo.HkCrossInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -29,15 +30,14 @@ import java.util.Map;
*/
@Slf4j
@Service
public class HkStaticInfoServiceImpl implements HkStaticInfoService {
@RequiredArgsConstructor
public class HkCrossInfoServiceImpl implements HkCrossInfoService {
@Value("${signal.manufacturer.hk.artemisPath}")
private String artemisPath;
@Autowired
private ArtemisConfig artemisConfig;
@Autowired
private CrossInfoMapper crossInfoMapper;
@Autowired
private ManufacturerInfoMapper manufacturerInfoMapper;
private final ArtemisConfig artemisConfig;
private final CrossInfoMapper crossInfoMapper;
private final ManufacturerInfoMapper manufacturerInfoMapper;
@Override
public List<CrossInfoPO> hkCrossBasicInfo() {
......
package net.wanji.utc.service.staticinfo.impl;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.common.genericentity.ManufacturerRes;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.mapper.CrossInfoMapper;
......@@ -26,9 +27,9 @@ import java.util.Objects;
* @date 2022/11/15 10:32
*/
@Service
@RequiredArgsConstructor
public class StaticInfoServiceImpl implements StaticInfoService {
@Autowired
HkStaticInfoService hkStaticInfoService;
private final HkCrossInfoService hkCrossInfoService;
@Autowired
CrossInfoMapper crossInfoMapper;
@Autowired
......@@ -47,7 +48,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
List<CrossInfoPO> crossInfoPOList = new ArrayList<>();
ManufacturerRes<DetailCrossInfoVO> res = new ManufacturerRes<>();
if (Objects.equals(BasicEnum.ManufacturerEnum.HK.getCode(), outVO.getManufacturerCode())) {
crossInfoPOList = hkStaticInfoService.hkCrossBasicInfo();
crossInfoPOList = hkCrossInfoService.hkCrossBasicInfo();
} else {
// todo 其他厂商
res = othersStaticInfoService.crossBasicInfo(outVO.getManufacturerCode());
......
package net.wanji.utc.service.systemadmin;
import com.github.pagehelper.PageInfo;
import net.wanji.utc.po.ManufacturerApiInfoPO;
import net.wanji.utc.vo.systemadmin.DeleteByIntegerIdListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoOutVO;
/**
* @author Kent HAN
* @date 2022/11/24 13:59
*/
public interface ManufacturerApiInfoService {
PageInfo<ManufacturerApiInfoPO> list(ManufacturerApiInfoListInVO manufacturerApiInfoListInVO);
PageInfo<ManufacturerApiInfoOutVO> list(ManufacturerApiInfoListInVO manufacturerApiInfoListInVO);
void insertOrUpdate(ManufacturerApiInfoInsertOrUpdateInVO inVO);
......
......@@ -2,14 +2,17 @@ package net.wanji.utc.service.systemadmin.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.common.typeenum.ManufacturerApiInfoTypeEnum;
import net.wanji.utc.mapper.ManufacturerApiInfoMapper;
import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.ManufacturerApiInfoPO;
import net.wanji.utc.service.systemadmin.ManufacturerApiInfoService;
import net.wanji.utc.util.PageUtils;
import net.wanji.utc.vo.systemadmin.DeleteByIntegerIdListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoListInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerApiInfoOutVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -28,7 +31,7 @@ public class ManufacturerApiInfoServiceImpl implements ManufacturerApiInfoServic
ManufacturerInfoMapper manufacturerInfoMapper;
@Override
public PageInfo<ManufacturerApiInfoPO> list(ManufacturerApiInfoListInVO manufacturerApiInfoListInVO) {
public PageInfo<ManufacturerApiInfoOutVO> list(ManufacturerApiInfoListInVO manufacturerApiInfoListInVO) {
Integer pageNum = manufacturerApiInfoListInVO.getPageNum();
Integer pageSize = manufacturerApiInfoListInVO.getPageSize();
......@@ -50,8 +53,22 @@ public class ManufacturerApiInfoServiceImpl implements ManufacturerApiInfoServic
List<ManufacturerApiInfoPO> manufacturerApiInfoPOList = manufacturerApiInfoMapper.selectByOptionals(
name, typeCode, manufacturerId);
PageInfo<ManufacturerApiInfoPO> manufacturerApiInfoPOPageInfo = new PageInfo<>(manufacturerApiInfoPOList);
// 转换为VO类型的PageInfo对象
PageInfo<ManufacturerApiInfoOutVO> manufacturerApiInfoOutVOPageInfo =
PageUtils.PageInfo2PageInfoVo(manufacturerApiInfoPOPageInfo);
for (ManufacturerApiInfoPO manufacturerApiInfoPO : manufacturerApiInfoPOList) {
ManufacturerApiInfoOutVO manufacturerApiInfoOutVO = new ManufacturerApiInfoOutVO();
BeanUtils.copyProperties(manufacturerApiInfoPO, manufacturerApiInfoOutVO);
Integer type = manufacturerApiInfoPO.getType();
String apiType = ManufacturerApiInfoTypeEnum.getMsgByCode(type);
manufacturerApiInfoOutVO.setApiType(apiType);
Integer manufacturerId1 = manufacturerApiInfoPO.getManufacturerId();
String manufacturerNick1 = BasicEnum.ManufacturerEnum.getNickById(manufacturerId1);
manufacturerApiInfoOutVO.setManufacturerNick(manufacturerNick1);
manufacturerApiInfoOutVOPageInfo.getList().add(manufacturerApiInfoOutVO);
}
return manufacturerApiInfoPOPageInfo;
return manufacturerApiInfoOutVOPageInfo;
}
@Override
......@@ -60,8 +77,8 @@ public class ManufacturerApiInfoServiceImpl implements ManufacturerApiInfoServic
BeanUtils.copyProperties(inVO, manufacturerApiInfoPO);
String typeStr = inVO.getApiType();
Integer typeCode = ManufacturerApiInfoTypeEnum.getCodeByMsg(typeStr);
String manufacturerName = inVO.getManufacturerName();
Integer manufacturerId = manufacturerInfoMapper.selectIdByNick(manufacturerName);
String manufacturerNick = inVO.getManufacturerNick();
Integer manufacturerId = manufacturerInfoMapper.selectIdByNick(manufacturerNick);
manufacturerApiInfoPO.setType(typeCode);
manufacturerApiInfoPO.setManufacturerId(manufacturerId);
......
......@@ -23,13 +23,13 @@ public class ManufacturerApiInfoInsertOrUpdateInVO {
/** 接口类型 */
@ApiModelProperty(required = true, value = "接口类型",notes = "")
private String apiType ;
/** 请求方式:get、post */
@ApiModelProperty(required = true, value = "请求方式:get、post",notes = "")
/** 请求方式:GET、POST */
@ApiModelProperty(required = true, value = "请求方式:GET、POST",notes = "")
private String method ;
/** 接口地址 */
@ApiModelProperty(required = true, value = "接口地址",notes = "")
private String address ;
/** 厂商ID */
/** 接口厂商 */
@ApiModelProperty(required = true, value = "接口厂商",notes = "")
private String manufacturerName ;
private String manufacturerNick;
}
package net.wanji.utc.vo.systemadmin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/28 17:56
*/
@Data
public class ManufacturerApiInfoOutVO {
/** 接口ID */
@ApiModelProperty(value = "接口ID",notes = "")
private Integer id ;
/** 接口代码 */
@ApiModelProperty(value = "接口代码",notes = "")
private String code ;
/** 接口名称 */
@ApiModelProperty(value = "接口名称",notes = "")
private String name ;
/** 接口类型 */
@ApiModelProperty(value = "接口类型",notes = "")
private String apiType ;
/** 请求方式:GET、POST */
@ApiModelProperty(value = "请求方式:GET、POST",notes = "")
private String method ;
/** 接口地址 */
@ApiModelProperty(value = "接口地址",notes = "")
private String address ;
/** 厂商ID */
@ApiModelProperty(value = "接口厂商",notes = "")
private String manufacturerNick ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
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