whycrzg
2021-05-18 318fa133a638ba7a2695d8c4d2907da71204932b
绕组实验
8个文件已添加
620 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/WindingExperimentController.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ExperimentWindingStep1Mapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ExperimentWindingStep2Mapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ExperimentWindingStep1.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ExperimentWindingStep2.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/WindingExperimentService.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExperimentWindingStep1Mapper.xml 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExperimentWindingStep2Mapper.xml 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/WindingExperimentController.java
New file
@@ -0,0 +1,59 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.Experiment;
import com.whyc.pojo.ExperimentWindingStep1;
import com.whyc.pojo.ExperimentWindingStep2;
import com.whyc.pojo.Project;
import com.whyc.service.WindingExperimentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("windingExperiment")
@Api(tags = "绕组试验")
public class WindingExperimentController {
    /**
     * 绕组试验
     * winding
     * 电流 电压
     * Current
     * 电阻
     *
     * 温度
     */
    @Autowired
    private WindingExperimentService service;
    @GetMapping("getProjectName")
    @ApiOperation(value = "获取实验项目名")
    public Response<List<Project>> getProjectName(){
        return service.getProjectName();
    }
    @PostMapping("")
    @ApiOperation(value = "开始实验")
    public Response addWindingExperiment(@RequestBody Experiment experiment){
        return service.addWindingExperiment(experiment);
    }
    @PostMapping("addWindingStep1")
    @ApiOperation(value = "实验步骤1")
    public Response addExperimentWindingStep1(@RequestBody ExperimentWindingStep1 windingStep1){
        return service.addExperimentWindingStep1(windingStep1);
    }
    @PostMapping("addWindingStep2")
    @ApiOperation(value = "实验步骤2")
    public Response addExperimentWindingStep2(@RequestBody ExperimentWindingStep2 windingStep2){
        return service.addExperimentWindingStep2(windingStep2);
    }
}
src/main/java/com/whyc/mapper/ExperimentWindingStep1Mapper.java
New file
@@ -0,0 +1,18 @@
package com.whyc.mapper;
import com.whyc.pojo.ExperimentWindingStep1;
public interface ExperimentWindingStep1Mapper {
    int deleteByPrimaryKey(Integer id);
    int insert(ExperimentWindingStep1 record);
    int insertSelective(ExperimentWindingStep1 record);
    ExperimentWindingStep1 selectByPrimaryKey(Integer id);
    int updateByPrimaryKeySelective(ExperimentWindingStep1 record);
    int updateByPrimaryKey(ExperimentWindingStep1 record);
}
src/main/java/com/whyc/mapper/ExperimentWindingStep2Mapper.java
New file
@@ -0,0 +1,18 @@
package com.whyc.mapper;
import com.whyc.pojo.ExperimentWindingStep2;
public interface ExperimentWindingStep2Mapper {
    int deleteByPrimaryKey(Integer id);
    int insert(ExperimentWindingStep2 record);
    int insertSelective(ExperimentWindingStep2 record);
    ExperimentWindingStep2 selectByPrimaryKey(Integer id);
    int updateByPrimaryKeySelective(ExperimentWindingStep2 record);
    int updateByPrimaryKey(ExperimentWindingStep2 record);
}
src/main/java/com/whyc/pojo/ExperimentWindingStep1.java
New file
@@ -0,0 +1,59 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.apache.ibatis.type.Alias;
import java.io.Serializable;
import java.util.Date;
/**
 * tb_experiment_winding_step1
 * @author
 */
@Alias("ExperimentWindingStep1")
@ApiModel
@TableName(schema = "`db_3.5mw_web`" , value = "`tb_experiment_winding_step1`")
public class ExperimentWindingStep1 implements Serializable {
    private Integer id;
    /**
     * 绕组编号 测绕组引线(多个);测各相绕组引线(单个)
     */
    private String winding;
    /**
     * 电流(μA)
     */
    private Float electricCurrent;
    /**
     * 电压(V)
     */
    private Float vol;
    /**
     * 绝缘电阻
     */
    private Float resistance;
    private Float temperature;
    private Date saveTime;
    /**
     * 试验编号(ID)
     */
    private String experimentId;
    /**
     * 状态:0-未开始,1-进行中,2-已完成
     */
    private Boolean status;
    private String note;
    private static final long serialVersionUID = 1L;
}
src/main/java/com/whyc/pojo/ExperimentWindingStep2.java
New file
@@ -0,0 +1,59 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.apache.ibatis.type.Alias;
import java.io.Serializable;
import java.util.Date;
/**
 * tb_experiment_winding_step2
 * @author
 */
