新增 同步 库存全品种统计表 的定时任务

This commit is contained in:
king
2026-04-14 17:10:46 +08:00
parent 0134dd5ee7
commit 2cf72b270e
6 changed files with 449 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package com.lideeyunji.core.framework.config.job;
import com.lideeyunji.core.framework.service.IGrBiStStatsService;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 库存全品种统计表
* oracle gr_bi_st_stats -> mysql gr_bi_st_stats
*/
@Slf4j
@Component("generateStStatsJob")
public class GenerateStStatsJob implements JobHandler {
@Resource
private IGrBiStStatsService iGrBiStStatsService;
@Override
public String execute(String param) throws Exception {
log.info("*********** 开始生成库存全品种统计表 ************");
iGrBiStStatsService.generateStStats(lideeYunJiBaseConstant.DS_ERP_BI_DATA);
log.info("*********** 生成库存全品种统计表完成 ************");
return "*********** 生成库存全品种统计表完成 ************";
}
}

View File

@@ -0,0 +1,49 @@
package com.lideeyunji.core.framework.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* 库存全品种统计表
*
* @author ruoyi
* @date 2026-04-14
*/
@TableName("gr_bi_st_stats")
@Data
public class GrBiStStats implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "ID", type = IdType.INPUT)
private Long id;
@TableField(value = "GOODSID")
private String goodsId;
@TableField(value = "GOODSNAME")
private String goodsName;
@TableField(value = "GOODSTYPE")
private String goodsType;
@TableField(value = "GOODSUNIT")
private String goodsUnit;
@TableField(value = "REMQTY")
private String remQty;
@TableField(value = "REMMONEY")
private String remMoney;
@TableField(value = "MONTHSAMONEY")
private String monthSaMoney;
@TableField(value = "SKSA")
private String skSa;
@TableField(value = "THISSAMONEY")
private String thisSaMoney;
@TableField(value = "THISPROFIT")
private String thisProfit;
@TableField(value = "THISPROFITRATE")
private String thisProfitRate;
@TableField(value = "MAXAGE")
private String maxAge;
}

View File

@@ -0,0 +1,70 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lideeyunji.core.framework.entity.GrBiStStats;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 库存全品种统计表Mapper接口
*
* @author ruoyi
* @date 2026-03-12
*/
public interface GrBiStStatsMapper extends BaseMapper<GrBiStStats>
{
/**
* 查询库存全品种统计表
*
* @param ID 库存全品种统计表主键
* @return 库存全品种统计表
*/
public GrBiStStats selectGrBiStStatsByID(String ID);
/**
* 查询库存全品种统计表列表
*
* @param GrBiStStats 库存全品种统计表
* @return 库存全品种统计表集合
*/
public List<GrBiStStats> selectGrBiStStatsList(GrBiStStats GrBiStStats);
/**
* 新增库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
public int insertGrBiStStats(GrBiStStats GrBiStStats);
/**
* 修改库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
public int updateGrBiStStats(GrBiStStats GrBiStStats);
/**
* 删除库存全品种统计表
*
* @param ID 库存全品种统计表主键
* @return 结果
*/
public int deleteGrBiStStatsByID(String ID);
/**
* 批量删除库存全品种统计表
*
* @param IDs 需要删除的数据主键集合
* @return 结果
*/
public int deleteGrBiStStatsByIDs(String[] IDs);
@DS(value = "#dataSourceType")
List<GrBiStStats> getBusinessRealList(@Param("dataSourceType") String dataSourceType);
@DS(value = "#dataSourceType")
int deleteOldBusinessReal(@Param("dataSourceType") String dataSourceType);
}

View File

@@ -0,0 +1,64 @@
package com.lideeyunji.core.framework.service;
import com.lideeyunji.core.framework.entity.GrBiStStats;
import java.util.List;
/**
* 库存全品种统计表Service接口
*
* @author ruoyi
* @date 2026-03-12
*/
public interface IGrBiStStatsService
{
/**
* 查询库存全品种统计表
*
* @param ID 库存全品种统计表主键
* @return 库存全品种统计表
*/
public GrBiStStats selectGrBiStStatsByID(String ID);
/**
* 查询库存全品种统计表列表
*
* @param GrBiStStats 库存全品种统计表
* @return 库存全品种统计表集合
*/
public List<GrBiStStats> selectGrBiStStatsList(GrBiStStats GrBiStStats);
/**
* 新增库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
public int insertGrBiStStats(GrBiStStats GrBiStStats);
/**
* 修改库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
public int updateGrBiStStats(GrBiStStats GrBiStStats);
/**
* 批量删除库存全品种统计表
*
* @param IDs 需要删除的库存全品种统计表主键集合
* @return 结果
*/
public int deleteGrBiStStatsByIDs(String[] IDs);
/**
* 删除库存全品种统计表信息
*
* @param ID 库存全品种统计表主键
* @return 结果
*/
public int deleteGrBiStStatsByID(String ID);
void generateStStats(String dataSourceType);
}

