add - 多数据源、电检数据记录

master
yinq 1 year ago
parent ab1bfed6b4
commit acb0d08999

@ -72,10 +72,10 @@ spring:
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
url: jdbc:oracle:thin:@175.27.215.92:1521/helowin
username: aucma_scada
password: aucma
# 初始连接数
initialSize: 5
# 最小连接池数量

@ -73,10 +73,10 @@ spring:
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
url: jdbc:oracle:thin:@175.27.215.92:1521/helowin
username: aucma_scada
password: aucma
# 初始连接数
initialSize: 5
# 最小连接池数量

@ -40,11 +40,11 @@ spring:
# redis 配置
redis:
# 地址
host: 175.27.215.92
host: localhost
# 端口默认为6379
port: 6379
# 数据库索引
database: 5
database: 1
# 密码
password: redis@2023
# 连接超时时间
@ -65,16 +65,16 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:oracle:thin:@175.27.215.92:1521/helowin
username: aucma_mes
url: jdbc:oracle:thin:@10.100.72.20:1521/ORCLCDB
username: c##aucma_mes
password: aucma
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
url: jdbc:oracle:thin:@10.100.72.20:1521/ORCLCDB
username: c##aucma_scada
password: aucma
# 初始连接数
initialSize: 5
# 最小连接池数量

