whyczh
2021-03-25 da9bb5ab7c3efac4e0cb65fe6aebe7b5cc4cfbf4
Merge branch 'master' of http://118.89.139.230:10101/r/~whycxzp/lab
11个文件已添加
6个文件已修改
441 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/DeviceInfController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceManageController.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/DeviceInfDTO.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/Response.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/SystemInfDTO.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DeviceInfMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DeviceManageMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceInf.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceManage.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceParam.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DynamicLoadStateRt.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/Electric2MWState.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ElectricState.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceInfService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceManageService.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/config/application.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DeviceInfMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceInfController.java
New file
@@ -0,0 +1,32 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.dto.SystemInfDTO;
import com.whyc.service.DeviceInfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * 设备信息表
 */
@RestController
@RequestMapping("deviceInf")
@Api(tags = "设备信息")
public class DeviceInfController {
    @Autowired
    private DeviceInfService service;
    @GetMapping("all")
    @ApiOperation(value = "查询所有设备信息")
    public Response<List<SystemInfDTO>> getAll(){
        return service.getAll();
    }
}
src/main/java/com/whyc/controller/DeviceManageController.java
New file
@@ -0,0 +1,48 @@
package com.whyc.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceManage;
import com.whyc.service.DeviceManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 设备管理
 */
@RestController
@RequestMapping("deviceManage")
@Api(tags = "设备管理")
public class DeviceManageController {
    @Autowired
    private DeviceManageService service;
    @GetMapping("all")
    @ApiOperation(value = "查询所有-分页")
    public Response<IPage<DeviceManage>> getAll(@RequestParam int pageNum, @RequestParam int pageSize){
        return service.getAll(pageNum,pageSize);
    }
    @PostMapping
    @ApiOperation(value="添加-入库")
    public Response add(@RequestBody DeviceManage deviceManage){
        return service.add(deviceManage);
    }
    @PutMapping("delete")
    @ApiOperation(value="报废-出库")
    public Response delete(@RequestParam Integer deviceId){
        return service.delete(deviceId);
    }
    @PutMapping
    @ApiOperation(value = "编辑")
    public Response update(@RequestBody DeviceManage deviceManage){
        return service.update(deviceManage);
    }
}
src/main/java/com/whyc/dto/DeviceInfDTO.java
New file
@@ -0,0 +1,84 @@
package com.whyc.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.type.Alias;
import java.util.Date;
@Alias("Device")
public class DeviceInfDTO {
    private Integer  num;
    private Integer  deviceId          ; //设备id
    private String   deviceName        ; //设备名称
    private String   deviceIp          ; //设备ip
    private Integer  maintCycle    ; //维护周期
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
    private Date useStartTime      ; //开始使用时间
    private Integer  userId            ; //录入用户
    private String   note;
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(Integer deviceId) {
        this.deviceId = deviceId;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public String getDeviceIp() {
        return deviceIp;
    }
    public void setDeviceIp(String deviceIp) {
        this.deviceIp = deviceIp;
    }
    public Integer getMaintCycle() {
        return maintCycle;
    }
    public void setMaintCycle(Integer maintCycle) {
        this.maintCycle = maintCycle;
    }
    public Date getUseStartTime() {
        return useStartTime;
    }
    public void setUseStartTime(Date useStartTime) {
        this.useStartTime = useStartTime;
    }
    public Integer getUserId() {
        return userId;
    }
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    public String getNote() {
        return note;
    }
    public void setNote(String note) {
        this.note = note;
    }
}
src/main/java/com/whyc/dto/Response.java
@@ -46,6 +46,12 @@
        return this;
    }
    public Response<T> setMsg(Integer code,String msg) {
        this.code = code;
        this.msg = msg;
        return this;
    }
    public Integer getCode() {
        return code;
    }