@Alias("ExperimentWindingStep2")
@ApiModel
@TableName(schema = "`db_3.5mw_web`" , value = "`tb_experiment_winding_step2`")
public class ExperimentWindingStep2 implements Serializable {
    private Integer id;
    /**
     * 绕组编号 测绕组引线(多个);测各相绕组引线(单个)
     */
    private String winding;
    /**
     * 电流(mA)
     */
    private Float electricCurrent;
    /**
     * 电压(V)
     */
    private Float vol;
    /**
     * 直流电阻
     */
    private Float resistance;
    private Float temperature;
    private Date saveTime;
    /**
     * 试验编号(ID)
     */
    private String experimentId;
    /**
     * 状态:0-未开始,1-进行中,2-已完成
     */
    private Boolean status;
    private String note;
    private static final long serialVersionUID = 1L;
}
src/main/java/com/whyc/service/WindingExperimentService.java
New file
@@ -0,0 +1,107 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.ExperimentMapper;
import com.whyc.mapper.ExperimentWindingStep1Mapper;
import com.whyc.mapper.ExperimentWindingStep2Mapper;
import com.whyc.mapper.ProjectMapper;
import com.whyc.pojo.Experiment;
import com.whyc.pojo.ExperimentWindingStep1;
import com.whyc.pojo.ExperimentWindingStep2;
import com.whyc.pojo.Project;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class WindingExperimentService {
    @Resource
    private ExperimentMapper mapper;
    @Resource
    private ExperimentWindingStep1Mapper mapper1;
    @Resource
    private ExperimentWindingStep2Mapper mapper2;
    @Resource
    private ProjectMapper projectMapper;
    /**
     * 绕组实验 开始实验
     * @param experiment
     * @return
     */
    public Response<Object> addWindingExperiment(Experiment experiment) {
        experiment.setCreateTime(new Date());
        experiment.setStatus(0);
        try {
            if (mapper.insert(experiment) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
    }
    /**
     * 绕组实验步骤1
     * @param windingStep1
     * @return
     */
    public Response<Object> addExperimentWindingStep1(ExperimentWindingStep1 windingStep1) {
        try {
            if (mapper1.insert(windingStep1) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
    }
    /**
     * 绕组实验步骤2
     * @param windingStep2
     * @return
     */
    public Response<Object> addExperimentWindingStep2(ExperimentWindingStep2 windingStep2) {
        try {
            if (mapper2.insert(windingStep2) > 0) {
                return new Response().setMsg(1, "添加成功");
            } else {
                return new Response().setMsg(0, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().setMsg(0, "添加失败");
        }
    }
    public Response<List<Project>> getProjectName() {
        QueryWrapper<Project> wrapper = new QueryWrapper<>();
        ArrayList<Object> arr = new ArrayList<>();
        arr.add(1); //项目状态:0-已取消,1-进行中,2-完成,3-延期
        arr.add(3);
        wrapper.in("status", arr);
        List<Project> list = projectMapper.selectList(wrapper);
        Response<List<Project>> response = new Response<>();
        response.set(1, list);
        return response;
    }
}
src/main/resources/mapper/ExperimentWindingStep1Mapper.xml
New file
@@ -0,0 +1,153 @@
<?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.ExperimentWindingStep1Mapper">
  <resultMap id="BaseResultMap" type="com.whyc.pojo.ExperimentWindingStep1">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="winding" jdbcType="VARCHAR" property="winding" />
    <result column="electric_current" jdbcType="FLOAT" property="electricCurrent" />
    <result column="vol" jdbcType="FLOAT" property="vol" />
    <result column="resistance" jdbcType="FLOAT" property="resistance" />
    <result column="temperature" jdbcType="FLOAT" property="temperature" />
    <result column="save_time" jdbcType="TIMESTAMP" property="saveTime" />
    <result column="experiment_id" jdbcType="VARCHAR" property="experimentId" />
    <result column="status" jdbcType="BOOLEAN" property="status" />
    <result column="note" jdbcType="VARCHAR" property="note" />
  </resultMap>
  <sql id="Base_Column_List">
    id, winding, electric_current, vol, resistance, temperature, save_time, experiment_id,
    `status`, note
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from tb_experiment_winding_step1
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_experiment_winding_step1
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.whyc.pojo.ExperimentWindingStep1">
    insert into tb_experiment_winding_step1 (id, winding, electric_current,
      vol, resistance, temperature,
      save_time, experiment_id, `status`,
      note)
    values (#{id,jdbcType=INTEGER}, #{winding,jdbcType=VARCHAR}, #{electricCurrent,jdbcType=FLOAT},
      #{vol,jdbcType=FLOAT}, #{resistance,jdbcType=FLOAT}, #{temperature,jdbcType=FLOAT},
      #{saveTime,jdbcType=TIMESTAMP}, #{experimentId,jdbcType=VARCHAR}, #{status,jdbcType=BOOLEAN},
      #{note,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.whyc.pojo.ExperimentWindingStep1">
    insert into tb_experiment_winding_step1
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="winding != null">
        winding,
      </if>
      <if test="electricCurrent != null">
        electric_current,
      </if>
      <if test="vol != null">
        vol,
      </if>
      <if test="resistance != null">
        resistance,
      </if>
      <if test="temperature != null">
        temperature,
      </if>
      <if test="saveTime != null">
        save_time,
      </if>
      <if test="experimentId != null">
        experiment_id,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="note != null">
        note,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="winding != null">
        #{winding,jdbcType=VARCHAR},
      </if>
      <if test="electricCurrent != null">
        #{electricCurrent,jdbcType=FLOAT},
      </if>
      <if test="vol != null">
        #{vol,jdbcType=FLOAT},
      </if>
      <if test="resistance != null">
        #{resistance,jdbcType=FLOAT},
      </if>
      <if test="temperature != null">
        #{temperature,jdbcType=FLOAT},
      </if>
      <if test="saveTime != null">
        #{saveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="experimentId != null">
        #{experimentId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=BOOLEAN},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.whyc.pojo.ExperimentWindingStep1">
    update tb_experiment_winding_step1
    <set>
      <if test="winding != null">
        winding = #{winding,jdbcType=VARCHAR},
      </if>
      <if test="electricCurrent != null">
        electric_current = #{electricCurrent,jdbcType=FLOAT},
      </if>
      <if test="vol != null">
        vol = #{vol,jdbcType=FLOAT},
      </if>
      <if test="resistance != null">
        resistance = #{resistance,jdbcType=FLOAT},
      </if>
      <if test="temperature != null">
        temperature = #{temperature,jdbcType=FLOAT},
      </if>
      <if test="saveTime != null">
        save_time = #{saveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="experimentId != null">
        experiment_id = #{experimentId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=BOOLEAN},
      </if>
      <if test="note != null">
        note = #{note,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.whyc.pojo.ExperimentWindingStep1">
    update tb_experiment_winding_step1
    set winding = #{winding,jdbcType=VARCHAR},
      electric_current = #{electricCurrent,jdbcType=FLOAT},
      vol = #{vol,jdbcType=FLOAT},
      resistance = #{resistance,jdbcType=FLOAT},
      temperature = #{temperature,jdbcType=FLOAT},
      save_time = #{saveTime,jdbcType=TIMESTAMP},
      experiment_id = #{experimentId,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=BOOLEAN},
      note = #{note,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
src/main/resources/mapper/ExperimentWindingStep2Mapper.xml
New file
@@ -0,0 +1,147 @@
<?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.ExperimentWindingStep2Mapper">
  <resultMap id="BaseResultMap" type="com.whyc.pojo.ExperimentWindingStep2">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="winding" jdbcType="VARCHAR" property="winding" />
    <result column="electric_current" jdbcType="FLOAT" property="electricCurrent" />
    <result column="vol" jdbcType="FLOAT" property="vol" />
    <result column="resistance" jdbcType="FLOAT" property="resistance" />
    <result column="temperature" jdbcType="FLOAT" property="temperature" />
    <result column="save_time" jdbcType="TIMESTAMP" property="saveTime" />
    <result column="experiment_id" jdbcType="VARCHAR" property="experimentId" />
    <result column="status" jdbcType="BOOLEAN" property="status" />
    <result column="note" jdbcType="VARCHAR" property="note" />
  </resultMap>
  <sql id="Base_Column_List">
    id, winding, electric_current, vol, resistance, temperature, save_time, experiment_id,
    `status`, note
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from tb_experiment_winding_step2
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_experiment_winding_step2
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.whyc.pojo.ExperimentWindingStep2" useGeneratedKeys="true">
    insert into tb_experiment_winding_step2 (winding, electric_current, vol,
      resistance, temperature, save_time,
      experiment_id, `status`, note
      )
    values (#{winding,jdbcType=VARCHAR}, #{electricCurrent,jdbcType=FLOAT}, #{vol,jdbcType=FLOAT},
      #{resistance,jdbcType=FLOAT}, #{temperature,jdbcType=FLOAT}, #{saveTime,jdbcType=TIMESTAMP},
      #{experimentId,jdbcType=VARCHAR}, #{status,jdbcType=BOOLEAN}, #{note,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.whyc.pojo.ExperimentWindingStep2" useGeneratedKeys="true">
    insert into tb_experiment_winding_step2
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="winding != null">
        winding,
      </if>
      <if test="electricCurrent != null">
        electric_current,
      </if>
      <if test="vol != null">
        vol,
      </if>
      <if test="resistance != null">
        resistance,
      </if>
      <if test="temperature != null">
        temperature,
      </if>
      <if test="saveTime != null">
        save_time,
      </if>
      <if test="experimentId != null">
        experiment_id,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="note != null">
        note,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="winding != null">
        #{winding,jdbcType=VARCHAR},
      </if>
      <if test="electricCurrent != null">
        #{electricCurrent,jdbcType=FLOAT},
      </if>
      <if test="vol != null">
        #{vol,jdbcType=FLOAT},
      </if>
      <if test="resistance != null">
        #{resistance,jdbcType=FLOAT},
      </if>
      <if test="temperature != null">
        #{temperature,jdbcType=FLOAT},
      </if>
      <if test="saveTime != null">
        #{saveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="experimentId != null">
        #{experimentId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=BOOLEAN},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.whyc.pojo.ExperimentWindingStep2">
    update tb_experiment_winding_step2
    <set>
      <if test="winding != null">
        winding = #{winding,jdbcType=VARCHAR},
      </if>
      <if test="electricCurrent != null">
        electric_current = #{electricCurrent,jdbcType=FLOAT},
      </if>
      <if test="vol != null">
        vol = #{vol,jdbcType=FLOAT},
      </if>
      <if test="resistance != null">
        resistance = #{resistance,jdbcType=FLOAT},
      </if>
      <if test="temperature != null">
        temperature = #{temperature,jdbcType=FLOAT},
      </if>
      <if test="saveTime != null">
        save_time = #{saveTime,jdbcType=TIMESTAMP},
      </if>
      <if test="experimentId != null">
        experiment_id = #{experimentId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=BOOLEAN},
      </if>
      <if test="note != null">
        note = #{note,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.whyc.pojo.ExperimentWindingStep2">
    update tb_experiment_winding_step2
    set winding = #{winding,jdbcType=VARCHAR},
      electric_current = #{electricCurrent,jdbcType=FLOAT},
      vol = #{vol,jdbcType=FLOAT},
      resistance = #{resistance,jdbcType=FLOAT},
      temperature = #{temperature,jdbcType=FLOAT},
      save_time = #{saveTime,jdbcType=TIMESTAMP},
      experiment_id = #{experimentId,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=BOOLEAN},
      note = #{note,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>