View File

@@ -0,0 +1,118 @@
package com.lideeyunji.core.framework.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lideeyunji.core.framework.entity.GrBiStStats;
import com.lideeyunji.core.framework.mapper.GrBiStStatsMapper;
import com.lideeyunji.core.framework.service.IGrBiStStatsService;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 库存全品种统计表Service业务层处理
*
* @author ruoyi
* @date 2026-03-12
*/
@Slf4j
@Service
public class GrBiStStatsServiceImpl extends ServiceImpl<GrBiStStatsMapper, GrBiStStats> implements IGrBiStStatsService
{
@Override
@DSTransactional
@DS(value = "#dataSourceType")
public void generateStStats(String dataSourceType) {
// 获取数据
List<GrBiStStats> grBiSaSetdtlList = this.baseMapper.getBusinessRealList(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI);
if (CollUtil.isEmpty(grBiSaSetdtlList)) {
return;
}
//保存数据
int reNum = this.baseMapper.deleteOldBusinessReal(lideeYunJiBaseConstant.DS_ERP_BI_DATA);
log.info("删除数量:{}", reNum);
for (GrBiStStats grBiSaSetdtl : grBiSaSetdtlList) {
int re = this.baseMapper.insert(grBiSaSetdtl);
if (re < 1) {
throw new RuntimeException("批量新增异常");
}
}
}
/**
* 查询库存全品种统计表
*
* @param ID 库存全品种统计表主键
* @return 库存全品种统计表
*/
@Override
public GrBiStStats selectGrBiStStatsByID(String ID)
{
return this.baseMapper.selectGrBiStStatsByID(ID);
}
/**
* 查询库存全品种统计表列表
*
* @param GrBiStStats 库存全品种统计表
* @return 库存全品种统计表
*/
@Override
public List<GrBiStStats> selectGrBiStStatsList(GrBiStStats GrBiStStats)
{
return this.baseMapper.selectGrBiStStatsList(GrBiStStats);
}
/**
* 新增库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
@Override
public int insertGrBiStStats(GrBiStStats GrBiStStats)
{
return this.baseMapper.insertGrBiStStats(GrBiStStats);
}
/**
* 修改库存全品种统计表
*
* @param GrBiStStats 库存全品种统计表
* @return 结果
*/
@Override
public int updateGrBiStStats(GrBiStStats GrBiStStats)
{
return this.baseMapper.updateGrBiStStats(GrBiStStats);
}
/**
* 批量删除库存全品种统计表
*
* @param IDs 需要删除的库存全品种统计表主键
* @return 结果
*/
@Override
public int deleteGrBiStStatsByIDs(String[] IDs)
{
return this.baseMapper.deleteGrBiStStatsByIDs(IDs);
}
/**
* 删除库存全品种统计表信息
*
* @param ID 库存全品种统计表主键
* @return 结果
*/
@Override
public int deleteGrBiStStatsByID(String ID)
{
return this.baseMapper.deleteGrBiStStatsByID(ID);
}
}

View File

