diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TowerController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TowerController.java new file mode 100644 index 0000000..51a6c00 --- /dev/null +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TowerController.java @@ -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 addTower(@RequestBody @Validated TowerVo vo) { + ServiceBody 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 getTowerList(@RequestBody @Validated PageVo vo) { + ServiceBody 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 getTowerInfo(@RequestParam("id")Integer id) { + ServiceBody 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 deleteTower(@RequestBody @Validated TowerIdVo vo) { + ServiceBody 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 updateTower(@RequestBody @Validated UpdateTowerVo vo) { + ServiceBody serviceBody = towerService.updateTower(vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + + + + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TowerDto.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TowerDto.java new file mode 100644 index 0000000..3e5b1b2 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TowerDto.java @@ -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; + +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Tower.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Tower.java new file mode 100644 index 0000000..4b79eb6 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/entity/Tower.java @@ -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; + +} \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TowerListModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TowerListModel.java new file mode 100644 index 0000000..53cd6f1 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TowerListModel.java @@ -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 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; + + + + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerIdVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerIdVo.java new file mode 100644 index 0000000..c22d12e --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerIdVo.java @@ -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 list; + + @Data + private static class Item { + @ApiModelProperty(value = "线路名称", example = "名称名称") + private Integer id; + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerVo.java new file mode 100644 index 0000000..aa52c70 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TowerVo.java @@ -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 list; + + @Data + public static class TowerItem { + @ApiModelProperty(value = "线路编号", example = "123456") + @NotBlank(message = "线路编号不能缺少") + private Integer lineId; + + + @ApiModelProperty(value = "杆塔名称", example = "12345678") + @NotBlank(message = "杆塔名称") + private String name; + } + + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/UpdateTowerVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/UpdateTowerVo.java new file mode 100644 index 0000000..f5f8956 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/UpdateTowerVo.java @@ -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; + + + +} diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TowerDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TowerDao.java new file mode 100644 index 0000000..5b8800a --- /dev/null +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TowerDao.java @@ -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 towerLst, @Param("date")Date date); + + + List selectAll(@Param("status") Integer status); + + int deleteById(@Param("list") List 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); +} \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TowerDao.xml b/xymanager_dao/src/main/resources/mappers/TowerDao.xml new file mode 100644 index 0000000..7cbc015 --- /dev/null +++ b/xymanager_dao/src/main/resources/mappers/TowerDao.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + id, name, bs_manufacturer, dy_level_id + + + + + + + + + + insert into `tower` + (name,line_id,create_time,update_time) + VALUES + + (#{item.name},#{item.lineId},#{date},#{date}) + + + + + update `tower` + set status = #{status}, + update_time = #{update} + where id in + + #{item.id} + + + + + update `tower` + + + name = #{data.name,jdbcType=VARCHAR}, + + + line_id = #{data.lineId,jdbcType=INTEGER}, + + + where id = #{data.id} + + + \ No newline at end of file diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TowerServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TowerServiceImpl.java new file mode 100644 index 0000000..55b66d6 --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TowerServiceImpl.java @@ -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 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 getTowerList(PageVo vo) { + TowerListModel model = new TowerListModel(); + int pageindex = vo.getPageindex(); + int pagesize = vo.getPagesize(); + PageUtils.SetPage(pageindex, pagesize); + List list = towerDao.selectAll(CommonStatus.EFFECTIVE.value()); + boolean empty = CollectionUtil.isEmpty(list); + if (empty) { + model.setList(new ArrayList<>()); + } else { + List 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 deleteTower(TowerIdVo vo) { + List 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 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 getTowerInfo(Integer id) { + TowerDto dto = towerDao.getInfoByPrimaryKey(id,CommonStatus.EFFECTIVE.value()); + return Asserts.success(dto); + } +} + diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TowerService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TowerService.java new file mode 100644 index 0000000..9ba38eb --- /dev/null +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TowerService.java @@ -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 getTowerList(PageVo vo); + + + + /** + * 删除线路 + * + * @param vo + * @return + */ + ServiceBody deleteTower(TowerIdVo vo); + + + /** + * 修改线路 + * + * @param vo + * @return + */ + ServiceBody updateTower(UpdateTowerVo vo); + + /** + * 查询杆塔 + * + * @param id + * @return + */ + ServiceBody getTowerInfo(Integer id); + + +}