src/main/java/com/whyc/dto/SystemInfDTO.java
New file
@@ -0,0 +1,36 @@
package com.whyc.dto;
import org.apache.ibatis.type.Alias;
import java.util.List;
@Alias("SystemInfDTO")
public class SystemInfDTO {
    private Integer systemId;
    private String systemName;
    private List<DeviceInfDTO> devices;
    public Integer getSystemId() {
        return systemId;
    }
    public void setSystemId(Integer systemId) {
        this.systemId = systemId;
    }
    public String getSystemName() {
        return systemName;
    }
    public void setSystemName(String systemName) {
        this.systemName = systemName;
    }
    public List<DeviceInfDTO> getDevices() {
        return devices;
    }
    public void setDevices(List<DeviceInfDTO> devices) {
        this.devices = devices;
    }
}
src/main/java/com/whyc/mapper/DeviceInfMapper.java
New file
@@ -0,0 +1,10 @@
package com.whyc.mapper;
import com.whyc.dto.SystemInfDTO;
import com.whyc.pojo.DeviceInf;
import java.util.List;
public interface DeviceInfMapper extends CustomMapper<DeviceInf> {
    List<SystemInfDTO> getAll();
}
src/main/java/com/whyc/mapper/DeviceManageMapper.java
New file
@@ -0,0 +1,6 @@
package com.whyc.mapper;
import com.whyc.pojo.DeviceManage;
public interface DeviceManageMapper extends CustomMapper<DeviceManage>{
}
src/main/java/com/whyc/pojo/DeviceInf.java
@@ -1,10 +1,15 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
import java.util.Date;
/**
 * 设备信息
 */
