汇总统计

test
anthonywj 1 year ago
parent 70323f2e5f
commit e319a9888d

@ -6,6 +6,7 @@ import com.glxp.api.req.inout.CptTraceRequest;
import com.glxp.api.req.inout.FilterOrderDetailResultRequest;
import com.glxp.api.res.inout.CptTraceOrderResponse;
import com.glxp.api.res.inout.IoOrderDetailResultResponse;
import com.glxp.api.res.inv.IoOrderDetailStatRsponse;
import io.lettuce.core.dynamic.annotation.Param;
import java.util.List;
@ -33,7 +34,7 @@ public interface IoOrderDetailResultDao extends BaseMapperPlus<IoOrderDetailBizD
*
* @return
*/
List<IoOrderDetailResultEntity> selectStatDataByTime(@Param("list") List<String> orderIdFk);
List<IoOrderDetailStatRsponse> selectStatDataByTime(@Param("list") List<String> orderIdFk);
List<CptTraceOrderResponse> cptTrace(CptTraceRequest cptTraceRequest);
}

@ -192,5 +192,6 @@ public class IoOrderDetailResultEntity {
@TableField(exist = false)
private String deptCode;
@TableField(exist = false)
private String invCode;
}

@ -166,7 +166,15 @@ public class IoStatDayEntity {
@TableField(value = "deptCode")
private String deptCode;
/**
*
*/
@TableField(value = "invCode")
private String invCode;
@TableField(exist = false)
private String deptName;
}
}

@ -160,6 +160,12 @@ public class IoStatMonthEntity {
@TableField(value = "deptCode")
private String deptCode;
/**
*
*/
@TableField(value = "invCode")
private String invCode;
@TableField(exist = false)
private String deptName;
}
}

@ -54,4 +54,17 @@ public class IoStatOrderEntity {
@TableField(value = "remark")
private String remark;
}
/**
*
*/
@TableField(value = "deptCode")
private String deptCode;
/**
*
*/
@TableField(value = "invCode")
private String invCode;
}

@ -154,7 +154,12 @@ public class IoStatQuarterEntity {
@TableField(value = "deptCode")
private String deptCode;
/**
*
*/
@TableField(value = "invCode")
private String invCode;
@TableField(exist = false)
private String deptName;
}
}

@ -147,9 +147,14 @@ public class IoStatYearEntity {
@TableField(value = "deptCode")
private String deptCode;
/**
*
*/
@TableField(value = "invCode")
private String invCode;
@TableField(exist = false)
private String deptName;
}
}

@ -0,0 +1,23 @@
package com.glxp.api.res.inv;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class IoOrderDetailStatRsponse {
private String mainAction;
private String orderIdFk;
private String bindRlFk;
private String nameCode;
private String batchNo;
private String coName;
private String spec;
private BigDecimal price;
private int reCount;
private String deptCode;
private String invCode;
}

