#20230506 欣影管理平台杆塔管理功能代码
parent
1b97865905
commit
24ad12e410
@ -0,0 +1,105 @@
|
||||
package com.shxy.xymanager_admin.controller;
|
||||
|
||||
import com.shxy.xymanager_common.annotation.Log;
|
||||
import com.shxy.xymanager_common.base.BaseController;
|
||||
import com.shxy.xymanager_common.base.ResponseReult;
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.bean.ServiceStatus;
|
||||
import com.shxy.xymanager_common.dto.TowerDto;
|
||||
import com.shxy.xymanager_common.model.TowerListModel;
|
||||
import com.shxy.xymanager_common.vo.*;
|
||||
import com.shxy.xymanager_service.service.TowerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Api(value = "杆塔接口", tags = "杆塔接口相关")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class TowerController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
TowerService towerService;
|
||||
|
||||
|
||||
@ApiOperation(value = "新增杆塔", notes = "新增杆塔接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/addTower")
|
||||
@Log(title = "新增杆塔", type = "查询")
|
||||
public ResponseReult<String> addTower(@RequestBody @Validated TowerVo vo) {
|
||||
ServiceBody<String> serviceBody = towerService.addTower(vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取杆塔列表", notes = "获取杆塔列表接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/getTowerList")
|
||||
@Log(title = "获取杆塔列表", type = "查询")
|
||||
public ResponseReult<TowerListModel> getTowerList(@RequestBody @Validated PageVo vo) {
|
||||
ServiceBody<TowerListModel> serviceBody = towerService.getTowerList(vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取杆塔", notes = "获取杆塔列表接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/getTowerInfo")
|
||||
@Log(title = "获取杆塔", type = "查询")
|
||||
public ResponseReult<TowerDto> getTowerInfo(@RequestParam("id")Integer id) {
|
||||
ServiceBody<TowerDto> serviceBody = towerService.getTowerInfo(id);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "删除杆塔", notes = "删除杆塔接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/deleteTower")
|
||||
@Log(title = "删除杆塔", type = "修改")
|
||||
public ResponseReult<String> deleteTower(@RequestBody @Validated TowerIdVo vo) {
|
||||
ServiceBody<String> serviceBody = towerService.deleteTower(vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改杆塔", notes = "修改杆塔接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/updateTower")
|
||||
@Log(title = "修改杆塔", type = "修改")
|
||||
public ResponseReult<String> updateTower(@RequestBody @Validated UpdateTowerVo vo) {
|
||||
ServiceBody<String> serviceBody = towerService.updateTower(vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.shxy.xymanager_common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TowerDto implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer lineId;
|
||||
|
||||
private String lineName;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.shxy.xymanager_common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Tower implements Serializable {
|
||||
|
||||
private Integer lineId;
|
||||
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.shxy.xymanager_common.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 杆塔线路列表
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "获取杆塔线路列表", description = "获取杆塔线路列表信息")
|
||||
public class TowerListModel implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "总记录数", example = "120")
|
||||
private long total;
|
||||
@ApiModelProperty(value = "总页数", example = "120")
|
||||
private int totalpage;
|
||||
@ApiModelProperty(value = "当前页", example = "1")
|
||||
private int currentpage;
|
||||
@ApiModelProperty(value = "每页记录数", example = "1")
|
||||
private int pagesize;
|
||||
|
||||
@ApiModelProperty(value = "杆塔线路列表", example = "[]")
|
||||
private List<TowerBean> list;
|
||||
|
||||
@Data
|
||||
public static class TowerBean {
|
||||
|
||||
@ApiModelProperty(value = "杆塔编号", example = "123456")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "杆塔名称", example = "AAAA")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "线路编号", example = "123456")
|
||||
private Integer lineId;
|
||||
|
||||
@ApiModelProperty(value = "线路编号", example = "123456")
|
||||
private String lineName;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.shxy.xymanager_common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "杆塔编号数组", description = "杆塔编号数组描述")
|
||||
public class TowerIdVo {
|
||||
@NotEmpty(message = "不能传入空值")
|
||||
@ApiModelProperty(value = "杆塔编号数组", required = true, example = "A0001")
|
||||
private List<Item> list;
|
||||
|
||||
@Data
|
||||
private static class Item {
|
||||
@ApiModelProperty(value = "线路名称", example = "名称名称")
|
||||
private Integer id;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.shxy.xymanager_common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "杆塔对象", description = "杆塔对象描述")
|
||||
public class TowerVo {
|
||||
|
||||
@NotEmpty(message = "不能传入空值")
|
||||
@ApiModelProperty(value = "杆塔对象数组", required = true, example = "A0001")
|
||||
private List<TowerVo.TowerItem> list;
|
||||
|
||||
@Data
|
||||
public static class TowerItem {
|
||||
@ApiModelProperty(value = "线路编号", example = "123456")
|
||||
@NotBlank(message = "线路编号不能缺少")
|
||||
private Integer lineId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "杆塔名称", example = "12345678")
|
||||
@NotBlank(message = "杆塔名称")
|
||||
private String name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.shxy.xymanager_common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "修改杆塔对象", description = "修改杆塔对象描述")
|
||||
public class UpdateTowerVo {
|
||||
|
||||
@ApiModelProperty(value = "杆塔编号", example = "123456")
|
||||
@NotBlank(message = "杆塔编号不能缺少")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "杆塔名称", example = "名称名称")
|
||||
@NotBlank(message = "杆塔名称不能缺少")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "线路编号", example = "单位")
|
||||
@NotBlank(message = "线路编号不能缺少")
|
||||
private Integer lineId;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.shxy.xymanager_dao.dao;
|
||||
|
||||
import com.shxy.xymanager_common.dto.TowerDto;
|
||||
import com.shxy.xymanager_common.entity.Tower;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface TowerDao {
|
||||
|
||||
int addTower(@Param("list") List<Tower> towerLst, @Param("date")Date date);
|
||||
|
||||
|
||||
List<TowerDto> selectAll(@Param("status") Integer status);
|
||||
|
||||
int deleteById(@Param("list") List<Tower> record, @Param("status") Integer status, @Param("update") Date update);
|
||||
|
||||
int updateByPrimaryKeySelective(@Param("data") Tower record, @Param("update") Date update);
|
||||
|
||||
|
||||
TowerDto getInfoByPrimaryKey(@Param("id") Integer id, @Param("status") Integer status);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?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="com.shxy.xymanager_dao.dao.TowerDao">
|
||||
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.Tower">
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="line_id" jdbcType="INTEGER" property="dyLevelId"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, name, bs_manufacturer, dy_level_id
|
||||
</sql>
|
||||
|
||||
<select id="selectAll" resultType="com.shxy.xymanager_common.dto.TowerDto">
|
||||
select
|
||||
t.id as id,
|
||||
t.name as name,
|
||||
l.id as lineId,
|
||||
l.name as lineName
|
||||
from tower t,
|
||||
`lines` l
|
||||
where t.line_id = l.id and t.status = #{status,jdbcType=INTEGER}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getInfoByPrimaryKey" resultType="com.shxy.xymanager_common.dto.TowerDto">
|
||||
select
|
||||
t.id as id,
|
||||
t.name as name,
|
||||
l.id as lineId,
|
||||
l.name as lineName
|
||||
from tower t,
|
||||
`lines` l
|
||||
where t.line_id = l.id and t.status = #{status,jdbcType=INTEGER} and t.id = #{id,jdbcType=INTEGER}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<insert id="addTower" parameterType="java.util.List">
|
||||
insert into `tower`
|
||||
(name,line_id,create_time,update_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.name},#{item.lineId},#{date},#{date})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="deleteById">
|
||||
update `tower`
|
||||
set status = #{status},
|
||||
update_time = #{update}
|
||||
where id in
|
||||
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.Tower">
|
||||
update `tower`
|
||||
<set>
|
||||
<if test="data.name != null">
|
||||
name = #{data.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="data.lineId != null">
|
||||
line_id = #{data.lineId,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{data.id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,123 @@
|
||||
package com.shxy.xymanager_service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
|
||||
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
|
||||
import com.shxy.xymanager_common.dto.TowerDto;
|
||||
import com.shxy.xymanager_common.entity.Lines;
|
||||
import com.shxy.xymanager_common.entity.TerminalUpload;
|
||||
import com.shxy.xymanager_common.entity.Tower;
|
||||
import com.shxy.xymanager_common.enums.CommonStatus;
|
||||
import com.shxy.xymanager_common.exception.Asserts;
|
||||
import com.shxy.xymanager_common.model.LineListModel;
|
||||
import com.shxy.xymanager_common.model.TerminalApkInfoListModel;
|
||||
import com.shxy.xymanager_common.model.TowerListModel;
|
||||
import com.shxy.xymanager_common.page.PageUtils;
|
||||
import com.shxy.xymanager_common.util.UploadUtils;
|
||||
import com.shxy.xymanager_common.vo.*;
|
||||
import com.shxy.xymanager_dao.dao.TerminalUploadDao;
|
||||
import com.shxy.xymanager_dao.dao.TerminalsDao;
|
||||
import com.shxy.xymanager_dao.dao.TowerDao;
|
||||
import com.shxy.xymanager_service.interaction.Cma;
|
||||
import com.shxy.xymanager_service.service.TowerService;
|
||||
import com.shxy.xymanager_service.service.UploadService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 设备服务实现层
|
||||
*
|
||||
* @author 晶晶
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TowerServiceImpl implements TowerService {
|
||||
|
||||
@Autowired
|
||||
private TowerDao towerDao;
|
||||
|
||||
@Override
|
||||
public ServiceBody addTower(TowerVo vo) {
|
||||
List<Tower> towerLst = BeanUtil.copyToList(vo.getList(), Tower.class, CopyOptions.create().ignoreCase());
|
||||
Date date = new Date();
|
||||
int i = towerDao.addTower(towerLst,date);
|
||||
if (i != 0) {
|
||||
return Asserts.success("录入成功");
|
||||
} else {
|
||||
return Asserts.error("录入失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceBody<TowerListModel> getTowerList(PageVo vo) {
|
||||
TowerListModel model = new TowerListModel();
|
||||
int pageindex = vo.getPageindex();
|
||||
int pagesize = vo.getPagesize();
|
||||
PageUtils.SetPage(pageindex, pagesize);
|
||||
List<TowerDto> list = towerDao.selectAll(CommonStatus.EFFECTIVE.value());
|
||||
boolean empty = CollectionUtil.isEmpty(list);
|
||||
if (empty) {
|
||||
model.setList(new ArrayList<>());
|
||||
} else {
|
||||
List<TowerListModel.TowerBean> beans = BeanUtil.copyToList(list, TowerListModel.TowerBean.class, CopyOptions.create().ignoreCase());
|
||||
model.setList(beans);
|
||||
}
|
||||
PageInfo pageData = PageUtils.getPageData(list);
|
||||
int currentpage = pageData.getPageNum();
|
||||
model.setCurrentpage(currentpage);
|
||||
long total = pageData.getTotal();
|
||||
model.setTotal(total);
|
||||
|
||||
int pageSize = pageData.getPageSize();
|
||||
model.setPagesize(pageSize);
|
||||
int pages = pageData.getPages();
|
||||
model.setTotalpage(pages);
|
||||
|
||||
|
||||
return Asserts.success(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceBody<String> deleteTower(TowerIdVo vo) {
|
||||
List<Tower> lines = BeanUtil.copyToList(vo.getList(), Tower.class);
|
||||
Date date = new Date();
|
||||
int i = towerDao.deleteById(lines, CommonStatus.DELETE.value(), date);
|
||||
if (i != 0) {
|
||||
return Asserts.success("删除成功");
|
||||
} else {
|
||||
return Asserts.error("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceBody<String> updateTower(UpdateTowerVo vo) {
|
||||
Tower tower = new Tower();
|
||||
BeanUtil.copyProperties(vo, tower, true);
|
||||
int i = towerDao.updateByPrimaryKeySelective(tower, new Date());
|
||||
if (i != 0) {
|
||||
return Asserts.success("修改成功");
|
||||
} else {
|
||||
return Asserts.error("修改失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceBody<TowerDto> getTowerInfo(Integer id) {
|
||||
TowerDto dto = towerDao.getInfoByPrimaryKey(id,CommonStatus.EFFECTIVE.value());
|
||||
return Asserts.success(dto);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.shxy.xymanager_service.service;
|
||||
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.dto.TowerDto;
|
||||
import com.shxy.xymanager_common.model.TowerListModel;
|
||||
import com.shxy.xymanager_common.vo.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author CY
|
||||
*/
|
||||
public interface TowerService {
|
||||
|
||||
|
||||
/**
|
||||
* 新增杆塔
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ServiceBody addTower(TowerVo vo);
|
||||
|
||||
/**
|
||||
* 新增杆塔
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ServiceBody<TowerListModel> getTowerList(PageVo vo);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除线路
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
ServiceBody<String> deleteTower(TowerIdVo vo);
|
||||
|
||||
|
||||
/**
|
||||
* 修改线路
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
ServiceBody<String> updateTower(UpdateTowerVo vo);
|
||||
|
||||
/**
|
||||
* 查询杆塔
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ServiceBody<TowerDto> getTowerInfo(Integer id);
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue