I2新增查询功能和代码优化

master
liuguijing 1 year ago
parent 32dbd5ba6c
commit 6c78a409bb

@ -1,11 +1,7 @@
package com.shxy.i2.Tool; package com.shxy.i2.Tool;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.XML; import cn.hutool.json.XML;
import com.shxy.i2.constant.CommonStatus;
import com.shxy.i2.constant.Constant;
import com.shxy.i2.dao.*; import com.shxy.i2.dao.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Client;
@ -13,9 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@Slf4j @Slf4j
@Component @Component

@ -1481,105 +1481,142 @@ public class XydlI2ServiceImpl implements XydlI2Service {
} }
String today = DateUtil.today(); String today = DateUtil.today();
// String today = "2024-02-01";
ListModel.Beans yspbeans = new ListModel.Beans(); ListModel.Beans yspbeans = new ListModel.Beans();
yspbeans.setName("油色谱"); yspbeans.setName("油色谱");
Data_Ysp data_ysp1 = data_yspDao.selectMaxId(); Data_Ysp data_ysp1 = data_yspDao.selectMaxId();
Data_Ysp data_ysp2 = data_yspDao.selectNowId(DateUtil.parseDate(today)); Data_Ysp data_ysp2 = data_yspDao.selectNowId(DateUtil.parseDate(today));
BigInteger yspmaxid = data_ysp1.getMaxid(); if (data_ysp1 != null) {
BigInteger yspuploadnum = map.get(Constant.YSPID); BigInteger yspmaxid = data_ysp1.getMaxid();
BigInteger ysptodaymaxid = data_ysp2.getMaxid(); BigInteger yspuploadnum = map.get(Constant.YSPID);
BigInteger ysptodayminid = data_ysp2.getMinid(); BigDecimal ysptodaymul = new BigDecimal(0);
BigDecimal ysptodaymul = NumberUtil.sub(ysptodaymaxid, ysptodayminid); BigDecimal ysptodayupload = new BigDecimal(0);
BigDecimal ysptodayupload = NumberUtil.sub(yspuploadnum, ysptodayminid); if (data_ysp2 != null) {
yspbeans.setHistory(yspmaxid); BigInteger ysptodaymaxid = data_ysp2.getMaxid();
yspbeans.setUploadnum(yspuploadnum); BigInteger ysptodayminid = data_ysp2.getMinid();
yspbeans.setNownum(BigInteger.valueOf(ysptodaymul.longValue())); ysptodaymul = NumberUtil.sub(ysptodaymaxid, ysptodayminid);
yspbeans.setNowuploadnum(BigInteger.valueOf(ysptodayupload.longValue())); ysptodayupload = NumberUtil.sub(yspuploadnum, ysptodayminid);
listModel.getList().add(yspbeans); }
yspbeans.setHistory(yspmaxid);
yspbeans.setUploadnum(yspuploadnum);
yspbeans.setNownum(BigInteger.valueOf(ysptodaymul.longValue()));
yspbeans.setNowuploadnum(BigInteger.valueOf(ysptodayupload.longValue()));
listModel.getList().add(yspbeans);
}
ListModel.Beans txbeans = new ListModel.Beans(); ListModel.Beans txbeans = new ListModel.Beans();
txbeans.setName("铁芯夹件"); txbeans.setName("铁芯夹件");
Data_Tx data_tx1 = data_txDao.selectMaxId(); Data_Tx data_tx1 = data_txDao.selectMaxId();
Data_Tx data_tx2 = data_txDao.selectNowId(DateUtil.parseDate(today)); Data_Tx data_tx2 = data_txDao.selectNowId(DateUtil.parseDate(today));
BigInteger txmaxid = data_tx1.getMaxid(); if (data_tx1 != null) {
BigInteger txuploadnum = map.get(Constant.TXID); BigInteger txmaxid = data_tx1.getMaxid();
BigInteger txtodaymaxid = data_tx2.getMaxid(); BigInteger txuploadnum = map.get(Constant.TXID);
BigInteger txtodayminid = data_tx2.getMinid(); BigDecimal txtodaymul = new BigDecimal(0);
BigDecimal txtodaymul = NumberUtil.sub(txtodaymaxid, txtodayminid); BigDecimal txtodayupload = new BigDecimal(0);
BigDecimal txtodayupload = NumberUtil.sub(txuploadnum, txtodayminid); if (data_tx2 != null) {
txbeans.setHistory(txmaxid); BigInteger txtodaymaxid = data_tx2.getMaxid();
txbeans.setUploadnum(txuploadnum); BigInteger txtodayminid = data_tx2.getMinid();
txbeans.setNownum(BigInteger.valueOf(txtodaymul.longValue())); txtodaymul = NumberUtil.sub(txtodaymaxid, txtodayminid);
txbeans.setNowuploadnum(BigInteger.valueOf(txtodayupload.longValue())); txtodayupload = NumberUtil.sub(txuploadnum, txtodayminid);
listModel.getList().add(txbeans); }
txbeans.setHistory(txmaxid);
txbeans.setUploadnum(txuploadnum);
txbeans.setNownum(BigInteger.valueOf(txtodaymul.longValue()));
txbeans.setNowuploadnum(BigInteger.valueOf(txtodayupload.longValue()));
listModel.getList().add(txbeans);
}
ListModel.Beans dlqbeans = new ListModel.Beans(); ListModel.Beans dlqbeans = new ListModel.Beans();
dlqbeans.setName("断路器局放"); dlqbeans.setName("断路器局放");
Data_Dlq_Jbfd data_dlq_jbfd1 = data_dlq_jbfdDao.selectMaxId(); Data_Dlq_Jbfd data_dlq_jbfd1 = data_dlq_jbfdDao.selectMaxId();
Data_Dlq_Jbfd data_dlq_jbfd2 = data_dlq_jbfdDao.selectNowId(DateUtil.parseDate(today)); Data_Dlq_Jbfd data_dlq_jbfd2 = data_dlq_jbfdDao.selectNowId(DateUtil.parseDate(today));
BigInteger dlqmaxid = data_dlq_jbfd1.getMaxid(); if (data_dlq_jbfd1 != null) {
BigInteger dlquploadnum = map.get(Constant.DLQJBFDID); BigInteger dlqmaxid = data_dlq_jbfd1.getMaxid();
BigInteger dlqtodaymaxid = data_dlq_jbfd2.getMaxid(); BigInteger dlquploadnum = map.get(Constant.DLQJBFDID);
BigInteger dlqtodayminid = data_dlq_jbfd2.getMinid(); BigDecimal dlqtodaymul = new BigDecimal(0);
BigDecimal dlqtodaymul = NumberUtil.sub(dlqtodaymaxid, dlqtodayminid); BigDecimal dlqtodayupload = new BigDecimal(0);
BigDecimal dlqtodayupload = NumberUtil.sub(dlquploadnum, dlqtodayminid); if (data_dlq_jbfd2 != null) {
dlqbeans.setHistory(dlqmaxid); BigInteger dlqtodaymaxid = data_dlq_jbfd2.getMaxid();
dlqbeans.setUploadnum(dlquploadnum); BigInteger dlqtodayminid = data_dlq_jbfd2.getMinid();
dlqbeans.setNownum(BigInteger.valueOf(dlqtodaymul.longValue())); dlqtodaymul = NumberUtil.sub(dlqtodaymaxid, dlqtodayminid);
dlqbeans.setNowuploadnum(BigInteger.valueOf(dlqtodayupload.longValue())); dlqtodayupload = NumberUtil.sub(dlquploadnum, dlqtodayminid);
listModel.getList().add(dlqbeans); }
dlqbeans.setHistory(dlqmaxid);
dlqbeans.setUploadnum(dlquploadnum);
dlqbeans.setNownum(BigInteger.valueOf(dlqtodaymul.longValue()));
dlqbeans.setNowuploadnum(BigInteger.valueOf(dlqtodayupload.longValue()));
listModel.getList().add(dlqbeans);
}
ListModel.Beans sf6beans = new ListModel.Beans(); ListModel.Beans sf6beans = new ListModel.Beans();
sf6beans.setName("SF6气体压力"); sf6beans.setName("SF6气体压力");
Data_SF6_Qtyl data_sf6_qtyl1 = data_sf6_qtylDao.selectMaxId(); Data_SF6_Qtyl data_sf6_qtyl1 = data_sf6_qtylDao.selectMaxId();
Data_SF6_Qtyl data_sf6_qtyl2 = data_sf6_qtylDao.selectNowId(DateUtil.parseDate(today)); Data_SF6_Qtyl data_sf6_qtyl2 = data_sf6_qtylDao.selectNowId(DateUtil.parseDate(today));
BigInteger sf6maxid = data_sf6_qtyl1.getMaxid(); if (data_sf6_qtyl1 != null) {
BigInteger sf6uploadnum = map.get(Constant.SF6QTYLID); BigInteger sf6maxid = data_sf6_qtyl1.getMaxid();
BigInteger sf6todaymaxid = data_sf6_qtyl2.getMaxid(); BigInteger sf6uploadnum = map.get(Constant.SF6QTYLID);
BigInteger sf6todayminid = data_sf6_qtyl2.getMinid(); BigDecimal sf6todaymul = new BigDecimal(0);
BigDecimal sf6todaymul = NumberUtil.sub(sf6todaymaxid, sf6todayminid); BigDecimal sf6todayupload = new BigDecimal(0);
BigDecimal sf6todayupload = NumberUtil.sub(sf6uploadnum, sf6todayminid); if (data_sf6_qtyl2 != null) {
sf6beans.setHistory(sf6maxid); BigInteger sf6todaymaxid = data_sf6_qtyl2.getMaxid();
sf6beans.setUploadnum(sf6uploadnum); BigInteger sf6todayminid = data_sf6_qtyl2.getMinid();
sf6beans.setNownum(BigInteger.valueOf(sf6todaymul.longValue())); sf6todaymul = NumberUtil.sub(sf6todaymaxid, sf6todayminid);
sf6beans.setNowuploadnum(BigInteger.valueOf(sf6todayupload.longValue())); sf6todayupload = NumberUtil.sub(sf6uploadnum, sf6todayminid);
listModel.getList().add(sf6beans); }
sf6beans.setHistory(sf6maxid);
sf6beans.setUploadnum(sf6uploadnum);
sf6beans.setNownum(BigInteger.valueOf(sf6todaymul.longValue()));
sf6beans.setNowuploadnum(BigInteger.valueOf(sf6todayupload.longValue()));
listModel.getList().add(sf6beans);
}
ListModel.Beans jsybeans = new ListModel.Beans();
jsybeans.setName("避雷器");
Data_Jsyhw_Jyjc data_jsyhw_jyjc1 = data_jsyhw_jyjcDao.selectMaxId(); Data_Jsyhw_Jyjc data_jsyhw_jyjc1 = data_jsyhw_jyjcDao.selectMaxId();
Data_Jsyhw_Jyjc data_jsyhw_jyjc2 = data_jsyhw_jyjcDao.selectNowId(DateUtil.parseDate(today)); Data_Jsyhw_Jyjc data_jsyhw_jyjc2 = data_jsyhw_jyjcDao.selectNowId(DateUtil.parseDate(today));
BigInteger jsymaxid = data_jsyhw_jyjc1.getMaxid(); if (data_jsyhw_jyjc1 != null) {
BigInteger jsyuploadnum = map.get(Constant.JSYHWJYJCID); ListModel.Beans jsybeans = new ListModel.Beans();
BigInteger jsytodaymaxid = data_jsyhw_jyjc2.getMaxid(); jsybeans.setName("避雷器");
BigInteger jsytodayminid = data_jsyhw_jyjc2.getMinid(); BigInteger jsymaxid = data_jsyhw_jyjc1.getMaxid();
BigDecimal jsytodaymul = NumberUtil.sub(jsytodaymaxid, jsytodayminid); BigInteger jsyuploadnum = map.get(Constant.JSYHWJYJCID);
BigDecimal jsytodayupload = NumberUtil.sub(jsyuploadnum, jsytodayminid); BigDecimal jsytodaymul = new BigDecimal(0);
jsybeans.setHistory(jsymaxid); BigDecimal jsytodayupload = new BigDecimal(0);
jsybeans.setUploadnum(jsyuploadnum); if (data_jsyhw_jyjc2 != null) {
jsybeans.setNownum(BigInteger.valueOf(jsytodaymul.longValue())); BigInteger jsytodaymaxid = data_jsyhw_jyjc2.getMaxid();
jsybeans.setNowuploadnum(BigInteger.valueOf(jsytodayupload.longValue())); BigInteger jsytodayminid = data_jsyhw_jyjc2.getMinid();
listModel.getList().add(jsybeans); jsytodaymul = NumberUtil.sub(jsytodaymaxid, jsytodayminid);
jsytodayupload = NumberUtil.sub(jsyuploadnum, jsytodayminid);
}
jsybeans.setHistory(jsymaxid);
jsybeans.setUploadnum(jsyuploadnum);
jsybeans.setNownum(BigInteger.valueOf(jsytodaymul.longValue()));
jsybeans.setNowuploadnum(BigInteger.valueOf(jsytodayupload.longValue()));
listModel.getList().add(jsybeans);
}
ListModel.Beans yxbeans = new ListModel.Beans();
yxbeans.setName("遥信");
Data_YxlDto data_yxlDto1 = data_yxDao.selectMaxId(); Data_YxlDto data_yxlDto1 = data_yxDao.selectMaxId();
Data_YxlDto data_yxlDto2 = data_yxDao.selectNowId(DateUtil.parseDate(today)); Data_YxlDto data_yxlDto2 = data_yxDao.selectNowId(DateUtil.parseDate(today));
BigInteger yxmaxid = data_yxlDto1.getMaxid(); if (data_yxlDto1 != null) {
BigInteger yxuploadnum = map.get(Constant.YXID); ListModel.Beans yxbeans = new ListModel.Beans();
BigInteger yxtodaymaxid = data_yxlDto2.getMaxid(); yxbeans.setName("遥信");
BigInteger yxtodayminid = data_yxlDto2.getMinid(); BigInteger yxmaxid = data_yxlDto1.getMaxid();
BigDecimal yxtodaymul = NumberUtil.sub(yxtodaymaxid, yxtodayminid); BigInteger yxuploadnum = map.get(Constant.YXID);
BigDecimal yxtodayupload = NumberUtil.sub(yxuploadnum, yxtodayminid); BigDecimal yxtodaymul = new BigDecimal(0);
yxbeans.setHistory(yxmaxid); BigDecimal yxtodayupload = new BigDecimal(0);
yxbeans.setUploadnum(yxuploadnum); if (data_yxlDto2 != null) {
yxbeans.setNownum(BigInteger.valueOf(yxtodaymul.longValue())); BigInteger yxtodaymaxid = data_yxlDto2.getMaxid();
yxbeans.setNowuploadnum(BigInteger.valueOf(yxtodayupload.longValue())); BigInteger yxtodayminid = data_yxlDto2.getMinid();
listModel.getList().add(yxbeans); yxtodaymul = NumberUtil.sub(yxtodaymaxid, yxtodayminid);
yxtodayupload = NumberUtil.sub(yxuploadnum, yxtodayminid);
}
yxbeans.setHistory(yxmaxid);
yxbeans.setUploadnum(yxuploadnum);
yxbeans.setNownum(BigInteger.valueOf(yxtodaymul.longValue()));
yxbeans.setNowuploadnum(BigInteger.valueOf(yxtodayupload.longValue()));
listModel.getList().add(yxbeans);
}
ServiceBody<ListModel> serviceBody = new ServiceBody<ListModel>(); ServiceBody<ListModel> serviceBody = new ServiceBody<ListModel>();
serviceBody.setCode(ServiceStatus.SUCCESS); serviceBody.setCode(ServiceStatus.SUCCESS);