@@ -0,0 +1,119 @@
<?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.lideeyunji.core.framework.mapper.GrBiStStatsMapper">
<resultMap type="com.lideeyunji.core.framework.entity.GrBiStStats" id="GrBiStStatsResult">
<result property="id" column="ID"/>
<result property="goodsId" column="GOODSID"/>
<result property="goodsName" column="GOODSNAME"/>
<result property="goodsType" column="GOODSTYPE"/>
<result property="goodsUnit" column="GOODSUNIT"/>
<result property="remQty" column="REMQTY"/>
<result property="remMoney" column="REMMONEY"/>
<result property="monthSaMoney" column="MONTHSAMONEY"/>
<result property="skSa" column="SKSA"/>
<result property="thisSaMoney" column="THISSAMONEY"/>
<result property="thisProfit" column="THISPROFIT"/>
<result property="thisProfitRate" column="THISPROFITRATE"/>
<result property="maxAge" column="MAXAGE"/>
</resultMap>
<sql id="selectGrBiStStatsVo">
select ID, GOODSID, GOODSNAME, GOODSTYPE, GOODSUNIT, REMQTY, REMMONEY, MONTHSAMONEY, SKSA, THISSAMONEY, THISPROFIT, THISPROFITRATE,MAXAGE from gr_bi_st_stats
</sql>
<select id="getBusinessRealList" resultMap="GrBiStStatsResult">
<include refid="selectGrBiStStatsVo"/>
</select>
<delete id="deleteOldBusinessReal">
delete from gr_bi_st_stats
</delete>
<select id="selectGrBiStStatsList" parameterType="com.lideeyunji.core.framework.entity.GrBiStStats" resultMap="GrBiStStatsResult">
<include refid="selectGrBiStStatsVo"/>
<where>
<if test="id != null and id != ''"> and ID = #{id}</if>
<if test="goodsId != null and goodsId != ''"> and GOODSID = #{goodsId}</if>
<if test="goodsName != null and goodsName != ''"> and GOODSNAME = #{goodsName}</if>
<if test="goodsType != null and goodsType != ''"> and GOODSTYPE = #{goodsType}</if>
<if test="goodsUnit != null and goodsUnit != ''"> and GOODSUNIT = #{goodsUnit}</if>
<if test="remQty != null and remQty != ''"> and REMQTY = #{remQty}</if>
<if test="remMoney != null and remMoney != ''"> and REMMONEY = #{remMoney}</if>
<if test="monthSaMoney != null and monthSaMoney != ''"> and MONTHSAMONEY = #{monthSaMoney}</if>
<if test="skSa != null and skSa != ''"> and SKSA = #{skSa}</if>
<if test="thisSaMoney != null and thisSaMoney != ''"> and THISSAMONEY = #{thisSaMoney}</if>
<if test="thisProfit != null and thisProfit != ''"> and THISPROFIT = #{thisProfit}</if>
<if test="thisProfitRate != null and thisProfitRate != ''"> and THISPROFITRATE = #{thisProfitRate}</if>
<if test="maxAge != null and maxAge != ''"> and MAXAGE = #{maxAge}</if>
</where>
</select>
<select id="selectGrBiStStatsByID" parameterType="String" resultMap="GrBiStStatsResult">
<include refid="selectGrBiStStatsVo"/>
where ID = #{ID}
</select>
<insert id="insertGrBiStStats" parameterType="com.lideeyunji.core.framework.entity.GrBiStStats">
insert into gr_bi_st_stats
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">ID,</if>
<if test="goodsId != null">GOODSID,</if>
<if test="goodsName != null">GOODSNAME,</if>
<if test="goodsType != null">GOODSTYPE,</if>
<if test="goodsUnit != null">GOODSUNIT,</if>
<if test="remQty != null">REMQTY,</if>
<if test="remMoney != null">REMMONEY,</if>
<if test="monthSaMoney != null">MONTHSAMONEY,</if>
<if test="skSa != null">SKSA,</if>
<if test="thisSaMoney != null">THISSAMONEY,</if>
<if test="thisProfit != null">THISPROFIT,</if>
<if test="thisProfitRate != null">THISPROFITRATE,</if>
<if test="maxAge != null">MAXAGE,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id!= null">#{id},</if>
<if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="goodsType != null">#{goodsType},</if>
<if test="goodsUnit != null">#{goodsUnit},</if>
<if test="remQty != null">#{remQty},</if>
<if test="remMoney != null">#{remMoney},</if>
<if test="monthSaMoney != null">#{monthSaMoney},</if>
<if test="skSa != null">#{skSa},</if>
<if test="thisSaMoney != null">#{thisSaMoney},</if>
<if test="thisProfit != null">#{thisProfit},</if>
<if test="thisProfitRate != null">#{thisProfitRate},</if>
<if test="maxAge != null">#{maxAge},</if>
</trim>
</insert>
<update id="updateGrBiStStats" parameterType="com.lideeyunji.core.framework.entity.GrBiStStats">
update gr_bi_st_stats
<trim prefix="SET" suffixOverrides=",">
<if test="goodsId!= null">GOODSID = #{goodsId},</if>
<if test="goodsName!= null">GOODSNAME = #{goodsName},</if>
<if test="goodsType!= null">GOODSTYPE = #{goodsType},</if>
<if test="goodsUnit!= null">GOODSUNIT = #{goodsUnit},</if>
<if test="remQty!= null">REMQTY = #{remQty},</if>
<if test="remMoney!= null">REMMONEY = #{remMoney},</if>
<if test="monthSaMoney!= null">MONTHSAMONEY = #{monthSaMoney},</if>
<if test="skSa!= null">SKSA = #{skSa},</if>
<if test="thisSaMoney != null">THISSAMONEY = #{thisSaMoney},</if>
<if test="thisProfit != null">THISPROFIT = #{thisProfit},</if>
<if test="thisProfitRate != null">THISPROFITRATE = #{thisProfitRate},</if>
<if test="maxAge != null">MAXAGE = #{maxAge},</if>
</trim>
where ID = #{ID}
</update>
<delete id="deleteGrBiStStatsByID" parameterType="String">
delete from gr_bi_st_stats where ID = #{ID}
</delete>
<delete id="deleteGrBiStStatsByIDs" parameterType="String">
delete from gr_bi_st_stats where ID in
<foreach item="ID" collection="IDs" open="(" separator="," close=")">
#{ID}
</foreach>
</delete>
</mapper>