feat: 增加导入装置

dev
huangfeng 1 year ago
parent 0fc6f0490c
commit af12d19fcc

@ -8,6 +8,7 @@ import com.shxy.xymanager_common.excel.TerminalExcel;
import com.shxy.xymanager_common.exception.ApiException; import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.model.PhotoDayModel; import com.shxy.xymanager_common.model.PhotoDayModel;
import com.shxy.xymanager_common.model.TerminalGpsModel; import com.shxy.xymanager_common.model.TerminalGpsModel;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.util.EasyExcelUtil; import com.shxy.xymanager_common.util.EasyExcelUtil;
import com.shxy.xymanager_common.vo.TerminalSelectVo; import com.shxy.xymanager_common.vo.TerminalSelectVo;
import com.shxy.xymanager_dao.dao.TerminalPositionsDao; import com.shxy.xymanager_dao.dao.TerminalPositionsDao;
@ -54,6 +55,13 @@ public class TerminalExtController extends BaseController {
TerminalExtService terminalExtService; TerminalExtService terminalExtService;
@PostMapping("importTerminal")
@ApiOperation("导入装置")
public ResponseReult<String> importTerminal(@Validated @RequestBody UploadModel model) throws Exception {
terminalExtService.importTerminal(model);
return ResponseReult.success("OK");
}
@PostMapping("updateComment") @PostMapping("updateComment")
@ApiOperation("修改备注") @ApiOperation("修改备注")
public ResponseReult<String> updateComment(@RequestBody MntnStatus model) throws Exception { public ResponseReult<String> updateComment(@RequestBody MntnStatus model) throws Exception {

@ -128,4 +128,13 @@ public class Terminals implements Serializable {
} }
} }
public void makeDefaultValue(){
this.setStatus(CommonStatus.EFFECTIVE.value());
this.setOnlineStatus(0);
this.setSn("1");
this.setBsManufacturer("上海欣影");
this.setNetType(1);
this.setDevType("1");
}
} }

@ -0,0 +1,19 @@
package com.shxy.xymanager_common.model;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class UploadModel {
@NotNull(message = "lineId不能为空")
private Integer lineId;
@NotNull(message = "protocol不能为空")
private Integer protocol;
@NotNull(message = "cmdidList不能为空")
private List<String> cmdidList;
@NotNull(message = "channelCount不能为空")
private Integer channelCount;
}

@ -6,17 +6,12 @@ import com.shxy.xymanager_common.bean.PermissionDetail;
import com.shxy.xymanager_common.entity.*; import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.enums.CommonStatus; import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.ApiException; import com.shxy.xymanager_common.exception.ApiException;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils; import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
import com.shxy.xymanager_common.vo.TerminalSelectVo; import com.shxy.xymanager_common.vo.TerminalSelectVo;
import com.shxy.xymanager_dao.dao.MntnRawReportsMapper; import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_dao.dao.MntnStatusMapper; import com.shxy.xymanager_service.service.*;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_dao.dao.View_Dy_Line_Tower_TerminalsDao;
import com.shxy.xymanager_service.service.ActivitiesService;
import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TerminalExtService;
import com.shxy.xymanager_service.service.UserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,6 +32,8 @@ public class TerminalExtServiceImpl implements TerminalExtService {
@Resource @Resource
TerminalsDao terminalsDao; TerminalsDao terminalsDao;
@Resource @Resource
TowerDao towerDao;
@Resource
ActivitiesService activitiesService; ActivitiesService activitiesService;
@Resource @Resource
UserService userService; UserService userService;
@ -48,6 +45,10 @@ public class TerminalExtServiceImpl implements TerminalExtService {
MntnRawReportsMapper rawReportsMapper; MntnRawReportsMapper rawReportsMapper;
@Resource @Resource
CacheService cacheService; CacheService cacheService;
@Resource
NewCacheService newCacheService;
@Resource
TerminalChannelMapperDao channelMapperDao;
@Override @Override
@ -219,4 +220,46 @@ public class TerminalExtServiceImpl implements TerminalExtService {
} }
return new PageInfo<>(list); return new PageInfo<>(list);
} }
@Override
public void importTerminal(UploadModel model) {
Lines line = newCacheService.getLine(model.getLineId());
if (line == null) {
throw new ApiException("未找到该线路");
}
Protocols protocol = cacheService.getProtocolMap().get(model.getProtocol());
if (protocol == null) {
throw new ApiException("未找到该规约");
}
Date now = new Date();
for (String cmdid : model.getCmdidList()) {
Towers tower = new Towers();
tower.setName(cmdid);
tower.setLineid(line.getId());
tower.setStatus(CommonStatus.EFFECTIVE.value());
tower.setCreateTime(now);
tower.setUpdateTime(now);
towerDao.insert(tower);
Terminals term = new Terminals();
term.makeDefaultValue();
term.setCmdid(cmdid);
term.setLineId(line.getId());
term.setTowerId(tower.getId());
term.setProtocol(model.getProtocol());
term.setDisplayName(cmdid);
term.setCreateTime(now);
term.setUpdateTime(now);
terminalsDao.insert(term);
for (int i = 1; i <= model.getChannelCount(); i++) {
TerminalChannelMapper channel = new TerminalChannelMapper();
channel.setTermId(term.getId());
channel.setChannelId(i);
channel.setCreateTime(now);
channel.setUpdateTime(now);
channelMapperDao.insertSelective(channel);
}
}
}
} }

@ -2,6 +2,7 @@ package com.shxy.xymanager_service.service;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.entity.*; import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.model.UploadModel;
import com.shxy.xymanager_common.vo.*; import com.shxy.xymanager_common.vo.*;
import java.util.List; import java.util.List;
@ -18,4 +19,6 @@ public interface TerminalExtService {
void updateComment(MntnStatus model); void updateComment(MntnStatus model);
PageInfo<MntnRawReports> listReport(Integer termId, Integer pageNum, Integer pageSize); PageInfo<MntnRawReports> listReport(Integer termId, Integer pageNum, Integer pageSize);
void importTerminal(UploadModel model);
} }

Loading…
Cancel
Save