@ -208,181 +208,5 @@
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP}
where check_type = #{checkType,jdbcType=VARCHAR} where check_type = #{checkType,jdbcType=VARCHAR}
</update> </update>
<resultMap id="BaseResultMap" type="com.shxy.i2.entity.Upload_Statics">
<id column="check_type" jdbcType="VARCHAR" property="checkType" />
<result column="value" jdbcType="BIGINT" property="value" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
check_type, value, update_time
</sql>
<select id="selectByExample" parameterType="com.shxy.i2.entity.Upload_StaticsExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from upload_statics
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from upload_statics
where check_type = #{checkType,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from upload_statics
where check_type = #{checkType,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.shxy.i2.entity.Upload_StaticsExample">
delete from upload_statics
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.shxy.i2.entity.Upload_Statics">
insert into upload_statics (check_type, value, update_time
)
values (#{checkType,jdbcType=VARCHAR}, #{value,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.shxy.i2.entity.Upload_Statics">
insert into upload_statics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="checkType != null">
check_type,
</if>
<if test="value != null">
value,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="checkType != null">
#{checkType,jdbcType=VARCHAR},
</if>
<if test="value != null">
#{value,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.shxy.i2.entity.Upload_StaticsExample" resultType="java.lang.Long">
select count(*) from upload_statics
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update upload_statics
<set>
<if test="record.checkType != null">
check_type = #{record.checkType,jdbcType=VARCHAR},
</if>
<if test="record.value != null">
value = #{record.value,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update upload_statics
set check_type = #{record.checkType,jdbcType=VARCHAR},
value = #{record.value,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.i2.entity.Upload_Statics">
update upload_statics
<set>
<if test="value != null">
value = #{value,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where check_type = #{checkType,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.shxy.i2.entity.Upload_Statics">
update upload_statics
set value = #{value,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where check_type = #{checkType,jdbcType=VARCHAR}
</update>
</mapper> </mapper>
Loading…
Cancel
Save