Merge remote-tracking branch 'origin/dev' into dev

pro
anthonywj 2 years ago
commit 0f93175ce0

@ -70,4 +70,9 @@ public interface IoOrderDao extends BaseMapperPlus<IoOrderDao, IoOrderEntity, Io
List<String> selectWaitSubmitOrder(@Param("thirdSys") String thirdSys); List<String> selectWaitSubmitOrder(@Param("thirdSys") String thirdSys);
boolean updateOrder(IoOrderEntity orderEntity); boolean updateOrder(IoOrderEntity orderEntity);
List<String> selectOrderIdList(@Param("data") String data);
List<String> selectOrderfirstAndLastIdList(@Param("firstData") String firstData,@Param("lastData") String lastData);
} }

@ -31,5 +31,5 @@ public interface IoOrderDetailResultDao extends BaseMapperPlus<IoOrderDetailBizD
* *
* @return * @return
*/ */
List<IoOrderDetailResultEntity> selectStatDataByTime(@Param("date") String date); List<IoOrderDetailResultEntity> selectStatDataByTime(@Param("list") List<String> orderIdFk);
} }

@ -0,0 +1,12 @@
package com.glxp.api.res.inv;
import lombok.Data;
@Data
public class DateRequest {
private String firstDay;
private String lastDay;
private int year;
private int momth;
}

@ -7,6 +7,7 @@ import com.glxp.api.req.inout.FilterOrderRequest;
import com.glxp.api.req.inout.FilterUploadOrderRequest; import com.glxp.api.req.inout.FilterUploadOrderRequest;
import com.glxp.api.req.inout.OrderEditRequest; import com.glxp.api.req.inout.OrderEditRequest;
import com.glxp.api.res.inout.IoOrderResponse; import com.glxp.api.res.inout.IoOrderResponse;
import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -137,4 +138,6 @@ public interface IoOrderService {
BaseResponse submitOrderToThrSys(ThrSystemDetailEntity thrSystemDetailEntity); BaseResponse submitOrderToThrSys(ThrSystemDetailEntity thrSystemDetailEntity);
List<IoOrderEntity> selectList(Long userId); List<IoOrderEntity> selectList(Long userId);
List<String> selectOrderIdList(@Param("data") String data);
} }

