1.添加物资出入库汇总数据生成代码
							parent
							
								
									3dd30519db
								
							
						
					
					
						commit
						340073ea81
					
				| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.dao.inout; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.glxp.api.entity.inout.IoStatDayEntity; | ||||
| 
 | ||||
| public interface IoStatDayDao extends BaseMapper<IoStatDayEntity> { | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.dao.inout; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.glxp.api.entity.inout.IoStatMonthEntity; | ||||
| 
 | ||||
| public interface IoStatMonthDao extends BaseMapper<IoStatMonthEntity> { | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.dao.inout; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.glxp.api.entity.inout.IoStatOrderEntity; | ||||
| 
 | ||||
| public interface IoStatOrderDao extends BaseMapper<IoStatOrderEntity> { | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.dao.inout; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.glxp.api.entity.inout.IoStatQuarterEntity; | ||||
| 
 | ||||
| public interface IoStatQuarterDao extends BaseMapper<IoStatQuarterEntity> { | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.dao.inout; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.glxp.api.entity.inout.IoStatYearEntity; | ||||
| 
 | ||||
| public interface IoStatYearDao extends BaseMapper<IoStatYearEntity> { | ||||
| } | ||||
| @ -0,0 +1,160 @@ | ||||
| package com.glxp.api.entity.inout; | ||||
| 
 | ||||
| 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.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 天 | ||||
|  */ | ||||
| @Data | ||||
| @TableName(value = "io_stat_day") | ||||
| public class IoStatDayEntity { | ||||
| 
 | ||||
|     @TableId(value = "id", type = IdType.AUTO) | ||||
|     private Integer id; | ||||
| 
 | ||||
|     /** | ||||
|      * 年度 | ||||
|      */ | ||||
|     @TableField(value = "`year`") | ||||
|     private Integer year; | ||||
| 
 | ||||
|     /** | ||||
|      * 季度 | ||||
|      */ | ||||
|     @TableField(value = "quarter") | ||||
|     private Integer quarter; | ||||
| 
 | ||||
|     /** | ||||
|      * 月份 | ||||
|      */ | ||||
|     @TableField(value = "`month`") | ||||
|     private Integer month; | ||||
| 
 | ||||
|     /** | ||||
|      * 日 | ||||
|      */ | ||||
|     @TableField(value = "`day`") | ||||
|     private Integer day; | ||||
| 
 | ||||
|     /** | ||||
|      * 物资编码主键 | ||||
|      */ | ||||
|     @TableField(value = "relIdFk") | ||||
|     private String relIdFk; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品DI | ||||
|      */ | ||||
|     @TableField(value = "nameCode") | ||||
|     private String nameCode; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品名称 | ||||
|      */ | ||||
|     @TableField(value = "productName") | ||||
|     private String productName; | ||||
| 
 | ||||
|     /** | ||||
|      * 规格型号 | ||||
|      */ | ||||
|     @TableField(value = "ggxh") | ||||
|     private String ggxh; | ||||
| 
 | ||||
|     /** | ||||
|      * 批次号 | ||||
|      */ | ||||
|     @TableField(value = "batchNo") | ||||
|     private String batchNo; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初数量 | ||||
|      */ | ||||
|     @TableField(value = "beginCount") | ||||
|     private Integer beginCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初价格 | ||||
|      */ | ||||
|     @TableField(value = "beginPrice") | ||||
|     private BigDecimal beginPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初金额 | ||||
|      */ | ||||
|     @TableField(value = "beginAmount") | ||||
|     private BigDecimal beginAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库数量 | ||||
|      */ | ||||
|     @TableField(value = "inCount") | ||||
|     private String inCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库价格 | ||||
|      */ | ||||
|     @TableField(value = "inPrice") | ||||
|     private BigDecimal inPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库金额 | ||||
|      */ | ||||
|     @TableField(value = "inAmount") | ||||
|     private String inAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库数量 | ||||
|      */ | ||||
|     @TableField(value = "outCount") | ||||
|     private String outCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库价格 | ||||
|      */ | ||||
|     @TableField(value = "outPrice") | ||||
|     private BigDecimal outPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库金额 | ||||
|      */ | ||||
|     @TableField(value = "outAmount") | ||||
|     private String outAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余数量 | ||||
|      */ | ||||
|     @TableField(value = "balanceCount") | ||||
|     private String balanceCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余价格 | ||||
|      */ | ||||
|     @TableField(value = "balancePrice") | ||||
|     private BigDecimal balancePrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余金额 | ||||
|      */ | ||||
|     @TableField(value = "balanceAmount") | ||||
|     private String balanceAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @TableField(value = "remark") | ||||
|     private String remark; | ||||
| 
 | ||||
|     /** | ||||
|      * 更新时间 | ||||
|      */ | ||||
|     @TableField(value = "updateTime") | ||||
|     private Date updateTime; | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,154 @@ | ||||
| package com.glxp.api.entity.inout; | ||||
| 
 | ||||
| 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.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 月 | ||||
|  */ | ||||
| @Data | ||||
| @TableName(value = "io_stat_month") | ||||
| public class IoStatMonthEntity { | ||||
| 
 | ||||
|     @TableId(value = "id", type = IdType.AUTO) | ||||
|     private Integer id; | ||||
| 
 | ||||
|     /** | ||||
|      * 年度 | ||||
|      */ | ||||
|     @TableField(value = "`year`") | ||||
|     private Integer year; | ||||
| 
 | ||||
|     /** | ||||
|      * 季度 | ||||
|      */ | ||||
|     @TableField(value = "quarter") | ||||
|     private Integer quarter; | ||||
| 
 | ||||
|     /** | ||||
|      * 月份 | ||||
|      */ | ||||
|     @TableField(value = "`month`") | ||||
|     private Integer month; | ||||
| 
 | ||||
|     /** | ||||
|      * 物资编码主键 | ||||
|      */ | ||||
|     @TableField(value = "relIdFk") | ||||
|     private String relIdFk; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品DI | ||||
|      */ | ||||
|     @TableField(value = "nameCode") | ||||
|     private String nameCode; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品名称 | ||||
|      */ | ||||
|     @TableField(value = "productName") | ||||
|     private String productName; | ||||
| 
 | ||||
|     /** | ||||
|      * 规格型号 | ||||
|      */ | ||||
|     @TableField(value = "ggxh") | ||||
|     private String ggxh; | ||||
| 
 | ||||
|     /** | ||||
|      * 批次号 | ||||
|      */ | ||||
|     @TableField(value = "batchNo") | ||||
|     private String batchNo; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初数量 | ||||
|      */ | ||||
|     @TableField(value = "beginCount") | ||||
|     private Integer beginCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初价格 | ||||
|      */ | ||||
|     @TableField(value = "beginPrice") | ||||
|     private BigDecimal beginPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初金额 | ||||
|      */ | ||||
|     @TableField(value = "beginAmount") | ||||
|     private BigDecimal beginAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库数量 | ||||
|      */ | ||||
|     @TableField(value = "inCount") | ||||
|     private String inCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库价格 | ||||
|      */ | ||||
|     @TableField(value = "inPrice") | ||||
|     private BigDecimal inPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库金额 | ||||
|      */ | ||||
|     @TableField(value = "inAmount") | ||||
|     private String inAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库数量 | ||||
|      */ | ||||
|     @TableField(value = "outCount") | ||||
|     private String outCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库价格 | ||||
|      */ | ||||
|     @TableField(value = "outPrice") | ||||
|     private BigDecimal outPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库金额 | ||||
|      */ | ||||
|     @TableField(value = "outAmount") | ||||
|     private String outAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余数量 | ||||
|      */ | ||||
|     @TableField(value = "balanceCount") | ||||
|     private String balanceCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余价格 | ||||
|      */ | ||||
|     @TableField(value = "balancePrice") | ||||
|     private BigDecimal balancePrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余金额 | ||||
|      */ | ||||
|     @TableField(value = "balanceAmount") | ||||
|     private String balanceAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @TableField(value = "remark") | ||||
|     private String remark; | ||||
| 
 | ||||
|     /** | ||||
|      * 更新时间 | ||||
|      */ | ||||
|     @TableField(value = "updateTime") | ||||
|     private Date updateTime; | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,147 @@ | ||||
| package com.glxp.api.entity.inout; | ||||
| 
 | ||||
| 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.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 季度 | ||||
|  */ | ||||
| @Data | ||||
| @TableName(value = "io_stat_quarter") | ||||
| public class IoStatQuarterEntity { | ||||
|     @TableId(value = "id", type = IdType.AUTO) | ||||
|     private Integer id; | ||||
| 
 | ||||
|     /** | ||||
|      * 年度 | ||||
|      */ | ||||
|     @TableField(value = "`year`") | ||||
|     private Integer year; | ||||
| 
 | ||||
|     /** | ||||
|      * 季度 | ||||
|      */ | ||||
|     @TableField(value = "quarter") | ||||
|     private Integer quarter; | ||||
| 
 | ||||
|     /** | ||||
|      * 物资编码主键 | ||||
|      */ | ||||
|     @TableField(value = "relIdFk") | ||||
|     private String relIdFk; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品DI | ||||
|      */ | ||||
|     @TableField(value = "nameCode") | ||||
|     private String nameCode; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品名称 | ||||
|      */ | ||||
|     @TableField(value = "productName") | ||||
|     private String productName; | ||||
| 
 | ||||
|     /** | ||||
|      * 规格型号 | ||||
|      */ | ||||
|     @TableField(value = "ggxh") | ||||
|     private String ggxh; | ||||
| 
 | ||||
|     /** | ||||
|      * 批次号 | ||||
|      */ | ||||
|     @TableField(value = "batchNo") | ||||
|     private String batchNo; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初数量 | ||||
|      */ | ||||
|     @TableField(value = "beginCount") | ||||
|     private Integer beginCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初价格 | ||||
|      */ | ||||
|     @TableField(value = "beginPrice") | ||||
|     private BigDecimal beginPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初金额 | ||||
|      */ | ||||
|     @TableField(value = "beginAmount") | ||||
|     private BigDecimal beginAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库数量 | ||||
|      */ | ||||
|     @TableField(value = "inCount") | ||||
|     private String inCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库价格 | ||||
|      */ | ||||
|     @TableField(value = "inPrice") | ||||
|     private BigDecimal inPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库金额 | ||||
|      */ | ||||
|     @TableField(value = "inAmount") | ||||
|     private String inAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库数量 | ||||
|      */ | ||||
|     @TableField(value = "outCount") | ||||
|     private String outCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库价格 | ||||
|      */ | ||||
|     @TableField(value = "outPrice") | ||||
|     private BigDecimal outPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库金额 | ||||
|      */ | ||||
|     @TableField(value = "outAmount") | ||||
|     private String outAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余数量 | ||||
|      */ | ||||
|     @TableField(value = "balanceCount") | ||||
|     private String balanceCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余价格 | ||||
|      */ | ||||
|     @TableField(value = "balancePrice") | ||||
|     private BigDecimal balancePrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余金额 | ||||
|      */ | ||||
|     @TableField(value = "balanceAmount") | ||||
|     private String balanceAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @TableField(value = "remark") | ||||
|     private String remark; | ||||
| 
 | ||||
|     /** | ||||
|      * 更新时间 | ||||
|      */ | ||||
|     @TableField(value = "updateTime") | ||||
|     private Date updateTime; | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,142 @@ | ||||
| package com.glxp.api.entity.inout; | ||||
| 
 | ||||
| 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.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 年 | ||||
|  */ | ||||
| @Data | ||||
| @TableName(value = "io_stat_year") | ||||
| public class IoStatYearEntity { | ||||
| 
 | ||||
|     @TableId(value = "id", type = IdType.AUTO) | ||||
|     private Integer id; | ||||
| 
 | ||||
|     /** | ||||
|      * 年度 | ||||
|      */ | ||||
|     @TableField(value = "`year`") | ||||
|     private Integer year; | ||||
| 
 | ||||
|     /** | ||||
|      * 物资编码主键 | ||||
|      */ | ||||
|     @TableField(value = "relIdFk") | ||||
|     private String relIdFk; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品DI | ||||
|      */ | ||||
|     @TableField(value = "nameCode") | ||||
|     private String nameCode; | ||||
| 
 | ||||
|     /** | ||||
|      * 产品名称 | ||||
|      */ | ||||
|     @TableField(value = "productName") | ||||
|     private String productName; | ||||
| 
 | ||||
|     /** | ||||
|      * 规格型号 | ||||
|      */ | ||||
|     @TableField(value = "ggxh") | ||||
|     private String ggxh; | ||||
| 
 | ||||
|     /** | ||||
|      * 批次号 | ||||
|      */ | ||||
|     @TableField(value = "batchNo") | ||||
|     private String batchNo; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初数量 | ||||
|      */ | ||||
|     @TableField(value = "beginCount") | ||||
|     private Integer beginCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初价格 | ||||
|      */ | ||||
|     @TableField(value = "beginPrice") | ||||
|     private BigDecimal beginPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 期初金额 | ||||
|      */ | ||||
|     @TableField(value = "beginAmount") | ||||
|     private BigDecimal beginAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库数量 | ||||
|      */ | ||||
|     @TableField(value = "inCount") | ||||
|     private String inCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库价格 | ||||
|      */ | ||||
|     @TableField(value = "inPrice") | ||||
|     private BigDecimal inPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 入库金额 | ||||
|      */ | ||||
|     @TableField(value = "inAmount") | ||||
|     private String inAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库数量 | ||||
|      */ | ||||
|     @TableField(value = "outCount") | ||||
|     private String outCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库价格 | ||||
|      */ | ||||
|     @TableField(value = "outPrice") | ||||
|     private BigDecimal outPrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 出库金额 | ||||
|      */ | ||||
|     @TableField(value = "outAmount") | ||||
|     private String outAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余数量 | ||||
|      */ | ||||
|     @TableField(value = "balanceCount") | ||||
|     private String balanceCount; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余价格 | ||||
|      */ | ||||
|     @TableField(value = "balancePrice") | ||||
|     private BigDecimal balancePrice; | ||||
| 
 | ||||
|     /** | ||||
|      * 结余金额 | ||||
|      */ | ||||
|     @TableField(value = "balanceAmount") | ||||
|     private String balanceAmount; | ||||
| 
 | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @TableField(value = "remark") | ||||
|     private String remark; | ||||
| 
 | ||||
|     /** | ||||
|      * 更新时间 | ||||
|      */ | ||||
|     @TableField(value = "updateTime") | ||||
|     private Date updateTime; | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,16 @@ | ||||
| package com.glxp.api.service.inout; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 天 Service | ||||
|  */ | ||||
| public interface IoStatDayService { | ||||
| 
 | ||||
|     /** | ||||
|      * 统计出入库汇总数据 | ||||
|      * | ||||
|      * @param date | ||||
|      */ | ||||
|     void statData(Date date); | ||||
| } | ||||
| @ -0,0 +1,17 @@ | ||||
| package com.glxp.api.service.inout; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 月 Service | ||||
|  */ | ||||
| public interface IoStatMonthService { | ||||
| 
 | ||||
|     /** | ||||
|      * 统计出入库汇总数据 | ||||
|      * | ||||
|      * @param date | ||||
|      */ | ||||
|     void statData(Date date); | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,7 @@ | ||||
| package com.glxp.api.service.inout; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 总表 Service | ||||
|  */ | ||||
| public interface IoStatOrderService { | ||||
| } | ||||
| @ -0,0 +1,17 @@ | ||||
| package com.glxp.api.service.inout; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 季度 Service | ||||
|  */ | ||||
| public interface IoStatQuarterService { | ||||
| 
 | ||||
|     /** | ||||
|      * 统计出入库汇总数据 | ||||
|      * | ||||
|      * @param date | ||||
|      */ | ||||
|     void statData(Date date); | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,17 @@ | ||||
| package com.glxp.api.service.inout; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总 - 年 Service | ||||
|  */ | ||||
| public interface IoStatYearService { | ||||
| 
 | ||||
|     /** | ||||
|      * 统计出入库汇总数据 | ||||
|      * | ||||
|      * @param date | ||||
|      */ | ||||
|     void statData(Date date); | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,97 @@ | ||||
| package com.glxp.api.service.inout.impl; | ||||
| 
 | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.glxp.api.constant.ConstantType; | ||||
| import com.glxp.api.dao.inout.IoOrderDao; | ||||
| import com.glxp.api.dao.inout.IoOrderDetailResultDao; | ||||
| import com.glxp.api.dao.inout.IoStatDayDao; | ||||
| import com.glxp.api.entity.inout.IoOrderDetailResultEntity; | ||||
| import com.glxp.api.entity.inout.IoOrderEntity; | ||||
| import com.glxp.api.entity.inout.IoStatDayEntity; | ||||
| import com.glxp.api.service.inout.IoStatDayService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.CopyOnWriteArrayList; | ||||
| 
 | ||||
| @Slf4j | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class IoStatDayServiceImpl implements IoStatDayService { | ||||
| 
 | ||||
|     @Resource | ||||
|     private IoStatDayDao statDayDao; | ||||
|     @Resource | ||||
|     private IoOrderDetailResultDao ioOrderDetailResultDao; | ||||
|     @Resource | ||||
|     private IoOrderDao orderDao; | ||||
| 
 | ||||
|     @Override | ||||
|     public void statData(Date date) { | ||||
|         //汇总前一天的数据
 | ||||
|         DateTime yesterday = DateUtil.offsetDay(date, -1); | ||||
|         List<IoOrderDetailResultEntity> orderDetailResultEntities = ioOrderDetailResultDao.selectList(new QueryWrapper<IoOrderDetailResultEntity>() | ||||
|                 .select("orderIdFk", "bindRlFk", "nameCode", "batchNo", "productDate", "expireDate", "coName", "spec", "price", "count", "reCount") | ||||
|                 .between("createTime", DateUtil.beginOfDay(yesterday), DateUtil.endOfDay(yesterday))); | ||||
|         if (CollUtil.isNotEmpty(orderDetailResultEntities)) { | ||||
|             List<IoOrderDetailResultEntity> dataList = new CopyOnWriteArrayList<>(orderDetailResultEntities); | ||||
|             dataList.parallelStream().forEach(orderDetailResultEntity -> { | ||||
|                 //查询此产品前一天的数据
 | ||||
|                 IoStatDayEntity statDayEntity = statDayDao.selectOne(buildQueryWrapper(orderDetailResultEntity, yesterday)); | ||||
|                 if (null == statDayEntity) { | ||||
|                     //第一次汇总次产品数据
 | ||||
|                     statDayEntity = new IoStatDayEntity(); | ||||
|                     statDayEntity.setYear(yesterday.year()); | ||||
|                     statDayEntity.setMonth(yesterday.month()); | ||||
|                     statDayEntity.setDay(DateUtil.dayOfMonth(yesterday)); | ||||
|                     statDayEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk())); | ||||
|                     statDayEntity.setNameCode(orderDetailResultEntity.getNameCode()); | ||||
|                     statDayEntity.setProductName(orderDetailResultEntity.getCoName()); | ||||
|                     statDayEntity.setGgxh(orderDetailResultEntity.getSpec()); | ||||
|                     statDayEntity.setBatchNo(orderDetailResultEntity.getBatchNo()); | ||||
| 
 | ||||
|                     //设置期初数据
 | ||||
|                     statDayEntity.setBeginCount(0); | ||||
|                     statDayEntity.setBeginPrice(orderDetailResultEntity.getPrice()); | ||||
|                     statDayEntity.setBeginAmount(BigDecimal.ZERO); | ||||
|                     //查询此单是出库还是入库
 | ||||
|                     IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk())); | ||||
|                     if (order.getMainAction().equals(ConstantType.TYPE_PUT)) { | ||||
|                         //入库
 | ||||
|                         statDayEntity.setInCount(String.valueOf(orderDetailResultEntity.getReCount())); | ||||
|                         statDayEntity.setInPrice(orderDetailResultEntity.getPrice()); | ||||
|                         BigDecimal inAmount = orderDetailResultEntity.getPrice().multiply(BigDecimal.valueOf(orderDetailResultEntity.getReCount())); | ||||
|                         statDayEntity.setInAmount(inAmount.toString()); | ||||
| 
 | ||||
|                     } else if (order.getMainAction().equals(ConstantType.TYPE_OUT)) { | ||||
|                         //出库
 | ||||
| 
 | ||||
|                     } | ||||
| 
 | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private static QueryWrapper<IoStatDayEntity> buildQueryWrapper(IoOrderDetailResultEntity orderDetailResultEntity, DateTime yesterday) { | ||||
|         QueryWrapper<IoStatDayEntity> wrapper = new QueryWrapper<>(); | ||||
|         wrapper.eq("year", yesterday.year()) | ||||
|                 .eq("month", yesterday.month()) | ||||
|                 .eq("day", DateUtil.dayOfMonth(yesterday)) | ||||
|                 .eq("relIdFk", orderDetailResultEntity.getBindRlFk()) | ||||
|                 .eq(StrUtil.isNotBlank(orderDetailResultEntity.getBatchNo()), "batchNo", orderDetailResultEntity.getBatchNo()) | ||||
|                 .eq(StrUtil.isNotBlank(orderDetailResultEntity.getNameCode()), "nameCode", orderDetailResultEntity.getNameCode()); | ||||
|         return wrapper; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,18 @@ | ||||
| package com.glxp.api.service.inout.impl; | ||||
| 
 | ||||
| import com.glxp.api.service.inout.IoStatMonthService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| @Slf4j | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class IoStatMonthServiceImpl implements IoStatMonthService { | ||||
|     @Override | ||||
|     public void statData(Date date) { | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,12 @@ | ||||
| package com.glxp.api.service.inout.impl; | ||||
| 
 | ||||
| import com.glxp.api.service.inout.IoStatOrderService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| @Slf4j | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class IoStatOrderServiceImpl implements IoStatOrderService { | ||||
| } | ||||
| @ -0,0 +1,18 @@ | ||||
| package com.glxp.api.service.inout.impl; | ||||
| 
 | ||||
| import com.glxp.api.service.inout.IoStatQuarterService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| @Slf4j | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class IoStatQuarterServiceImpl implements IoStatQuarterService { | ||||
|     @Override | ||||
|     public void statData(Date date) { | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,18 @@ | ||||
| package com.glxp.api.service.inout.impl; | ||||
| 
 | ||||
| import com.glxp.api.service.inout.IoStatYearService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| @Slf4j | ||||
| @Service | ||||
| @Transactional(rollbackFor = Exception.class) | ||||
| public class IoStatYearServiceImpl implements IoStatYearService { | ||||
|     @Override | ||||
|     public void statData(Date date) { | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,90 @@ | ||||
| package com.glxp.api.task; | ||||
| 
 | ||||
| 
 | ||||
| import cn.hutool.core.thread.ThreadUtil; | ||||
| import com.glxp.api.dao.schedule.ScheduledDao; | ||||
| import com.glxp.api.entity.system.ScheduledEntity; | ||||
| import com.glxp.api.req.system.ScheduledRequest; | ||||
| import com.glxp.api.service.inout.IoStatDayService; | ||||
| import com.glxp.api.service.inout.IoStatMonthService; | ||||
| import com.glxp.api.service.inout.IoStatQuarterService; | ||||
| import com.glxp.api.service.inout.IoStatYearService; | ||||
| import com.glxp.api.util.DateUtil; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.scheduling.annotation.SchedulingConfigurer; | ||||
| import org.springframework.scheduling.config.ScheduledTaskRegistrar; | ||||
| import org.springframework.scheduling.support.CronTrigger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 物资出入库汇总定时任务 | ||||
|  */ | ||||
| @Slf4j | ||||
| @Component | ||||
| public class IoStatOrderTask implements SchedulingConfigurer { | ||||
| 
 | ||||
|     @Resource | ||||
|     private ScheduledDao scheduledDao; | ||||
|     @Resource | ||||
|     private IoStatDayService statDayService; | ||||
|     @Resource | ||||
|     private IoStatMonthService statMonthService; | ||||
|     @Resource | ||||
|     private IoStatQuarterService statQuarterService; | ||||
|     @Resource | ||||
|     private IoStatYearService statYearService; | ||||
| 
 | ||||
|     @Override | ||||
|     public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { | ||||
|         taskRegistrar.addTriggerTask(this::process, triggerContext -> { | ||||
|             ScheduledRequest scheduledRequest = new ScheduledRequest(); | ||||
|             scheduledRequest.setCronName("ioStatOrderTask"); | ||||
|             ScheduledEntity scheduled = scheduledDao.findScheduled(scheduledRequest); | ||||
|             if (null == scheduled) { | ||||
|                 log.info("物资出入库汇总定时任务未配置,请注意!"); | ||||
|                 return null; | ||||
|             } | ||||
|             String cron = scheduled.getCron(); | ||||
|             return new CronTrigger(cron).nextExecutionTime(triggerContext); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     private void process() { | ||||
|         log.info("开始汇总物资出入库数据"); | ||||
|         //生成每日汇总数据
 | ||||
|         Date today = new Date(); | ||||
|         ThreadUtil.execAsync(() -> { | ||||
|             log.info("开始生成每日物资出入库汇总数据"); | ||||
|             statDayService.statData(today); | ||||
|             log.info("每日物资出入库数据汇总生成结束"); | ||||
|         }); | ||||
| 
 | ||||
|         if (DateUtil.isMonthStart(today)) { | ||||
|             ThreadUtil.execAsync(() -> { | ||||
|                 log.info("本日为月初,生成月度物资出入库汇总数据"); | ||||
|                 statMonthService.statData(today); | ||||
|                 log.info("月度物资出入库汇总数据生成结束"); | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         if (DateUtil.isQuarterStart(today)) { | ||||
|             ThreadUtil.execAsync(() -> { | ||||
|                 log.info("本日为季初,生成季度物资出入库汇总数据"); | ||||
|                 statQuarterService.statData(today); | ||||
|                 log.info("季度物资出入库汇总数据生成结束"); | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         if (DateUtil.isYearStart(today)) { | ||||
|             ThreadUtil.execAsync(() -> { | ||||
|                 log.info("本日为年初,生成年度物资出入库汇总数据"); | ||||
|                 statYearService.statData(today); | ||||
|                 log.info("年度物资出入库汇总数据生成结束"); | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,5 @@ | ||||
| <?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.glxp.api.dao.inout.IoStatDayDao"> | ||||
| 
 | ||||
| </mapper> | ||||
| @ -0,0 +1,4 @@ | ||||
| <?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.glxp.api.dao.inout.IoStatMonthDao"> | ||||
| </mapper> | ||||
| @ -0,0 +1,4 @@ | ||||
| <?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.glxp.api.dao.inout.IoStatOrderDao"> | ||||
| </mapper> | ||||
| @ -0,0 +1,4 @@ | ||||
| <?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.glxp.api.dao.inout.IoStatQuarterDao"> | ||||
| </mapper> | ||||
| @ -0,0 +1,4 @@ | ||||
| <?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.glxp.api.dao.inout.IoStatYearDao"> | ||||
| </mapper> | ||||
					Loading…
					
					
				
		Reference in New Issue