@Alias("DeviceInf")
@TableName(schema = "db_experiment",value = "tb_device_inf")
public class DeviceInf {
    private Long     num;
src/main/java/com/whyc/pojo/DeviceManage.java
New file
@@ -0,0 +1,52 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
/**
 * 设备管理
 */
@Alias("DeviceManage")
@TableName(schema = "db_experiment",value = "tb_device_manage")
public class DeviceManage {
    @TableId
    private Integer num;
    private Integer deviceId;
    private String deviceName;
    /**设备状态:新增时设备状态为1(入库),报废时设备状态为0(出库)*/
    private Byte status;
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(Integer deviceId) {
        this.deviceId = deviceId;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public Byte getStatus() {
        return status;
    }
    public void setStatus(Byte status) {
        this.status = status;
    }
}
src/main/java/com/whyc/pojo/DeviceParam.java
New file
@@ -0,0 +1,42 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
/**
 * 某种类型设备参数配置表
 */
@Alias("DeviceParam")
@TableName(schema = "db_experiment",value = "tb_device_param")
public class DeviceParam {
    private Integer num;
    /**设备类型:暂定根据device_inf表deviceId首位数字匹配*/
    private Byte deviceType;
    /**预设,后续更新*/
    private Float param1;
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Byte getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(Byte deviceType) {
        this.deviceType = deviceType;
    }
    public Float getParam1() {
        return param1;
    }
    public void setParam1(Float param1) {
        this.param1 = param1;
    }
}
src/main/java/com/whyc/pojo/DynamicLoadStateRt.java
@@ -1,10 +1,15 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
import java.util.Date;
/**
 * 动态负载状态实时
 */
@Alias("DynamicLoadStateRt")
@TableName(schema = "db_experiment",value = "tb_dynamicload_state_rt")
public class DynamicLoadStateRt {
    Integer       num                ; //主键
src/main/java/com/whyc/pojo/Electric2MWState.java
@@ -1,14 +1,19 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
import java.util.Date;
/**
 * TODO:电子2mw状态
 */
@Alias("Electric2MWState")
@TableName(schema = "db_experiment",value = "tb_electric2mw_state")
public class Electric2MWState {
    Long         num;
    Integer            electric2KWId;
    Long           num;
    Integer        electric2KWId;
    Date           recordTime;
    Float          branchDCVol             ; // 分直流电压
    Float          branchDCCurr            ; // 分直流电流
src/main/java/com/whyc/pojo/ElectricState.java
@@ -1,10 +1,15 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.ibatis.type.Alias;
import java.util.Date;
/**
 * TODO:电子设备状态
 */
@Alias("ElectricState")
@TableName(schema = "db_experiment",value = "tb_electric_state")
public class ElectricState {
    Long          num                         ; //主键
src/main/java/com/whyc/service/DeviceInfService.java
New file
@@ -0,0 +1,26 @@
package com.whyc.service;
import com.whyc.dto.Response;
import com.whyc.dto.SystemInfDTO;
import com.whyc.mapper.DeviceInfMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class DeviceInfService {
    @Resource
    private DeviceInfMapper mapper;
    public Response<List<SystemInfDTO>> getAll() {
        /*QueryWrapper<DeviceInf> query = Wrappers.query();
        query.select("system_id","system_name","GROUP_concat(device_id,\"-\",device_name) as deviceName").groupBy("system_id");
        List<DeviceInf> deviceInfs = mapper.selectList(query);*/
        List<SystemInfDTO> systemList = mapper.getAll();
        System.out.println(System.getProperty("user.timezone"));
        return new Response<List<SystemInfDTO>>().set(1,systemList);
    }
}
src/main/java/com/whyc/service/DeviceManageService.java
New file
@@ -0,0 +1,48 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whyc.dto.Response;
import com.whyc.mapper.DeviceManageMapper;
import com.whyc.pojo.DeviceManage;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class DeviceManageService {
    @Resource
    private DeviceManageMapper mapper;
    public Response add(DeviceManage deviceManage) {
        //新增入库
        deviceManage.setStatus((byte) 1);
        mapper.insert(deviceManage);
        return new Response().setMsg(1,"添加成功");
    }
    public Response delete(Integer deviceId) {
        //逻辑删除,更改状态为0
        UpdateWrapper<DeviceManage> wrapper = Wrappers.update();
        wrapper.set("status",0).eq("device_id",deviceId);
        int update = mapper.update(null, wrapper);
        return new Response().setMsg(1,"出库报废成功");
    }
    public Response update(DeviceManage deviceManage) {
        mapper.updateById(deviceManage);
        return new Response().setMsg(1,"修改成功");
    }
    public Response<IPage<DeviceManage>> getAll(int pageNum,int pageSize) {
        QueryWrapper<DeviceManage> wrapper = Wrappers.query();
        wrapper.eq("status",1);
        IPage<DeviceManage> page1 = mapper.selectPage(new Page<>(pageNum,pageSize), wrapper);
        return new Response<IPage<DeviceManage>>().set(1,page1);
    }
}
src/main/resources/config/application.yml
@@ -12,8 +12,8 @@
#    url: jdbc:mysql://localhost:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
    url: jdbc:mysql://192.168.10.221:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
#    url: jdbc:mysql://192.168.10.221:3360?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
#    url: jdbc:mysql://192.168.10.222:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
#    url: jdbc:mysql://118.89.139.230:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
#    url: jdbc:mysql://192.168.10.222:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
#    url: jdbc:mysql://118.89.139.230:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
    username: root
    password: lmx8688139
    maxIdel: 60
@@ -21,7 +21,7 @@
    minPoolSize: 2
    maxPoolSize: 500
mybatis-plus:
  typeAliasesPackage: com.whyc.pojo
  typeAliasesPackage: com.whyc.pojo,com.whyc.dto
  mapper-locations: classpath:mapper/**/*Mapper.xml
  global-config:
    db-config:
src/main/resources/mapper/DeviceInfMapper.xml
New file
@@ -0,0 +1,21 @@
<?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.whyc.mapper.DeviceInfMapper" >
    <resultMap id="SystemResultMap" type="SystemInfDTO">
        <result column="system_id" property="systemId" />
        <result column="system_name" property="systemName" />
        <collection property="devices" ofType="Device">
            <id column="num" property="num"/>
            <result column="device_id" property="deviceId"/>
            <result column="device_name" property="deviceName"/>
            <result column="maint_cycle" property="maintCycle"/>
            <result column="use_starttime" property="useStartTime"/>
            <result column="user_id" property="userId"/>
        </collection>
    </resultMap>
    <select id="getAll" resultMap="SystemResultMap">
        select * from db_experiment.tb_device_inf
    </select>
</mapper>