@ -869,6 +869,11 @@ public class IoOrderServiceImpl implements IoOrderService {
return ioOrderEntities; return ioOrderEntities;
} }
@Override
public List<String> selectOrderIdList(String data) {
return orderDao.selectOrderIdList(data);
}
/** /**
* *
* *

@ -11,10 +11,7 @@ import com.glxp.api.dao.inout.IoOrderDao;
import com.glxp.api.dao.inout.IoOrderDetailResultDao; import com.glxp.api.dao.inout.IoOrderDetailResultDao;
import com.glxp.api.dao.inout.IoStatDayDao; import com.glxp.api.dao.inout.IoStatDayDao;
import com.glxp.api.dao.inout.IoStatOrderDao; import com.glxp.api.dao.inout.IoStatOrderDao;
import com.glxp.api.entity.inout.IoOrderDetailResultEntity; import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.entity.inout.IoStatDayEntity;
import com.glxp.api.entity.inout.IoStatOrderEntity;
import com.glxp.api.req.inout.FilterStatDataDetailRequest; import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.service.inout.IoStatDayService; import com.glxp.api.service.inout.IoStatDayService;
import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.GennerOrderUtils;
@ -29,10 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.time.LocalDate;
import java.util.Collections; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@ -52,14 +49,21 @@ public class IoStatDayServiceImpl implements IoStatDayService {
@Resource @Resource
private SqlSessionFactory sqlSessionFactory; private SqlSessionFactory sqlSessionFactory;
@Override @Override
public void statData(Date date) { public void statData(Date date) {
//汇总前一天的数据 //汇总前一天的数据9
DateTime yesterday = DateUtil.offsetDay(date, -1); DateTime yesterday = DateUtil.offsetDay(date, -1);
List<IoOrderDetailResultEntity> orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(yesterday.toString("yyyy-MM-dd")); List<IoStatDayEntity> dataList = new ArrayList<>();
//查询单号
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);
}
if (CollUtil.isNotEmpty(orderDetailResultEntities)) { if (CollUtil.isNotEmpty(orderDetailResultEntities)) {
//声明用于存放汇总数据的集合 //声明用于存放汇总数据的集合
List<IoStatDayEntity> dataList = new ArrayList<>();
orderDetailResultEntities.forEach(orderDetailResultEntity -> { orderDetailResultEntities.forEach(orderDetailResultEntity -> {
//获取新的汇总数据 //获取新的汇总数据
IoStatDayEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday); IoStatDayEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday);
@ -83,6 +87,17 @@ public class IoStatDayServiceImpl implements IoStatDayService {
} }
}); });
//汇总上一天存在上上一天不存在产品的汇总数据
//获取上上天的数据
DateTime twoDay = DateUtil.offsetDay(date, -2);
QueryWrapper<IoStatDayEntity> ew = new QueryWrapper<>();
ew.eq("year", twoDay.year());
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);
dataList.addAll(newOrOldDate);
//插入汇总记录 //插入汇总记录
saveData(yesterday, dataList); saveData(yesterday, dataList);
} }
@ -100,7 +115,7 @@ public class IoStatDayServiceImpl implements IoStatDayService {
} }
@Override @Override
public List<IoStatDayEntity> filterListByRecordKey(String recordKey) { public List<IoStatDayEntity> filterListByRecordKey(String recordKey) {
return statDayDao.filterListByRecordKey(recordKey); return statDayDao.filterListByRecordKey(recordKey);
} }
@ -223,4 +238,26 @@ public class IoStatDayServiceImpl implements IoStatDayService {
return wrapper; return wrapper;
} }
private List<IoStatDayEntity> getNewOrOldDate(List<IoStatDayEntity> newIoStatDayEntity, List<IoStatDayEntity> oldIoStatDayEntity){
// 计算出两个集合之间产品批次号组成的差异
List<IoStatDayEntity> IoStatDayEntityList = oldIoStatDayEntity.stream()
.filter(notComment -> {
List<IoStatDayEntity> filtered = newIoStatDayEntity.stream().filter(all ->
Objects.equals(all.getBatchNo(), notComment.getBatchNo()) // 使用 Objects.equals 来进行非空判断
&& Objects.equals(all.getRelIdFk(), notComment.getRelIdFk()))
.collect(Collectors.toList());
return filtered.isEmpty();
}).collect(Collectors.toList());
for (IoStatDayEntity ioStatDayEntity : IoStatDayEntityList) {
ioStatDayEntity.setId(null);
ioStatDayEntity.setBeginCount(ioStatDayEntity.getBalanceCount());
ioStatDayEntity.setBalanceAmount(ioStatDayEntity.getBalanceAmount());
ioStatDayEntity.setBeginPrice(ioStatDayEntity.getBalancePrice());
ioStatDayEntity.setInCount(0);
ioStatDayEntity.setOutCount(0);
}
return IoStatDayEntityList;
}
} }

@ -7,13 +7,11 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.inout.IoStatDayDao; import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.inout.IoStatMonthDao; import com.glxp.api.dao.inout.*;
import com.glxp.api.dao.inout.IoStatOrderDao; import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inout.IoStatDayEntity;
import com.glxp.api.entity.inout.IoStatMonthEntity;
import com.glxp.api.entity.inout.IoStatOrderEntity;
import com.glxp.api.req.inout.FilterStatDataDetailRequest; import com.glxp.api.req.inout.FilterStatDataDetailRequest;
import com.glxp.api.res.inv.DateRequest;
import com.glxp.api.service.inout.IoStatMonthService; import com.glxp.api.service.inout.IoStatMonthService;
import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.OrderNoTypeBean; import com.glxp.api.util.OrderNoTypeBean;
@ -27,7 +25,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@ -44,36 +45,65 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
private IoStatOrderDao statOrderDao; private IoStatOrderDao statOrderDao;
@Resource @Resource
private SqlSessionFactory sqlSessionFactory; private SqlSessionFactory sqlSessionFactory;
@Resource
private IoOrderDao orderDao;
@Resource
private IoOrderDetailResultDao ioOrderDetailResultDao;
@Override @Override
public void statData(Date date) { public void statData(Date date) {
//汇总上一个月的数据
DateTime lastMonth = DateUtil.lastMonth(); DateTime lastMonth = DateUtil.lastMonth();
//查询上个月每天的汇总数据 //汇总上一个月的数据
List<IoStatDayEntity> statDayList = statDayDao.selectList(new QueryWrapper<IoStatDayEntity>() DateRequest dateRequest = getYearAndMonth(1);
.eq("year", lastMonth.year()) DateRequest dateRequest1 = getfirstDayAndLastDay(dateRequest.getYear(), dateRequest.getMomth());
.eq("quarter", lastMonth.quarter()) List<IoStatMonthEntity> dataList = new ArrayList<>();
.eq("month", lastMonth.monthBaseOne()) //查询单号
); List<String> orderIdFkList = new ArrayList<>();
orderIdFkList = orderDao.selectOrderfirstAndLastIdList(dateRequest1.getFirstDay(), dateRequest1.getLastDay());
if (CollUtil.isNotEmpty(statDayList)) { List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
if(orderIdFkList.size()>0){
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
}
if (CollUtil.isNotEmpty(orderDetailResultEntities)) {
//声明用于存放汇总数据的集合 //声明用于存放汇总数据的集合
List<IoStatMonthEntity> dataList = new ArrayList<>(); orderDetailResultEntities.forEach(orderDetailResultEntity -> {
statDayList.forEach(statDayEntity -> {
//获取新的汇总数据 //获取新的汇总数据
IoStatMonthEntity statData = getStatData(dataList, statDayEntity, lastMonth); IoStatMonthEntity statData = getStatData(dataList, orderDetailResultEntity, lastMonth);
//设置入库数据 //查询此单是出库还是入库
statData.setInCount(statData.getInCount() + statDayEntity.getInCount()); IoOrderEntity order = orderDao.selectOne(new QueryWrapper<IoOrderEntity>().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk()));
statData.setInPrice(statDayEntity.getBalancePrice()); if (order.getMainAction().equals(ConstantType.TYPE_PUT)) {
statData.setInAmount(statData.getInAmount().add(statDayEntity.getInAmount())); //入库
statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount());
//设置出库数据 if (null != orderDetailResultEntity.getPrice()) {
statData.setOutCount(statData.getOutCount() + statDayEntity.getOutCount()); BigDecimal inAmount = orderDetailResultEntity.getPrice().multiply(BigDecimal.valueOf(orderDetailResultEntity.getReCount()));
statData.setOutPrice(statDayEntity.getBalancePrice()); statData.setInAmount(inAmount.add(statData.getInAmount()));
statData.setOutAmount(statData.getOutAmount().add(statDayEntity.getOutAmount())); }
} else if (order.getMainAction().equals(ConstantType.TYPE_OUT)) {
//出库
statData.setOutCount(orderDetailResultEntity.getReCount() + statData.getOutCount());
if (null != orderDetailResultEntity.getPrice()) {
BigDecimal outAmount = orderDetailResultEntity.getPrice().multiply(BigDecimal.valueOf(orderDetailResultEntity.getReCount()));
statData.setOutAmount(outAmount.add(statData.getOutAmount()));
}
}
}); });
//汇总上一天存在上上一天不存在产品的汇总数据
//获取上上天的数据
DateTime twoDay = new DateTime();
QueryWrapper<IoStatMonthEntity> ew = new QueryWrapper<>();
ew.eq("year", twoDay.year());
ew.eq("quarter", twoDay.quarter());
ew.eq("month", twoDay.monthBaseOne()-2);
List<IoStatMonthEntity> ioStatMonthEntityList=statMonthDao.selectList(ew);
List<IoStatMonthEntity> newOrOldDate=getNewOrOldDate(dataList,ioStatMonthEntityList);
dataList.addAll(newOrOldDate);
//插入汇总记录 //插入汇总记录
saveData(lastMonth, dataList); saveData(lastMonth, dataList);
} }
@ -137,19 +167,20 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
* *
* *
* @param dataList * @param dataList
* @param statDayEntity * @param orderDetailResultEntity
* @param lastMonth * @param lastMonth
* @return * @return
*/ */
private IoStatMonthEntity getStatData(List<IoStatMonthEntity> dataList, IoStatDayEntity statDayEntity, DateTime lastMonth) { private IoStatMonthEntity getStatData(List<IoStatMonthEntity> dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime lastMonth) {
if (CollUtil.isNotEmpty(dataList)) { if (CollUtil.isNotEmpty(dataList)) {
for (IoStatMonthEntity statMonthEntity : dataList) { for (IoStatMonthEntity statDayEntity : dataList) {
if (statMonthEntity.getRelIdFk().equals(statDayEntity.getRelIdFk())) { if (Long.valueOf(statDayEntity.getRelIdFk()).equals(orderDetailResultEntity.getBindRlFk())) {
if ((StrUtil.isNotBlank(statMonthEntity.getBatchNo()) && StrUtil.isNotBlank(statDayEntity.getRelIdFk())) && statMonthEntity.getBatchNo().equals(statDayEntity.getBatchNo())) { if ((StrUtil.isNotBlank(statDayEntity.getBatchNo()) && StrUtil.isNotBlank(orderDetailResultEntity.getBatchNo())) && statDayEntity.getBatchNo().equals(orderDetailResultEntity.getBatchNo())) {
return statMonthEntity; return statDayEntity;
} else if (StrUtil.isBlank(statDayEntity.getBatchNo()) && StrUtil.isBlank(orderDetailResultEntity.getBatchNo())) {
return statDayEntity;
} }
} else if (StrUtil.isBlank(statMonthEntity.getBatchNo()) && StrUtil.isBlank(statDayEntity.getBatchNo())) {
return statMonthEntity;
} }
} }
} }
@ -158,28 +189,28 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
statData.setYear(lastMonth.year()); statData.setYear(lastMonth.year());
statData.setQuarter(lastMonth.quarter()); statData.setQuarter(lastMonth.quarter());
statData.setMonth(lastMonth.monthBaseOne()); statData.setMonth(lastMonth.monthBaseOne());
statData.setRelIdFk(statDayEntity.getRelIdFk()); statData.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk()));
statData.setNameCode(statDayEntity.getNameCode()); statData.setNameCode(orderDetailResultEntity.getNameCode());
statData.setProductName(statDayEntity.getProductName()); statData.setProductName(orderDetailResultEntity.getCoName());
statData.setGgxh(statDayEntity.getGgxh()); statData.setGgxh(orderDetailResultEntity.getSpec());
statData.setBatchNo(statDayEntity.getBatchNo()); statData.setBatchNo(orderDetailResultEntity.getBatchNo());
//设置结余价格 //设置结余价格
statData.setBalancePrice(statDayEntity.getBalancePrice()); statData.setBalancePrice(orderDetailResultEntity.getPrice());
//设置初始化出入库数量和价格 //设置初始化出入库数量和价格
statData.setInCount(0); statData.setInCount(0);
statData.setInPrice(statDayEntity.getInPrice()); statData.setInPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice());
statData.setInAmount(BigDecimal.ZERO); statData.setInAmount(BigDecimal.ZERO);
statData.setOutCount(0); statData.setOutCount(0);
statData.setOutPrice(statDayEntity.getOutPrice()); statData.setOutPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice());
statData.setOutAmount(BigDecimal.ZERO); statData.setOutAmount(BigDecimal.ZERO);
//设置期初数据 //设置期初数据
IoStatMonthEntity statMonthEntity = statMonthDao.selectOne(buildQueryWrapper(statDayEntity, lastMonth)); IoStatMonthEntity statMonthEntity = statMonthDao.selectOne(buildQueryWrapper(orderDetailResultEntity, lastMonth));
if (null == statMonthEntity) { if (null == statMonthEntity) {
//第一次汇总月度数据 //第一次汇总月度数据
statData.setBeginCount(0); statData.setBeginCount(0);
statData.setBeginPrice(statDayEntity.getBalancePrice()); statData.setBeginPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice());
statData.setBeginAmount(BigDecimal.ZERO); statData.setBeginAmount(BigDecimal.ZERO);
statData.setBalanceCount(0); statData.setBalanceCount(0);
@ -190,12 +221,12 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
statData.setBeginPrice(statMonthEntity.getBalancePrice()); statData.setBeginPrice(statMonthEntity.getBalancePrice());
statData.setBeginAmount(statMonthEntity.getBalanceAmount()); statData.setBeginAmount(statMonthEntity.getBalanceAmount());
statData.setBalanceCount(statDayEntity.getBalanceCount()); statData.setBalanceCount(statMonthEntity.getBalanceCount());
statData.setBalanceAmount(statMonthEntity.getBalanceAmount()); statData.setBalanceAmount(statMonthEntity.getBalanceAmount());
} }
//设置结余价格 //设置结余价格
statData.setBalancePrice(statDayEntity.getBalancePrice()); statData.setBalancePrice(statData.getBeginPrice());
dataList.add(statData); dataList.add(statData);
return statData; return statData;
@ -204,11 +235,11 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
/** /**
* *
* *
* @param statDayEntity * @param ioOrderDetailResultEntity
* @param lastMonth * @param lastMonth
* @return * @return
*/ */
private Wrapper<IoStatMonthEntity> buildQueryWrapper(IoStatDayEntity statDayEntity, DateTime lastMonth) { private Wrapper<IoStatMonthEntity> buildQueryWrapper(IoOrderDetailResultEntity ioOrderDetailResultEntity, DateTime lastMonth) {
QueryWrapper<IoStatMonthEntity> wrapper = new QueryWrapper<>(); QueryWrapper<IoStatMonthEntity> wrapper = new QueryWrapper<>();
if (lastMonth.monthBaseOne() == 1) { if (lastMonth.monthBaseOne() == 1) {
//当前汇总的记录为1月上一月份的时间取前一年的12月 //当前汇总的记录为1月上一月份的时间取前一年的12月
@ -219,9 +250,68 @@ public class IoStatMonthServiceImpl implements IoStatMonthService {
.eq("month", lastMonth.monthBaseOne() - 1);//取上上月的数据 .eq("month", lastMonth.monthBaseOne() - 1);//取上上月的数据
} }
wrapper.eq("relIdFk", statDayEntity.getRelIdFk()) wrapper.eq("relIdFk", ioOrderDetailResultEntity.getBindRlFk());
.eq(StrUtil.isNotBlank(statDayEntity.getBatchNo()), "batchNo", statDayEntity.getBatchNo()) wrapper.eq(StrUtil.isNotBlank(ioOrderDetailResultEntity.getBatchNo()), "batchNo", ioOrderDetailResultEntity.getBatchNo());
.eq(StrUtil.isNotBlank(statDayEntity.getNameCode()), "nameCode", statDayEntity.getNameCode()); wrapper.eq(StrUtil.isNotBlank(ioOrderDetailResultEntity.getNameCode()), "nameCode", ioOrderDetailResultEntity.getNameCode());
return wrapper; return wrapper;
} }
private List<IoStatMonthEntity> getNewOrOldDate(List<IoStatMonthEntity> newIoStatDayEntity, List<IoStatMonthEntity> oldIoStatDayEntity) {
// 计算出两个集合之间产品批次号组成的差异
// List<IoStatMonthEntity> ioStatMonthEntityList = oldIoStatDayEntity.stream().filter(notComment -> {
// List<IoStatMonthEntity> filtered = newIoStatDayEntity.stream().filter(all -> all.getBatchNo().equals(notComment.getBatchNo()) && all.getRelIdFk().equals(notComment.getRelIdFk())).collect(Collectors.toList());
// return filtered.isEmpty();
// }).collect(Collectors.toList());
List<IoStatMonthEntity> ioStatMonthEntityList = oldIoStatDayEntity.stream()
.filter(notComment -> {
List<IoStatMonthEntity> filtered = newIoStatDayEntity.stream().filter(all ->
Objects.equals(all.getBatchNo(), notComment.getBatchNo()) // 使用 Objects.equals 来进行非空判断
&& Objects.equals(all.getRelIdFk(), notComment.getRelIdFk()))
.collect(Collectors.toList());
return filtered.isEmpty();
}).collect(Collectors.toList());
for (IoStatMonthEntity ioStatDayEntity : ioStatMonthEntityList) {
ioStatDayEntity.setId(null);
ioStatDayEntity.setBeginCount(ioStatDayEntity.getBalanceCount());
ioStatDayEntity.setBalanceAmount(ioStatDayEntity.getBalanceAmount());
ioStatDayEntity.setBeginPrice(ioStatDayEntity.getBalancePrice());
ioStatDayEntity.setInCount(0);
ioStatDayEntity.setOutCount(0);
}
return ioStatMonthEntityList;
}
//获取目标月份的起始和结束时间
private DateRequest getfirstDayAndLastDay(int year, int month) {
LocalDate firstDayOfMonth = LocalDate.of(year, month, 1);
LocalDate lastDayOfMonth = firstDayOfMonth.withDayOfMonth(firstDayOfMonth.lengthOfMonth());
String pattern = "yyyy-MM-dd";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
DateRequest dateRequest = new DateRequest();
dateRequest.setLastDay(firstDayOfMonth.format(formatter));
dateRequest.setFirstDay(lastDayOfMonth.format(formatter));
return dateRequest;
}
//获取指定的月份和年份
private DateRequest getYearAndMonth(int lastNum) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR); // 获取当前年份
int month = calendar.get(Calendar.MONTH) + 1 - lastNum;
if (month < 1) { // 如果当前是一月份,则上一个月份是去年 12 月
year--;
month = 12 - month;
}
DateRequest dateRequest = new DateRequest();
dateRequest.setYear(year);
dateRequest.setMomth(month);
return dateRequest;
}
} }