@ -0,0 +1,99 @@
package com.aucma.report.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.aucma.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.report.domain.RecordElectricalInspection;
import com.aucma.report.service.IRecordElectricalInspectionService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;
/**
* Controller
*
* @author Yinq
* @date 2023-11-09
*/
@RestController
@RequestMapping("/report/electricalInspection" )
public class RecordElectricalInspectionController extends BaseController {
@Autowired
private IRecordElectricalInspectionService recordElectricalInspectionService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:list')" )
@GetMapping("/list" )
public TableDataInfo list(RecordElectricalInspection recordElectricalInspection) {
startPage();
List<RecordElectricalInspection> list = recordElectricalInspectionService.selectRecordElectricalInspectionList(recordElectricalInspection);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:export')" )
@Log(title = "电检数据记录" , businessType = BusinessType.EXPORT)
@PostMapping("/export" )
public void export(HttpServletResponse response, RecordElectricalInspection recordElectricalInspection) {
List<RecordElectricalInspection> list = recordElectricalInspectionService.selectRecordElectricalInspectionList(recordElectricalInspection);
ExcelUtil<RecordElectricalInspection> util = new ExcelUtil<RecordElectricalInspection>(RecordElectricalInspection. class);
util.exportExcel(response, list, "电检数据记录数据" );
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:query')" )
@GetMapping(value = "/{uuid}" )
public AjaxResult getInfo(@PathVariable("uuid" ) String uuid) {
return success(recordElectricalInspectionService.selectRecordElectricalInspectionByUuid(uuid));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:add')" )
@Log(title = "电检数据记录" , businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody RecordElectricalInspection recordElectricalInspection) {
return toAjax(recordElectricalInspectionService.insertRecordElectricalInspection(recordElectricalInspection));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:edit')" )
@Log(title = "电检数据记录" , businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody RecordElectricalInspection recordElectricalInspection) {
return toAjax(recordElectricalInspectionService.updateRecordElectricalInspection(recordElectricalInspection));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('report:electricalInspection:remove')" )
@Log(title = "电检数据记录" , businessType = BusinessType.DELETE)
@DeleteMapping("/{uuids}" )
public AjaxResult remove(@PathVariable String[] uuids) {
return toAjax(recordElectricalInspectionService.deleteRecordElectricalInspectionByUuids(uuids));
}
}

@ -0,0 +1,131 @@
package com.aucma.report.domain;
import java.util.Date;
import com.aucma.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.aucma.common.core.domain.BaseEntity;
/**
* detail_electricalinspection
*
* @author Yinq
* @date 2023-11-09
*/
public class DetailElectricalinspection extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@Excel(name = "标识")
private String uuid;
/**
*
*/
@Excel(name = "序号")
private Long serialnumber;
/**
*
*/
@Excel(name = "项目名称")
private String projectname;
/**
*
*/
@Excel(name = "测试条件")
private String testcondition;
/**
*
*/
@Excel(name = "测试值")
private String testvalue;
/**
*
*/
@Excel(name = "测试结果")
private String testresult;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date recordtime;
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getUuid() {
return uuid;
}
public void setSerialnumber(Long serialnumber) {
this.serialnumber = serialnumber;
}
public Long getSerialnumber() {
return serialnumber;
}
public void setProjectname(String projectname) {
this.projectname = projectname;
}
public String getProjectname() {
return projectname;
}
public void setTestcondition(String testcondition) {
this.testcondition = testcondition;
}
public String getTestcondition() {
return testcondition;
}
public void setTestvalue(String testvalue) {
this.testvalue = testvalue;
}
public String getTestvalue() {
return testvalue;
}
public void setTestresult(String testresult) {
this.testresult = testresult;
}
public String getTestresult() {
return testresult;
}
public void setRecordtime(Date recordtime) {
this.recordtime = recordtime;
}
public Date getRecordtime() {
return recordtime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("uuid", getUuid())
.append("serialnumber", getSerialnumber())
.append("projectname", getProjectname())
.append("testcondition", getTestcondition())
.append("testvalue", getTestvalue())
.append("testresult", getTestresult())
.append("recordtime", getRecordtime())
.toString();
}
}

@ -0,0 +1,131 @@
package com.aucma.report.domain;
import java.util.List;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.aucma.common.annotation.Excel;
import com.aucma.common.core.domain.BaseEntity;
/**
* record_electricalinspection
*
* @author Yinq
* @date 2023-11-09
*/
public class RecordElectricalInspection extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@Excel(name = "唯一标识")
private String uuid;
/**
*
*/
@Excel(name = "测试总结果")
private String result;
/**
*
*/
@Excel(name = "产品条码")
private String barcode;
/**
*
*/
@Excel(name = "测试时间")
private String testTime;
/**
*
*/
@Excel(name = "测试数据")
private String testData;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date recordTime;
/**
*
*/
private List<DetailElectricalinspection> detailElectricalinspectionList;
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getUuid() {
return uuid;
}
public void setResult(String result) {
this.result = result;
}
public String getResult() {
return result;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public String getBarcode() {
return barcode;
}
public void setTestTime(String testTime) {
this.testTime = testTime;
}
public String getTestTime() {
return testTime;
}
public void setTestData(String testData) {
this.testData = testData;
}
public String getTestData() {
return testData;
}
public void setRecordTime(Date recordTime) {
this.recordTime = recordTime;
}
public Date getRecordTime() {
return recordTime;
}
public List<DetailElectricalinspection> getDetailElectricalinspectionList() {
return detailElectricalinspectionList;
}
public void setDetailElectricalinspectionList(List<DetailElectricalinspection> detailElectricalinspectionList) {
this.detailElectricalinspectionList = detailElectricalinspectionList;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("uuid", getUuid())
.append("result", getResult())
.append("barcode", getBarcode())
.append("testTime", getTestTime())
.append("testData", getTestData())
.append("recordTime", getRecordTime())
.append("detailElectricalinspectionList", getDetailElectricalinspectionList())
.toString();
}
}

@ -0,0 +1,91 @@
package com.aucma.report.mapper;
import java.util.List;
import com.aucma.common.annotation.DataSource;
import com.aucma.common.enums.DataSourceType;
import com.aucma.report.domain.RecordElectricalInspection;
import com.aucma.report.domain.DetailElectricalinspection;
/**
* Mapper
*
* @author Yinq
* @date 2023-11-09
*/
@DataSource(value = DataSourceType.SLAVE)
public interface RecordElectricalInspectionMapper
{
/**
*
*
* @param uuid
* @return
*/
public RecordElectricalInspection selectRecordElectricalInspectionByUuid(String uuid);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public List<RecordElectricalInspection> selectRecordElectricalInspectionList(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public int insertRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public int updateRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param uuid
* @return
*/
public int deleteRecordElectricalInspectionByUuid(String uuid);
/**
*
*
* @param uuids
* @return
*/
public int deleteRecordElectricalInspectionByUuids(String[] uuids);
/**
*
*
* @param uuids
* @return
*/
public int deleteDetailElectricalinspectionByUuids(String[] uuids);
/**
*
*
* @param detailElectricalinspectionList
* @return
*/
public int batchDetailElectricalinspection(List<DetailElectricalinspection> detailElectricalinspectionList);
/**
*
*
* @param uuid ID
* @return
*/
public int deleteDetailElectricalinspectionByUuid(String uuid);
}

@ -0,0 +1,61 @@
package com.aucma.report.service;
import java.util.List;
import com.aucma.report.domain.RecordElectricalInspection;
/**
* Service
*
* @author Yinq
* @date 2023-11-09
*/
public interface IRecordElectricalInspectionService
{
/**
*
*
* @param uuid
* @return
*/
public RecordElectricalInspection selectRecordElectricalInspectionByUuid(String uuid);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public List<RecordElectricalInspection> selectRecordElectricalInspectionList(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public int insertRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param recordElectricalInspection
* @return
*/
public int updateRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection);
/**
*
*
* @param uuids
* @return
*/
public int deleteRecordElectricalInspectionByUuids(String[] uuids);
/**
*
*
* @param uuid
* @return
*/
public int deleteRecordElectricalInspectionByUuid(String uuid);
}

@ -0,0 +1,131 @@
package com.aucma.report.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.aucma.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.aucma.report.domain.DetailElectricalinspection;
import com.aucma.report.mapper.RecordElectricalInspectionMapper;
import com.aucma.report.domain.RecordElectricalInspection;
import com.aucma.report.service.IRecordElectricalInspectionService;
/**
* Service
*
* @author Yinq
* @date 2023-11-09
*/
@Service
public class RecordElectricalInspectionServiceImpl implements IRecordElectricalInspectionService
{
@Autowired
private RecordElectricalInspectionMapper recordElectricalInspectionMapper;
/**
*
*
* @param uuid
* @return
*/
@Override
public RecordElectricalInspection selectRecordElectricalInspectionByUuid(String uuid)
{
return recordElectricalInspectionMapper.selectRecordElectricalInspectionByUuid(uuid);
}
/**
*
*
* @param recordElectricalInspection
* @return
*/
@Override
public List<RecordElectricalInspection> selectRecordElectricalInspectionList(RecordElectricalInspection recordElectricalInspection)
{
return recordElectricalInspectionMapper.selectRecordElectricalInspectionList(recordElectricalInspection);
}
/**
*
*
* @param recordElectricalInspection
* @return
*/
@Transactional
@Override
public int insertRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection)
{
int rows = recordElectricalInspectionMapper.insertRecordElectricalInspection(recordElectricalInspection);
insertDetailElectricalinspection(recordElectricalInspection);
return rows;
}
/**
*
*
* @param recordElectricalInspection
* @return
*/
@Transactional
@Override
public int updateRecordElectricalInspection(RecordElectricalInspection recordElectricalInspection)
{
recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuid(recordElectricalInspection.getUuid());
insertDetailElectricalinspection(recordElectricalInspection);
return recordElectricalInspectionMapper.updateRecordElectricalInspection(recordElectricalInspection);
}
/**
*
*
* @param uuids
* @return
*/
@Transactional
@Override
public int deleteRecordElectricalInspectionByUuids(String[] uuids)
{
recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuids(uuids);
return recordElectricalInspectionMapper.deleteRecordElectricalInspectionByUuids(uuids);
}
/**
*
*
* @param uuid
* @return
*/
@Transactional
@Override
public int deleteRecordElectricalInspectionByUuid(String uuid)
{
recordElectricalInspectionMapper.deleteDetailElectricalinspectionByUuid(uuid);
return recordElectricalInspectionMapper.deleteRecordElectricalInspectionByUuid(uuid);
}
/**
*
*
* @param recordElectricalInspection
*/
public void insertDetailElectricalinspection(RecordElectricalInspection recordElectricalInspection)
{
List<DetailElectricalinspection> detailElectricalinspectionList = recordElectricalInspection.getDetailElectricalinspectionList();
String uuid = recordElectricalInspection.getUuid();
if (StringUtils.isNotNull(detailElectricalinspectionList))
{
List<DetailElectricalinspection> list = new ArrayList<DetailElectricalinspection>();
for (DetailElectricalinspection detailElectricalinspection : detailElectricalinspectionList)
{
detailElectricalinspection.setUuid(uuid);
list.add(detailElectricalinspection);
}
if (list.size() > 0)
{
recordElectricalInspectionMapper.batchDetailElectricalinspection(list);
}
}
}
}

@ -0,0 +1,140 @@
<?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.aucma.report.mapper.RecordElectricalInspectionMapper">
<resultMap type="RecordElectricalInspection" id="RecordElectricalInspectionResult">
<result property="uuid" column="uuid"/>
<result property="result" column="result"/>
<result property="barcode" column="barcode"/>
<result property="testTime" column="testtime"/>
<result property="testData" column="testdata"/>
<result property="recordTime" column="recordtime"/>
</resultMap>
<resultMap id="RecordElectricalInspectionDetailElectricalinspectionResult" type="RecordElectricalInspection"
extends="RecordElectricalInspectionResult">
<collection property="detailElectricalinspectionList" notNullColumn="sub_uuid" javaType="java.util.List"
resultMap="DetailElectricalinspectionResult"/>
</resultMap>
<resultMap type="DetailElectricalinspection" id="DetailElectricalinspectionResult">
<result property="uuid" column="sub_uuid"/>
<result property="serialnumber" column="sub_serialnumber"/>
<result property="projectname" column="sub_projectname"/>
<result property="testcondition" column="sub_testcondition"/>
<result property="testvalue" column="sub_testvalue"/>
<result property="testresult" column="sub_testresult"/>
<result property="recordtime" column="sub_recordtime"/>
</resultMap>
<sql id="selectRecordElectricalInspectionVo">
select uuid, result, barcode, testtime, testdata, recordtime
from record_electricalinspection
</sql>
<select id="selectRecordElectricalInspectionList" parameterType="RecordElectricalInspection"
resultMap="RecordElectricalInspectionResult">
<include refid="selectRecordElectricalInspectionVo"/>
<where>
<if test="uuid != null and uuid != ''">and uuid = #{uuid}</if>
<if test="result != null and result != ''">and result = #{result}</if>
<if test="barcode != null and barcode != ''">and barcode = #{barcode}</if>
<if test="testTime != null and testTime != ''">and testtime = #{testTime}</if>
<if test="testData != null and testData != ''">and testdata = #{testData}</if>
<if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''">
and recordtime between to_date(#{params.beginRecordTime}, 'yyyy-mm-dd hh24:mi:ss') and
to_date(#{params.endRecordTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
</where>
</select>
<select id="selectRecordElectricalInspectionByUuid" parameterType="String"
resultMap="RecordElectricalInspectionDetailElectricalinspectionResult">
select a.uuid,
a.result,
a.barcode,
a.testtime,
a.testdata,
a.recordtime,
b.uuid as sub_uuid,
b.serialnumber as sub_serialnumber,
b.projectname as sub_projectname,
b.testcondition as sub_testcondition,
b.testvalue as sub_testvalue,
b.testresult as sub_testresult,
b.recordtime as sub_recordtime
from record_electricalinspection a
left join detail_electricalinspection b on b.uuid = a.testdata
where a.uuid = #{uuid}
</select>
<insert id="insertRecordElectricalInspection" parameterType="RecordElectricalInspection">
insert into record_electricalinspection
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uuid != null">uuid,</if>
<if test="result != null">result,</if>
<if test="barcode != null">barcode,</if>
<if test="testTime != null">testtime,</if>
<if test="testData != null">testdata,</if>
<if test="recordTime != null">recordtime,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uuid != null">#{uuid},</if>
<if test="result != null">#{result},</if>
<if test="barcode != null">#{barcode},</if>
<if test="testTime != null">#{testTime},</if>
<if test="testData != null">#{testData},</if>
<if test="recordTime != null">#{recordTime},</if>
</trim>
</insert>
<update id="updateRecordElectricalInspection" parameterType="RecordElectricalInspection">
update record_electricalinspection
<trim prefix="SET" suffixOverrides=",">
<if test="result != null">result = #{result},</if>
<if test="barcode != null">barcode = #{barcode},</if>
<if test="testTime != null">testtime = #{testTime},</if>
<if test="testData != null">testdata = #{testData},</if>
<if test="recordTime != null">recordtime = #{recordTime},</if>
</trim>
where uuid = #{uuid}
</update>
<delete id="deleteRecordElectricalInspectionByUuid" parameterType="String">
delete
from record_electricalinspection
where uuid = #{uuid}
</delete>
<delete id="deleteRecordElectricalInspectionByUuids" parameterType="String">
delete from record_electricalinspection where uuid in
<foreach item="uuid" collection="array" open="(" separator="," close=")">
#{uuid}
</foreach>
</delete>
<delete id="deleteDetailElectricalinspectionByUuids" parameterType="String">
delete from detail_electricalinspection where uuid in
<foreach item="uuid" collection="array" open="(" separator="," close=")">
#{uuid}
</foreach>
</delete>
<delete id="deleteDetailElectricalinspectionByUuid" parameterType="String">
delete
from detail_electricalinspection
where uuid = #{uuid}
</delete>
<insert id="batchDetailElectricalinspection">
insert all
<foreach item="item" index="index" collection="list">
into detail_electricalinspection( uuid, serialnumber, projectname, testcondition, testvalue, testresult,
recordtime) values ( #{item.uuid}, #{item.serialnumber}, #{item.projectname}, #{item.testcondition},
#{item.testvalue}, #{item.testresult}, #{item.recordtime})
</foreach>
SELECT 1 FROM DUAL
</insert>
</mapper>
Loading…
Cancel
Save