@ -13,6 +13,7 @@ import com.glxp.api.dao.inout.IoStatDayDao;
import com.glxp.api.dao.inout.IoStatOrderDao;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.res.inv.IoOrderDetailStatRsponse;
import com.glxp.api.service.inout.IoStatDayService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
@ -58,9 +59,9 @@ public class IoStatDayServiceImpl implements IoStatDayService {
//查询单号
List<String> orderIdFkList = new ArrayList<>();
orderIdFkList = orderDao.selectOrderIdList(yesterday.toString("yyyy-MM-dd"));
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if(orderIdFkList.size()>0){
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
List<IoOrderDetailStatRsponse> orderDetailResultEntities = new ArrayList<>();
if (orderIdFkList.size() > 0) {
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
}
if (CollUtil.isNotEmpty(orderDetailResultEntities)) {
//声明用于存放汇总数据的集合
@ -69,7 +70,7 @@ public class IoStatDayServiceImpl implements IoStatDayService {
IoStatDayEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday);
//查询此单是出库还是入库
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode",orderDetailResultEntity.getDeptCode()));
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode", orderDetailResultEntity.getDeptCode()));
if (order.getMainAction().equals(ConstantType.TYPE_PUT)) {
//入库
statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount());
@ -95,8 +96,8 @@ public class IoStatDayServiceImpl implements IoStatDayService {
ew.eq("quarter", twoDay.quarter());
ew.eq("month", twoDay.monthBaseOne());
ew.eq("day", twoDay.dayOfMonth());
List<IoStatDayEntity> ioStatDayEntityList=statDayDao.selectList(ew);
List<IoStatDayEntity> newOrOldDate=getNewOrOldDate(dataList,ioStatDayEntityList,yesterday);
List<IoStatDayEntity> ioStatDayEntityList = statDayDao.selectList(ew);
List<IoStatDayEntity> newOrOldDate = getNewOrOldDate(dataList, ioStatDayEntityList, yesterday);
dataList.addAll(newOrOldDate);
//插入汇总记录
saveData(yesterday, dataList);
@ -126,7 +127,7 @@ public class IoStatDayServiceImpl implements IoStatDayService {
* @param orderDetailResultEntity
* @return
*/
private IoStatDayEntity getStatData(List<IoStatDayEntity> dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime yesterday) {
private IoStatDayEntity getStatData(List<IoStatDayEntity> dataList, IoOrderDetailStatRsponse orderDetailResultEntity, DateTime yesterday) {
if (CollUtil.isNotEmpty(dataList)) {
for (IoStatDayEntity statDayEntity : dataList) {
if (Long.valueOf(statDayEntity.getRelIdFk()).equals(orderDetailResultEntity.getBindRlFk()) && statDayEntity.getDeptCode().equals(orderDetailResultEntity.getDeptCode())) {
@ -183,7 +184,6 @@ public class IoStatDayServiceImpl implements IoStatDayService {
//设置结余价格
statData.setBalancePrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice());
dataList.add(statData);
return statData;
}
@ -191,45 +191,54 @@ public class IoStatDayServiceImpl implements IoStatDayService {
/**
*
*
* @param date
* @param dataList
* @param date
*/
private void saveData(Date date, List<IoStatDayEntity> dataList) {
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATD", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(4);
statOrderEntity.setDate(date);
statOrderEntity.setTitle(DateUtil.format(date, "yyyy-MM-dd") + " 日出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatDayDao mapper = sqlSession.getMapper(IoStatDayDao.class);
dataList.forEach(statDayEntity -> {
statDayEntity.setUpdateTime(updateTime);
statDayEntity.setRecordKeyFk(orderNo);
//计算结余数据
statDayEntity.setBalanceCount(statDayEntity.getBalanceCount() + statDayEntity.getInCount() - statDayEntity.getOutCount());
statDayEntity.setBalanceAmount(statDayEntity.getBalanceAmount().add(statDayEntity.getInAmount()).subtract(statDayEntity.getOutAmount()));
mapper.insert(statDayEntity);
});
sqlSession.commit();
sqlSession.close();
private void saveData(Date date, List<IoStatDayEntity> statDayEntities) {
Map<String, List<IoStatDayEntity>> stringListMap = statDayEntities.stream()
.collect(Collectors.groupingBy(IoStatDayEntity::getInvCode));
for (String key : stringListMap.keySet()) {
List<IoStatDayEntity> dataList = stringListMap.get(key);
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATD", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(4);
statOrderEntity.setInvCode(key);
statOrderEntity.setDate(date);
statOrderEntity.setTitle(DateUtil.format(date, "yyyy-MM-dd") + " 日出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatDayDao mapper = sqlSession.getMapper(IoStatDayDao.class);
dataList.forEach(statDayEntity -> {
statDayEntity.setUpdateTime(updateTime);
statDayEntity.setRecordKeyFk(orderNo);
//计算结余数据
statDayEntity.setBalanceCount(statDayEntity.getBalanceCount() + statDayEntity.getInCount() - statDayEntity.getOutCount());
statDayEntity.setBalanceAmount(statDayEntity.getBalanceAmount().add(statDayEntity.getInAmount()).subtract(statDayEntity.getOutAmount()));
mapper.insert(statDayEntity);
});
sqlSession.commit();
sqlSession.close();
}
}
private static QueryWrapper<IoStatDayEntity> buildQueryWrapper(IoOrderDetailResultEntity orderDetailResultEntity, DateTime yesterday) {
private static QueryWrapper<IoStatDayEntity> buildQueryWrapper(IoOrderDetailStatRsponse orderDetailResultEntity, DateTime yesterday) {
QueryWrapper<IoStatDayEntity> wrapper = new QueryWrapper<>();
DateTime dateTime =DateUtil.offsetDay(yesterday, -1); //取前天的时间
DateTime dateTime = DateUtil.offsetDay(yesterday, -1); //取前天的时间
wrapper.eq("year", dateTime.year())
.eq("month", dateTime.monthBaseOne())
.eq("day", dateTime.dayOfMonth()) //取前天的数据
@ -240,7 +249,7 @@ public class IoStatDayServiceImpl implements IoStatDayService {
return wrapper;
}
private List<IoStatDayEntity> getNewOrOldDate(List<IoStatDayEntity> newIoStatDayEntity, List<IoStatDayEntity> oldIoStatDayEntity,DateTime yesterday){
private List<IoStatDayEntity> getNewOrOldDate(List<IoStatDayEntity> newIoStatDayEntity, List<IoStatDayEntity> oldIoStatDayEntity, DateTime yesterday) {
// 计算出两个集合之间产品批次号组成的差异
List<IoStatDayEntity> IoStatDayEntityList = oldIoStatDayEntity.stream()

@ -13,6 +13,7 @@ import com.glxp.api.dao.schedule.SystemParamConfigDao;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.res.dev.DateRequest;
import com.glxp.api.res.inv.IoOrderDetailStatRsponse;
import com.glxp.api.service.inout.IoStatMonthService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
@ -55,14 +56,14 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
@Override
public void statData(Date date) {
DateTime lastMonth = DateUtil.offsetMonth(date,-1);
DateTime lastMonth = DateUtil.offsetMonth(date, -1);
DateRequest dateRequest1 = getfirstDayAndLastDay(lastMonth.year(), lastMonth.monthBaseOne());
List<IoStatMonthEntity> dataList = new ArrayList<>();
//查询单号
List<String> orderIdFkList = new ArrayList<>();
orderIdFkList = orderDao.selectOrderfirstAndLastIdList(dateRequest1.getFirstDay(), dateRequest1.getLastDay());
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if(orderIdFkList.size()>0){
List<IoOrderDetailStatRsponse> orderDetailResultEntities = new ArrayList<>();
if (orderIdFkList.size() > 0) {
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
}
@ -74,7 +75,7 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
IoStatMonthEntity statData = getStatData(dataList, orderDetailResultEntity, lastMonth);
//查询此单是出库还是入库
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode",orderDetailResultEntity.getDeptCode()));
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode", orderDetailResultEntity.getDeptCode()));
if (order.getMainAction().equals(ConstantType.TYPE_PUT)) {
//入库
statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount());
@ -102,8 +103,8 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
ew.eq("year", lastMonth.year())
.eq("month", lastMonth.monthBaseOne() - 1);//取上上月的数据
}
List<IoStatMonthEntity> ioStatMonthEntityList=statMonthDao.selectList(ew);
List<IoStatMonthEntity> newOrOldDate=getNewOrOldDate(dataList,ioStatMonthEntityList,lastMonth);
List<IoStatMonthEntity> ioStatMonthEntityList = statMonthDao.selectList(ew);
List<IoStatMonthEntity> newOrOldDate = getNewOrOldDate(dataList, ioStatMonthEntityList, lastMonth);
dataList.addAll(newOrOldDate);
//插入汇总记录
@ -130,39 +131,46 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
*
*
* @param lastMonth
* @param dataList
*/
private void saveData(DateTime lastMonth, List<IoStatMonthEntity> dataList) {
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATM", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(3);
statOrderEntity.setTitle(lastMonth.year() + " 年 " + lastMonth.monthBaseOne() + " 月出入库汇总");
DateUtil.offsetMonth(lastMonth,+1);
statOrderEntity.setDate(lastMonth);
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatMonthDao mapper = sqlSession.getMapper(IoStatMonthDao.class);
dataList.forEach(statMonthEntity -> {
statMonthEntity.setUpdateTime(updateTime);
statMonthEntity.setRecordKeyFk(orderNo);
//计算结余数据
statMonthEntity.setBalanceCount(statMonthEntity.getBalanceCount() + statMonthEntity.getInCount() - statMonthEntity.getOutCount());
statMonthEntity.setBalanceAmount(statMonthEntity.getBalanceAmount().add(statMonthEntity.getInAmount()).subtract(statMonthEntity.getOutAmount()));
mapper.insert(statMonthEntity);
});
sqlSession.commit();
sqlSession.close();
private void saveData(DateTime lastMonth, List<IoStatMonthEntity> statMonthEntities) {
Map<String, List<IoStatMonthEntity>> stringListMap = statMonthEntities.stream()
.collect(Collectors.groupingBy(IoStatMonthEntity::getInvCode));
for (String key : stringListMap.keySet()) {
List<IoStatMonthEntity> dataList = stringListMap.get(key);
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATM", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(3);
statOrderEntity.setTitle(lastMonth.year() + " 年 " + lastMonth.monthBaseOne() + " 月出入库汇总");
DateUtil.offsetMonth(lastMonth, +1);
statOrderEntity.setDate(lastMonth);
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatMonthDao mapper = sqlSession.getMapper(IoStatMonthDao.class);
dataList.forEach(statMonthEntity -> {
statMonthEntity.setUpdateTime(updateTime);
statMonthEntity.setRecordKeyFk(orderNo);
//计算结余数据
statMonthEntity.setBalanceCount(statMonthEntity.getBalanceCount() + statMonthEntity.getInCount() - statMonthEntity.getOutCount());
statMonthEntity.setBalanceAmount(statMonthEntity.getBalanceAmount().add(statMonthEntity.getInAmount()).subtract(statMonthEntity.getOutAmount()));
mapper.insert(statMonthEntity);
});
sqlSession.commit();
sqlSession.close();
}
}
/**
@ -173,7 +181,7 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
* @param lastMonth
* @return
*/
private IoStatMonthEntity getStatData(List<IoStatMonthEntity> dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime lastMonth) {
private IoStatMonthEntity getStatData(List<IoStatMonthEntity> dataList, IoOrderDetailStatRsponse orderDetailResultEntity, DateTime lastMonth) {
if (CollUtil.isNotEmpty(dataList)) {
for (IoStatMonthEntity statDayEntity : dataList) {
@ -242,7 +250,7 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
* @param lastMonth
* @return
*/
private Wrapper<IoStatMonthEntity> buildQueryWrapper(IoOrderDetailResultEntity ioOrderDetailResultEntity, DateTime lastMonth) {
private Wrapper<IoStatMonthEntity> buildQueryWrapper(IoOrderDetailStatRsponse ioOrderDetailResultEntity, DateTime lastMonth) {
QueryWrapper<IoStatMonthEntity> wrapper = new QueryWrapper<>();
if (lastMonth.monthBaseOne() == 1) {
//当前汇总的记录为1月上一月份的时间取前一年的12月

@ -10,6 +10,7 @@ import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.inout.*;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.res.inv.IoOrderDetailStatRsponse;
import com.glxp.api.service.inout.IoStatQuarterService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
@ -54,15 +55,15 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
//查询上一季度各个月度的数据
int quarter = yesterday.quarter();
int year = yesterday.year();
String topDate=getStartDayOfQuarter(year,quarter);
String lastDate=getLastDayOfQuarter(year,quarter);
String topDate = getStartDayOfQuarter(year, quarter);
String lastDate = getLastDayOfQuarter(year, quarter);
//查询单号
List<String> orderIdFkList = new ArrayList<>();
//汇总上一个季度的数据
List<IoStatQuarterEntity> dataList = new ArrayList<>();
orderIdFkList = orderDao.selectOrderfirstAndLastIdList(lastDate, topDate);
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if(orderIdFkList.size()>0){
List<IoOrderDetailStatRsponse> orderDetailResultEntities = new ArrayList<>();
if (orderIdFkList.size() > 0) {
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
}
@ -73,7 +74,7 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
IoStatQuarterEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday);
//查询此单是出库还是入库
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode",orderDetailResultEntity.getDeptCode()));
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode", orderDetailResultEntity.getDeptCode()));
if (order.getMainAction().equals(ConstantType.TYPE_PUT)) {
//入库
statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount());
@ -95,9 +96,9 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
//获取上上天的数据
QueryWrapper<IoStatQuarterEntity> ew = new QueryWrapper<>();
ew.eq("year", yesterday.year());
ew.eq("quarter", yesterday.quarter()-1);
List<IoStatQuarterEntity> ioStatMonthEntityList=statQuarterDao.selectList(ew);
List<IoStatQuarterEntity> newOrOldDate=getNewOrOldDate(dataList,ioStatMonthEntityList,yesterday);
ew.eq("quarter", yesterday.quarter() - 1);
List<IoStatQuarterEntity> ioStatMonthEntityList = statQuarterDao.selectList(ew);
List<IoStatQuarterEntity> newOrOldDate = getNewOrOldDate(dataList, ioStatMonthEntityList, yesterday);
dataList.addAll(newOrOldDate);
@ -127,40 +128,48 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
*
*
* @param yesterday
* @param dataList
*/
private void saveData(DateTime yesterday, List<IoStatQuarterEntity> dataList) {
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATQ", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(2);
DateTime dateTime=DateUtil.offsetDay(yesterday,+1);
statOrderEntity.setDate(dateTime);
statOrderEntity.setTitle(yesterday.year() + " 年 " + yesterday.quarter() + " 季度出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatQuarterDao mapper = sqlSession.getMapper(IoStatQuarterDao.class);
dataList.forEach(statQuarterEntity -> {
statQuarterEntity.setUpdateTime(updateTime);
statQuarterEntity.setRecordKeyFk(orderNo);
//设置结余数据
statQuarterEntity.setBalanceCount(statQuarterEntity.getBalanceCount() + statQuarterEntity.getInCount() - statQuarterEntity.getOutCount());
statQuarterEntity.setBalanceAmount(statQuarterEntity.getBalanceAmount().add(statQuarterEntity.getInAmount()).subtract(statQuarterEntity.getOutAmount()));
mapper.insert(statQuarterEntity);
});
sqlSession.commit();
sqlSession.close();
private void saveData(DateTime yesterday, List<IoStatQuarterEntity> statQuarterEntities) {
Map<String, List<IoStatQuarterEntity>> stringListMap = statQuarterEntities.stream()
.collect(Collectors.groupingBy(IoStatQuarterEntity::getInvCode));
for (String key : stringListMap.keySet()) {
List<IoStatQuarterEntity> dataList = stringListMap.get(key);
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATQ", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(2);
DateTime dateTime = DateUtil.offsetDay(yesterday, +1);
statOrderEntity.setDate(dateTime);
statOrderEntity.setTitle(yesterday.year() + " 年 " + yesterday.quarter() + " 季度出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatQuarterDao mapper = sqlSession.getMapper(IoStatQuarterDao.class);
dataList.forEach(statQuarterEntity -> {
statQuarterEntity.setUpdateTime(updateTime);
statQuarterEntity.setRecordKeyFk(orderNo);
//设置结余数据
statQuarterEntity.setBalanceCount(statQuarterEntity.getBalanceCount() + statQuarterEntity.getInCount() - statQuarterEntity.getOutCount());
statQuarterEntity.setBalanceAmount(statQuarterEntity.getBalanceAmount().add(statQuarterEntity.getInAmount()).subtract(statQuarterEntity.getOutAmount()));
mapper.insert(statQuarterEntity);
});
sqlSession.commit();
sqlSession.close();
}
}
/**
@ -171,7 +180,7 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
* @param yesterday
* @return
*/
private IoStatQuarterEntity getStatData(List<IoStatQuarterEntity> dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime yesterday) {
private IoStatQuarterEntity getStatData(List<IoStatQuarterEntity> dataList, IoOrderDetailStatRsponse orderDetailResultEntity, DateTime yesterday) {
if (CollUtil.isNotEmpty(dataList)) {
for (IoStatQuarterEntity statDayEntity : dataList) {
@ -238,7 +247,7 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
* @param yesterday
* @return
*/
private QueryWrapper<IoStatQuarterEntity> buildQueryWrapper(IoOrderDetailResultEntity ioOrderDetailResultEntity, DateTime yesterday) {
private QueryWrapper<IoStatQuarterEntity> buildQueryWrapper(IoOrderDetailStatRsponse ioOrderDetailResultEntity, DateTime yesterday) {
QueryWrapper<IoStatQuarterEntity> wrapper = new QueryWrapper<>();
if (yesterday.quarter() == 1) {
//当前汇总的记录为第一季度,上一季度时间取前一年的第四季度数据
@ -274,7 +283,7 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
// 创建 SimpleDateFormat 对象,用于格式化日期时间
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// 使用 SimpleDateFormat 格式化 Calendar 对象,得到格式化之后的字符串
// 使用 SimpleDateFormat 格式化 Calendar 对象,得到格式化之后的字符串
String dateString = df.format(cal.getTime());
return dateString;
@ -329,7 +338,7 @@ public class IoStatQuarterServiceImpl implements IoStatQuarterService {
ioStatDayEntity.setBeginCount(ioStatDayEntity.getBalanceCount());
ioStatDayEntity.setBeginAmount(ioStatDayEntity.getBalanceAmount());
ioStatDayEntity.setBeginPrice(ioStatDayEntity.getBalancePrice());
ioStatDayEntity.setQuarter(ioStatDayEntity.getQuarter()+1);
ioStatDayEntity.setQuarter(ioStatDayEntity.getQuarter() + 1);
ioStatDayEntity.setInAmount(new BigDecimal(0));
ioStatDayEntity.setOutAmount(new BigDecimal(0));
ioStatDayEntity.setInCount(0);

@ -10,6 +10,7 @@ import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.inout.*;
import com.glxp.api.entity.inout.*;
import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.res.inv.IoOrderDetailStatRsponse;
import com.glxp.api.service.inout.IoStatYearService;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean;
@ -55,9 +56,9 @@ public class IoStatYearServiceImpl implements IoStatYearService {
//查询单号
List<String> orderIdFkList = new ArrayList<>();
//汇总上一个季度的数据
orderIdFkList = orderDao.selectOrderfirstAndLastIdList(yesterday.year()+"-12-31", yesterday.year()+"-01-01");
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if(orderIdFkList.size()>0){
orderIdFkList = orderDao.selectOrderfirstAndLastIdList(yesterday.year() + "-12-31", yesterday.year() + "-01-01");
List<IoOrderDetailStatRsponse> orderDetailResultEntities = new ArrayList<>();
if (orderIdFkList.size() > 0) {
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
}
@ -68,7 +69,7 @@ public class IoStatYearServiceImpl implements IoStatYearService {
IoStatYearEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday);
//查询此单是出库还是入库
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode",orderDetailResultEntity.getDeptCode()));
IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()).eq("deptCode", orderDetailResultEntity.getDeptCode()));
if (order.getMainAction().equals(ConstantType.TYPE_PUT)) {
//入库
statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount());
@ -89,9 +90,9 @@ public class IoStatYearServiceImpl implements IoStatYearService {
//汇总上一季度存在上上一季度不存在产品的汇总数据
//获取上上天的数据
QueryWrapper<IoStatYearEntity> ew = new QueryWrapper<>();
ew.eq("year", yesterday.year()-1);
List<IoStatYearEntity> ioStatMonthEntityList=statYearDao.selectList(ew);
List<IoStatYearEntity> newOrOldDate=getNewOrOldDate(dataList,ioStatMonthEntityList,yesterday);
ew.eq("year", yesterday.year() - 1);
List<IoStatYearEntity> ioStatMonthEntityList = statYearDao.selectList(ew);
List<IoStatYearEntity> newOrOldDate = getNewOrOldDate(dataList, ioStatMonthEntityList, yesterday);
dataList.addAll(newOrOldDate);
@ -120,39 +121,48 @@ public class IoStatYearServiceImpl implements IoStatYearService {
*
*
* @param yesterday
* @param dataList
*/
private void saveData(DateTime yesterday, List<IoStatYearEntity> dataList) {
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATY", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(1);
DateTime dateTime=DateUtil.offsetDay(yesterday,+1);
statOrderEntity.setDate(dateTime);
statOrderEntity.setTitle(yesterday.year() + " 年度出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatYearDao mapper = sqlSession.getMapper(IoStatYearDao.class);
dataList.forEach(statYearEntity -> {
statYearEntity.setUpdateTime(updateTime);
statYearEntity.setRecordKeyFk(orderNo);
//设置结余数据
statYearEntity.setBalanceCount(statYearEntity.getBalanceCount() + statYearEntity.getInCount() - statYearEntity.getOutCount());
statYearEntity.setBalanceAmount(statYearEntity.getBalanceAmount().add(statYearEntity.getInAmount()).subtract(statYearEntity.getOutAmount()));
mapper.insert(statYearEntity);
});
sqlSession.commit();
sqlSession.close();
private void saveData(DateTime yesterday, List<IoStatYearEntity> statYearEntities) {
Map<String, List<IoStatYearEntity>> stringListMap = statYearEntities.stream()
.collect(Collectors.groupingBy(IoStatYearEntity::getInvCode));
for (String key : stringListMap.keySet()) {
List<IoStatYearEntity> dataList = stringListMap.get(key);
//生成汇总记录
IoStatOrderEntity statOrderEntity = new IoStatOrderEntity();
//生成记录号
OrderNoTypeBean orderNoTypeBean = new OrderNoTypeBean("STATY", "yyyyMMdd");
String orderNo = gennerOrderUtils.createStatOrderNo(orderNoTypeBean);
statOrderEntity.setRecordKey(orderNo);
statOrderEntity.setType(1);
DateTime dateTime = DateUtil.offsetDay(yesterday, +1);
statOrderEntity.setDate(dateTime);
statOrderEntity.setTitle(yesterday.year() + " 年度出入库汇总");
Date updateTime = new Date();
statOrderEntity.setUpdateTime(updateTime);
statOrderDao.insert(statOrderEntity);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
IoStatYearDao mapper = sqlSession.getMapper(IoStatYearDao.class);
dataList.forEach(statYearEntity -> {
statYearEntity.setUpdateTime(updateTime);
statYearEntity.setRecordKeyFk(orderNo);
//设置结余数据
statYearEntity.setBalanceCount(statYearEntity.getBalanceCount() + statYearEntity.getInCount() - statYearEntity.getOutCount());
statYearEntity.setBalanceAmount(statYearEntity.getBalanceAmount().add(statYearEntity.getInAmount()).subtract(statYearEntity.getOutAmount()));
mapper.insert(statYearEntity);
});
sqlSession.commit();
sqlSession.close();
}
}
/**
@ -163,7 +173,7 @@ public class IoStatYearServiceImpl implements IoStatYearService {
* @param yesterday
* @return
*/
private IoStatYearEntity getStatData(List<IoStatYearEntity> dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime yesterday) {
private IoStatYearEntity getStatData(List<IoStatYearEntity> dataList, IoOrderDetailStatRsponse orderDetailResultEntity, DateTime yesterday) {
if (CollUtil.isNotEmpty(dataList)) {
for (IoStatYearEntity statDayEntity : dataList) {
@ -229,7 +239,7 @@ public class IoStatYearServiceImpl implements IoStatYearService {
* @param ioOrderDetailResultEntity
* @param yesterday
*/
private QueryWrapper<IoStatYearEntity> buildQueryWrapper(IoOrderDetailResultEntity ioOrderDetailResultEntity, DateTime yesterday) {
private QueryWrapper<IoStatYearEntity> buildQueryWrapper(IoOrderDetailStatRsponse ioOrderDetailResultEntity, DateTime yesterday) {
QueryWrapper<IoStatYearEntity> wrapper = new QueryWrapper<>();
wrapper.eq("year", yesterday.year() - 1);
wrapper.eq("relIdFk", ioOrderDetailResultEntity.getBindRlFk());
@ -275,7 +285,7 @@ public class IoStatYearServiceImpl implements IoStatYearService {
ioStatDayEntity.setBeginCount(ioStatDayEntity.getBalanceCount());
ioStatDayEntity.setBeginAmount(ioStatDayEntity.getBalanceAmount());
ioStatDayEntity.setBeginPrice(ioStatDayEntity.getBalancePrice());
ioStatDayEntity.setYear(ioStatDayEntity.getYear()+1);
ioStatDayEntity.setYear(ioStatDayEntity.getYear() + 1);
ioStatDayEntity.setInAmount(new BigDecimal(0));
ioStatDayEntity.setOutAmount(new BigDecimal(0));
ioStatDayEntity.setInCount(0);

@ -663,5 +663,4 @@
</otherwise>
</choose>
</select>
</mapper>

@ -27,8 +27,8 @@
SELECT a2.*,
a1.mainAction,
a1.auditTime,
b1.NAME AS fromCorpName,
(select name from auth_warehouse aw where aw.code= a1.fromInvCode) as fromInvName,
b1.NAME AS fromCorpName,
(select name from auth_warehouse aw where aw.code = a1.fromInvCode) as fromInvName,
(SELECT NAME FROM basic_bussiness_type bus WHERE bus.action = a1.action) billTypeName
FROM io_order_detail_result a2
LEFT JOIN io_order a1 ON a1.billNo = a2.orderIdFk
@ -92,7 +92,7 @@
</where>
</select>
<select id="selectStatDataByTime" resultType="com.glxp.api.entity.inout.IoOrderDetailResultEntity">
<select id="selectStatDataByTime" resultType="com.glxp.api.res.inv.IoOrderDetailStatRsponse">
select orderIdFk,
bindRlFk,
nameCode,
@ -101,12 +101,13 @@
spec,
price,
reCount,
io_order.deptCode
io_order.deptCode,
io_order.invCode
from io_order_detail_result
left JOIN io_order on io_order.billNo=io_order_detail_result.orderIdFk
left JOIN io_order on io_order.billNo = io_order_detail_result.orderIdFk
<where>
<if test="list != null and list.size() > 0 ">
orderIdFk in
<if test="list != null and list.size() > 0">
and io_order_detail_result.orderIdFk in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
@ -119,19 +120,19 @@
<select id="cptTrace" parameterType="com.glxp.api.req.inout.CptTraceRequest"
resultType="com.glxp.api.res.inout.CptTraceOrderResponse">
select io.billNo,
io.createTime,
io.mainAction,
bbt.`name` billType,
basic_corp.`name` fromCorpName,
basic_corp.creditNo,
basic_corp.outType,
basic_corp.corpType,
io.action,
io.fromInvCode
io.createTime,
io.mainAction,
bbt.`name` billType,
basic_corp.`name` fromCorpName,
basic_corp.creditNo,
basic_corp.outType,
basic_corp.corpType,
io.action,
io.fromInvCode
from io_order_detail_result iodr
INNER JOIN io_order io on iodr.orderIdFk = io.billNo
inner join basic_corp on io.fromCorp = basic_corp.erpId
INNER JOIN basic_bussiness_type bbt on io.action = bbt.action
INNER JOIN io_order io on iodr.orderIdFk = io.billNo
inner join basic_corp on io.fromCorp = basic_corp.erpId
INNER JOIN basic_bussiness_type bbt on io.action = bbt.action
<where>
and bbt.inStock = true
<if test="batchNo != null and batchNo != ''">

@ -19,5 +19,4 @@
</if>
</where>
</select>
</mapper>
</mapper>

@ -997,3 +997,9 @@ CALL Pro_Temp_ColumnWork('inv_count_codes', 'expireDate', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('inv_count_codes', 'serialNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('inv_count_order', 'codeCount', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_stat_order', 'deptCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_stat_day', 'invCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_stat_month', 'invCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_stat_quarter', 'invCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_stat_year', 'invCode', 'varchar(255)', 1);

Loading…
Cancel
Save