@ -3,7 +3,9 @@ package com.glxp.api.task;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import com.glxp.api.dao.schedule.ScheduledDao; import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.dao.schedule.SystemParamConfigDao;
import com.glxp.api.entity.system.ScheduledEntity; import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.req.system.ScheduledRequest; import com.glxp.api.req.system.ScheduledRequest;
import com.glxp.api.service.inout.IoStatDayService; import com.glxp.api.service.inout.IoStatDayService;
import com.glxp.api.service.inout.IoStatMonthService; import com.glxp.api.service.inout.IoStatMonthService;
@ -17,6 +19,8 @@ import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
/** /**
@ -36,6 +40,8 @@ public class IoStatOrderTask implements SchedulingConfigurer {
private IoStatQuarterService statQuarterService; private IoStatQuarterService statQuarterService;
@Resource @Resource
private IoStatYearService statYearService; private IoStatYearService statYearService;
@Resource
private SystemParamConfigDao systemParamConfigDao;
@Override @Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
@ -53,7 +59,15 @@ public class IoStatOrderTask implements SchedulingConfigurer {
} }
private void process() { private void process() {
Date today = new Date(); SystemParamConfigEntity systemParamConfigEntity=systemParamConfigDao.selectByParamKey("date");
String name=systemParamConfigEntity.getParamValue();
Date today1 = new Date();
try {
today1 = new SimpleDateFormat("yyyy-MM-dd").parse(name);
} catch (ParseException e) {
e.printStackTrace();
}
Date today = today1;
//判断起始时间,设置生成递进顺序,保证日汇总数据优先生成,否则后续数据的源数据会发生缺失,导致计算错误 //判断起始时间,设置生成递进顺序,保证日汇总数据优先生成,否则后续数据的源数据会发生缺失,导致计算错误
if (DateUtil.isYearStart(today)) { if (DateUtil.isYearStart(today)) {
//年初第一天,依次生成 日 -> 月 -> 季度 -> 年度 汇总数据 //年初第一天,依次生成 日 -> 月 -> 季度 -> 年度 汇总数据

@ -54,10 +54,12 @@
AND relKey = #{relKey} AND relKey = #{relKey}
</if> </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if> </if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''"> <if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and date_format(#{endAduditTime}, '%Y-%m-%d') AND date_format(auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and
date_format(#{endAduditTime}, '%Y-%m-%d')
</if> </if>
<if test="actions != null and actions.size() != 0"> <if test="actions != null and actions.size() != 0">
AND `action` in AND `action` in
@ -139,27 +141,27 @@
<select id="getfilterList" resultType="com.glxp.api.res.inout.IoOrderResponse"> <select id="getfilterList" resultType="com.glxp.api.res.inout.IoOrderResponse">
select io.*, select io.*,
(select name from basic_bussiness_type bus where bus.action = io.action) billTypeName, (select name from basic_bussiness_type bus where bus.action = io.action) billTypeName,
(select name from auth_dept ad where ad.code = io.deptCode) deptName, (select name from auth_dept ad where ad.code = io.deptCode) deptName,
(select name from auth_warehouse aw where aw.code = io.invCode) invName, (select name from auth_warehouse aw where aw.code = io.invCode) invName,
(select employeeName from auth_user au where au.id = io.createUser) createUserName, (select employeeName from auth_user au where au.id = io.createUser) createUserName,
(select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName, (select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName,
(select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName, (select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName,
(select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName, (select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName,
(select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName, (select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName,
(select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName, (select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName,
(select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName, (select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName,
(select name from basic_corp bc where bc.erpId = io.customerId) customerName, (select name from basic_corp bc where bc.erpId = io.customerId) customerName,
(SELECT count(*) (SELECT count(*)
FROM io_order_detail_code FROM io_order_detail_code
WHERE io_order_detail_code.orderIdFk = io.billNo WHERE io_order_detail_code.orderIdFk = io.billNo
and io_order_detail_code.regStatus = 1 and io_order_detail_code.regStatus = 1
) AS allCout, ) AS allCout,
(SELECT count(*) (SELECT count(*)
FROM io_order_detail_code FROM io_order_detail_code
WHERE io_order_detail_code.orderIdFk = io.billNo WHERE io_order_detail_code.orderIdFk = io.billNo
and io_order_detail_code.regStatus = 0 and io_order_detail_code.regStatus = 0
) As partCount ) As partCount
from io_order as io from io_order as io
<where> <where>
<if test="id != null and id != ''"> <if test="id != null and id != ''">
@ -167,7 +169,7 @@
</if> </if>
<if test="corpName != null and corpName != ''"> <if test="corpName != null and corpName != ''">
AND (SELECT NAME FROM auth_warehouse aw2 WHERE aw2.CODE = io.fromInvCode) like AND (SELECT NAME FROM auth_warehouse aw2 WHERE aw2.CODE = io.fromInvCode) like
concat('%', #{corpName}, '%') concat('%', #{corpName}, '%')
</if> </if>
<if test="action != null and action != ''"> <if test="action != null and action != ''">
AND action = #{action} AND action = #{action}
@ -201,11 +203,11 @@
</if> </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d') date_format(#{endTime}, '%Y-%m-%d')
</if> </if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''"> <if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and AND date_format(auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and
date_format(#{endAduditTime}, '%Y-%m-%d') date_format(#{endAduditTime}, '%Y-%m-%d')
</if> </if>
<if test="actions != null and actions.size() != 0"> <if test="actions != null and actions.size() != 0">
AND `action` in AND `action` in
@ -257,12 +259,12 @@
<if test="invoiceActions1 == null and invoiceActions2 != null"> <if test="invoiceActions1 == null and invoiceActions2 != null">
and ( and (
`action` in `action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=","> <foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
and status = 7 and status = 7
) )
</if> </if>
<if test="invoiceActions1 != null and invoiceActions2 != null"> <if test="invoiceActions1 != null and invoiceActions2 != null">
@ -271,13 +273,13 @@
#{item} #{item}
</foreach> </foreach>
and status = 10) and status = 10)
or ( or (
`action` in `action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=","> <foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
and status = 7) and status = 7)
) )
</if> </if>
</if> </if>
</where> </where>
@ -326,7 +328,7 @@
</if> </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d') date_format(#{endTime}, '%Y-%m-%d')
</if> </if>
<if test="lastUpdateTime != null and lastUpdateTime != ''"> <if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[ <![CDATA[
@ -357,17 +359,17 @@
<select id="selectUploadOrder" resultType="com.glxp.api.res.inout.IoOrderResponse"> <select id="selectUploadOrder" resultType="com.glxp.api.res.inout.IoOrderResponse">
select io.*, select io.*,
(select name from basic_bussiness_type bus where bus.action = io.action) billTypeName, (select name from basic_bussiness_type bus where bus.action = io.action) billTypeName,
(select name from auth_dept ad where ad.code = io.deptCode) deptName, (select name from auth_dept ad where ad.code = io.deptCode) deptName,
(select name from auth_warehouse aw where aw.code = io.invCode) invName, (select name from auth_warehouse aw where aw.code = io.invCode) invName,
(select employeeName from auth_user au where au.id = io.createUser) createUserName, (select employeeName from auth_user au where au.id = io.createUser) createUserName,
(select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName, (select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName,
(select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName, (select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName,
(select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName, (select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName,
(select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName, (select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName,
(select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName, (select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName,
(select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName, (select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName,
(select name from basic_corp bc where bc.erpId = io.customerId) customerName (select name from basic_corp bc where bc.erpId = io.customerId) customerName
from io_order as io from io_order as io
<where> <where>
io.dealStatus = 3 io.dealStatus = 3
@ -388,7 +390,7 @@
</if> </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d') date_format(#{endTime}, '%Y-%m-%d')
</if> </if>
<if test="startTime != null and startTime != '' and (endTime == null or endTime == '')"> <if test="startTime != null and startTime != '' and (endTime == null or endTime == '')">
AND date_format(createTime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') AND date_format(createTime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d')
@ -415,10 +417,10 @@
<select id="selectWaitSubmitOrder" resultType="java.lang.String"> <select id="selectWaitSubmitOrder" resultType="java.lang.String">
select t.billNo select t.billNo
from io_order t from io_order t
left join thr_system_bus_api t1 on t.action = t1.code left join thr_system_bus_api t1 on t.action = t1.code
<where> <where>
t.status = 7 t.status = 7
and exportStatus = 0 and exportStatus = 0
<if test="thirdSys != null and thirdSys != ''"> <if test="thirdSys != null and thirdSys != ''">
AND t1.thirdSys = #{thirdSys} AND t1.thirdSys = #{thirdSys}
</if> </if>
@ -435,4 +437,23 @@
</trim> </trim>
WHERE billNo = #{billNo} WHERE billNo = #{billNo}
</update> </update>
<select id="selectOrderIdList" resultType="java.lang.String">
SELECT billNo
FROM io_order
LEFT JOIN basic_bussiness_type ON io_order.action = basic_bussiness_type.action
WHERE basic_bussiness_type.inStock = 1
and io_order.`status` = 7
AND date_format(io_order.updateTime, '%Y-%m-%d') = date_format(#{data},'%Y-%m-%d')
</select>
<select id="selectOrderfirstAndLastIdList" resultType="java.lang.String">
SELECT billNo
FROM io_order
LEFT JOIN basic_bussiness_type ON io_order.action = basic_bussiness_type.action
WHERE basic_bussiness_type.inStock = 1
and io_order.`status` = 7
AND date_format(io_order.updateTime, '%Y-%m-%d') between date_format(#{lastData}, '%Y-%m-%d') and
date_format(#{firstData}, '%Y-%m-%d')
</select>
</mapper> </mapper>

@ -86,7 +86,14 @@
price, price,
reCount reCount
from io_order_detail_result from io_order_detail_result
where orderIdFk in <where>
(select billNo from io_order where date_format(updateTime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')) <if test="list != null and list.size() > 0 ">
orderIdFk in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save