装置修改

jni
liuguijing 2 years ago
parent 22c948f0ca
commit ac5ae4ad59

@ -6,6 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@ -14,64 +15,56 @@ import java.util.List;
public class UpdateTerminalVo {
@ApiModelProperty(value = "装置编号", example = "123456")
@NotBlank(message = "装置编号不能缺少")
@NotNull(message = "装置编号不能缺少")
private Integer id;
@ApiModelProperty(value = "线路编号", example = "123456")
@NotBlank(message = "线路编号不能缺少")
private Integer lineid;
@ApiModelProperty(value = "杆塔编号", example = "123456")
@NotBlank(message = "杆塔编号不能缺少")
private Integer towerid;
@ApiModelProperty(value = "通道编号", example = "123456")
private List<Integer> channelid;
@ApiModelProperty(value = "sim卡号", example = "123456")
private String sim;
@ApiModelProperty(value = "图像监测装置 ID17 位编码)", example = "12345678")
@NotBlank(message = "图像监测装置不能缺少")
private String cmdid;
@ApiModelProperty(value = "原始 ID各厂家内部识别号", example = "12345678")
@NotBlank(message = "各厂家内部识别号不能缺少")
private Short orgId;
@ApiModelProperty(value = "装置名称", example = "名称名称")
@NotBlank(message = "装置名称不能缺少")
private String equipName;
@ApiModelProperty(value = "显示名", example = "名称名称")
@NotBlank(message = "显示名不能缺少")
private String displayName;
@ApiModelProperty(value = "装置型号", example = "型号型号")
@NotBlank(message = "装置型号不能缺少")
private String model;
@ApiModelProperty(value = "装置基本信息版本号", example = "型号型号")
@NotBlank(message = "装置基本信息版本号不能缺少")
private String essentialInfoVersion;
@ApiModelProperty(value = "是否带云台", example = " 0 不带云台 1带云台")
@NotBlank(message = "是否带云台不能缺少")
private Byte hasPan;
@ApiModelProperty(value = "生产厂家", example = "生产厂家")
@NotBlank(message = "生产厂家不能缺少")
private String bsManufacturer;
@ApiModelProperty(value = "生产日期", example = "2022-06-12")
@NotBlank(message = "生产日期不能缺少")
private Date bsProductionDate;
@ApiModelProperty(value = "出厂编号", example = "123456")
@NotBlank(message = "出厂编号不能缺少")
private String bsIdentifier;
@ApiModelProperty(value = "纬度", example = "21321")
@NotBlank(message = "纬度不能缺少")
private Double latitude;
@ApiModelProperty(value = "经度", example = "213")
@NotBlank(message = "经度不能缺少")
private Double longitude;
}

@ -8,7 +8,7 @@ import java.util.Date;
import java.util.List;
public interface TerminalChannelMapperDao {
int deleteByPrimaryKey(Integer id);
int deleteByTermId(Integer id);
int insert(TerminalChannelMapper record);

@ -24,9 +24,9 @@
from terminal_channel_mapper
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<delete id="deleteByTermId" parameterType="java.lang.Integer">
delete from terminal_channel_mapper
where id = #{id,jdbcType=INTEGER}
where term_id = #{id}
</delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalChannelMapper">
insert into terminal_channel_mapper (id, term_id, channel_id,

@ -9,7 +9,6 @@ import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
import com.shxy.xymanager_common.entity.TerminalStatus;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
@ -23,17 +22,13 @@ import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
import com.shxy.xymanager_dao.dao.TerminalStatusDao;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_service.interaction.Cma;
import com.shxy.xymanager_service.service.TerminalService;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -60,9 +55,6 @@ public class TerminalServiceImpl implements TerminalService {
@Autowired
private TerminalStatusDao terminalStatusDao;
// @Autowired
// private Cma cma;
/**
*
*
@ -135,9 +127,24 @@ public class TerminalServiceImpl implements TerminalService {
*/
@Override
public ServiceBody<String> updateTerminal(UpdateTerminalVo vo) {
Integer termid = vo.getId();
List<Integer> channelid = vo.getChannelid();
Terminals terminals = new Terminals();
BeanUtil.copyProperties(vo, terminals, true);
int i = terminalsDao.updateByPrimaryKeySelective(terminals, new Date());
terminalChannelMapperDao.deleteByTermId(termid);
if (!CollectionUtil.isEmpty(channelid)) {
List<TerminalChannelMapper> list = new ArrayList<>();
for (Integer id : channelid) {
TerminalChannelMapper record = new TerminalChannelMapper();
record.setChannelId(id);
record.setTermId(termid);
list.add(record);
}
Date date = new Date();
terminalChannelMapperDao.insertList(list, date, date);
}
if (i != 0) {
return Asserts.success("修改成功");
} else {
@ -160,7 +167,6 @@ public class TerminalServiceImpl implements TerminalService {
terminals.setId(item.getTermid());
list.add(terminals);
}
// List<Terminals> list = BeanUtil.copyToList(vo.getList(), Terminals.class);
int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
if (i != 0) {
return Asserts.success("删除成功");
@ -179,13 +185,13 @@ public class TerminalServiceImpl implements TerminalService {
@Override
public ServiceBody<String> resetTerminal(String cmId) {
// Cma cma = new Cma("47.96.238.157", 6891);
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=reset --cmdid=" +cmId +"\t"+"--mode=0";
Integer retCode = ProcessExecUtils.exec(cmd);
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=reset --cmdid=" + cmId + "\t" + "--mode=0";
Integer retCode = ProcessExecUtils.exec(cmd);
// boolean reset = cma.reset(vo.getTermid().toString(), (short) 0x01);
if (retCode ==0) {
if (retCode == 0) {
return Asserts.success("装置复位成功");
} else {
return Asserts.error("装置复位失败");
return Asserts.error("装置复位失败");
}
}
@ -193,11 +199,11 @@ public class TerminalServiceImpl implements TerminalService {
@Override
public ServiceBody<TerminalModel> getTerminalStatus(Integer termId) {
String cmdId = terminalsDao.getCmdIdByTermId(termId);
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --act=runningstatus --cmdid="+cmdId;
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --act=runningstatus --cmdid=" + cmdId;
ProcessExecUtils.exec(cmd);
TerminalModel model = new TerminalModel();
TerminalInfoDto dto = terminalsDao.getTerminalInfo(termId);
if(null!=dto) {
if (null != dto) {
BigInteger updatetime = MyDateUtils.TimeSecond2MillSecond(dto.getWsUpdateTime().longValue());
BeanUtils.copyProperties(dto, model);
DateTime now = DateTime.now();
@ -212,11 +218,11 @@ public class TerminalServiceImpl implements TerminalService {
public ServiceBody<TerminalModel> getLastedTerminalStatus(TerminalStatusVo vo) {
BigInteger wsUpdateTime = terminalsDao.getUpdateTime(vo.getTermId());
BigInteger queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
Boolean hasNew =wsUpdateTime.compareTo(queryTime)<0?false:true;
Boolean hasNew = wsUpdateTime.compareTo(queryTime) < 0 ? false : true;
TerminalModel model = new TerminalModel();
if(hasNew) {
if (hasNew) {
TerminalInfoDto dto = terminalsDao.getTerminalInfo(vo.getTermId());
BeanUtils.copyProperties(dto,model);
BeanUtils.copyProperties(dto, model);
String updateTime = MyDateUtils.TimeSecondToDate(dto.getWsUpdateTime());
model.setWsUpdateTime(updateTime);
return Asserts.success(model);

Loading…
Cancel
Save