diff --git a/src/main/java/com/glxp/api/dao/inout/IoOrderDao.java b/src/main/java/com/glxp/api/dao/inout/IoOrderDao.java index eae776426..4755e859d 100644 --- a/src/main/java/com/glxp/api/dao/inout/IoOrderDao.java +++ b/src/main/java/com/glxp/api/dao/inout/IoOrderDao.java @@ -70,4 +70,9 @@ public interface IoOrderDao extends BaseMapperPlus selectWaitSubmitOrder(@Param("thirdSys") String thirdSys); boolean updateOrder(IoOrderEntity orderEntity); + + List selectOrderIdList(@Param("data") String data); + + List selectOrderfirstAndLastIdList(@Param("firstData") String firstData,@Param("lastData") String lastData); + } diff --git a/src/main/java/com/glxp/api/dao/inout/IoOrderDetailResultDao.java b/src/main/java/com/glxp/api/dao/inout/IoOrderDetailResultDao.java index dc8c808b1..d4548eb7a 100644 --- a/src/main/java/com/glxp/api/dao/inout/IoOrderDetailResultDao.java +++ b/src/main/java/com/glxp/api/dao/inout/IoOrderDetailResultDao.java @@ -31,5 +31,5 @@ public interface IoOrderDetailResultDao extends BaseMapperPlus selectStatDataByTime(@Param("date") String date); + List selectStatDataByTime(@Param("list") List orderIdFk); } diff --git a/src/main/java/com/glxp/api/res/inv/DateRequest.java b/src/main/java/com/glxp/api/res/inv/DateRequest.java new file mode 100644 index 000000000..c153d7a71 --- /dev/null +++ b/src/main/java/com/glxp/api/res/inv/DateRequest.java @@ -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; +} diff --git a/src/main/java/com/glxp/api/service/inout/IoOrderService.java b/src/main/java/com/glxp/api/service/inout/IoOrderService.java index 80a5af315..a9e69f313 100644 --- a/src/main/java/com/glxp/api/service/inout/IoOrderService.java +++ b/src/main/java/com/glxp/api/service/inout/IoOrderService.java @@ -7,6 +7,7 @@ import com.glxp.api.req.inout.FilterOrderRequest; import com.glxp.api.req.inout.FilterUploadOrderRequest; import com.glxp.api.req.inout.OrderEditRequest; import com.glxp.api.res.inout.IoOrderResponse; +import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; @@ -137,4 +138,6 @@ public interface IoOrderService { BaseResponse submitOrderToThrSys(ThrSystemDetailEntity thrSystemDetailEntity); List selectList(Long userId); + + List selectOrderIdList(@Param("data") String data); } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java index dc579d6dc..d780f4888 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java @@ -869,6 +869,11 @@ public class IoOrderServiceImpl implements IoOrderService { return ioOrderEntities; } + @Override + public List selectOrderIdList(String data) { + return orderDao.selectOrderIdList(data); + } + /** * 查询此单据关联的所有单据 * diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoStatDayServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoStatDayServiceImpl.java index f6eb7bb96..68840468e 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoStatDayServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoStatDayServiceImpl.java @@ -11,10 +11,7 @@ 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.dao.inout.IoStatOrderDao; -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.entity.inout.IoStatOrderEntity; +import com.glxp.api.entity.inout.*; import com.glxp.api.req.inout.FilterStatDataDetailRequest; import com.glxp.api.service.inout.IoStatDayService; import com.glxp.api.util.GennerOrderUtils; @@ -29,10 +26,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; @Slf4j @Service @@ -52,14 +49,21 @@ public class IoStatDayServiceImpl implements IoStatDayService { @Resource private SqlSessionFactory sqlSessionFactory; + @Override public void statData(Date date) { - //汇总前一天的数据 + //汇总前一天的数据9 DateTime yesterday = DateUtil.offsetDay(date, -1); - List orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(yesterday.toString("yyyy-MM-dd")); + List dataList = new ArrayList<>(); + //查询单号 + List orderIdFkList = new ArrayList<>(); + orderIdFkList = orderDao.selectOrderIdList(yesterday.toString("yyyy-MM-dd")); + List orderDetailResultEntities = new ArrayList<>(); + if(orderIdFkList.size()>0){ + orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList); + } if (CollUtil.isNotEmpty(orderDetailResultEntities)) { //声明用于存放汇总数据的集合 - List dataList = new ArrayList<>(); orderDetailResultEntities.forEach(orderDetailResultEntity -> { //获取新的汇总数据 IoStatDayEntity statData = getStatData(dataList, orderDetailResultEntity, yesterday); @@ -83,6 +87,17 @@ public class IoStatDayServiceImpl implements IoStatDayService { } }); + //汇总上一天存在上上一天不存在产品的汇总数据 + //获取上上天的数据 + DateTime twoDay = DateUtil.offsetDay(date, -2); + QueryWrapper ew = new QueryWrapper<>(); + ew.eq("year", twoDay.year()); + ew.eq("quarter", twoDay.quarter()); + ew.eq("month", twoDay.monthBaseOne()); + ew.eq("day", twoDay.dayOfMonth()); + List ioStatDayEntityList=statDayDao.selectList(ew); + List newOrOldDate=getNewOrOldDate(dataList,ioStatDayEntityList); + dataList.addAll(newOrOldDate); //插入汇总记录 saveData(yesterday, dataList); } @@ -100,7 +115,7 @@ public class IoStatDayServiceImpl implements IoStatDayService { } @Override - public List filterListByRecordKey(String recordKey) { + public List filterListByRecordKey(String recordKey) { return statDayDao.filterListByRecordKey(recordKey); } @@ -223,4 +238,26 @@ public class IoStatDayServiceImpl implements IoStatDayService { return wrapper; } + private List getNewOrOldDate(List newIoStatDayEntity, List oldIoStatDayEntity){ + + // 计算出两个集合之间产品批次号组成的差异 + List IoStatDayEntityList = oldIoStatDayEntity.stream() + .filter(notComment -> { + List 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; + } } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoStatMonthServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoStatMonthServiceImpl.java index 9120efa99..8e0d41973 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoStatMonthServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoStatMonthServiceImpl.java @@ -7,13 +7,11 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; -import com.glxp.api.dao.inout.IoStatDayDao; -import com.glxp.api.dao.inout.IoStatMonthDao; -import com.glxp.api.dao.inout.IoStatOrderDao; -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.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.DateRequest; import com.glxp.api.service.inout.IoStatMonthService; import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.OrderNoTypeBean; @@ -27,7 +25,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; @Slf4j @Service @@ -44,36 +45,65 @@ public class IoStatMonthServiceImpl implements IoStatMonthService { private IoStatOrderDao statOrderDao; @Resource private SqlSessionFactory sqlSessionFactory; + @Resource + private IoOrderDao orderDao; + @Resource + private IoOrderDetailResultDao ioOrderDetailResultDao; @Override public void statData(Date date) { - //汇总上一个月的数据 + DateTime lastMonth = DateUtil.lastMonth(); - //查询上个月每天的汇总数据 - List statDayList = statDayDao.selectList(new QueryWrapper() - .eq("year", lastMonth.year()) - .eq("quarter", lastMonth.quarter()) - .eq("month", lastMonth.monthBaseOne()) - ); - - if (CollUtil.isNotEmpty(statDayList)) { + //汇总上一个月的数据 + DateRequest dateRequest = getYearAndMonth(1); + DateRequest dateRequest1 = getfirstDayAndLastDay(dateRequest.getYear(), dateRequest.getMomth()); + List dataList = new ArrayList<>(); + //查询单号 + List orderIdFkList = new ArrayList<>(); + orderIdFkList = orderDao.selectOrderfirstAndLastIdList(dateRequest1.getFirstDay(), dateRequest1.getLastDay()); + List orderDetailResultEntities = new ArrayList<>(); + if(orderIdFkList.size()>0){ + orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList); + } + + + if (CollUtil.isNotEmpty(orderDetailResultEntities)) { //声明用于存放汇总数据的集合 - List dataList = new ArrayList<>(); - statDayList.forEach(statDayEntity -> { + orderDetailResultEntities.forEach(orderDetailResultEntity -> { //获取新的汇总数据 - IoStatMonthEntity statData = getStatData(dataList, statDayEntity, lastMonth); + IoStatMonthEntity statData = getStatData(dataList, orderDetailResultEntity, lastMonth); - //设置入库数据 - statData.setInCount(statData.getInCount() + statDayEntity.getInCount()); - statData.setInPrice(statDayEntity.getBalancePrice()); - statData.setInAmount(statData.getInAmount().add(statDayEntity.getInAmount())); - - //设置出库数据 - statData.setOutCount(statData.getOutCount() + statDayEntity.getOutCount()); - statData.setOutPrice(statDayEntity.getBalancePrice()); - statData.setOutAmount(statData.getOutAmount().add(statDayEntity.getOutAmount())); + //查询此单是出库还是入库 + IoOrderEntity order = orderDao.selectOne(new QueryWrapper().select("mainAction").eq("billNo", orderDetailResultEntity.getOrderIdFk())); + if (order.getMainAction().equals(ConstantType.TYPE_PUT)) { + //入库 + statData.setInCount(orderDetailResultEntity.getReCount() + statData.getInCount()); + if (null != orderDetailResultEntity.getPrice()) { + BigDecimal inAmount = orderDetailResultEntity.getPrice().multiply(BigDecimal.valueOf(orderDetailResultEntity.getReCount())); + statData.setInAmount(inAmount.add(statData.getInAmount())); + } + } 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 ew = new QueryWrapper<>(); + ew.eq("year", twoDay.year()); + ew.eq("quarter", twoDay.quarter()); + ew.eq("month", twoDay.monthBaseOne()-2); + List ioStatMonthEntityList=statMonthDao.selectList(ew); + List newOrOldDate=getNewOrOldDate(dataList,ioStatMonthEntityList); + dataList.addAll(newOrOldDate); + //插入汇总记录 saveData(lastMonth, dataList); } @@ -137,19 +167,20 @@ public class IoStatMonthServiceImpl implements IoStatMonthService { * 获取新的汇总数据 * * @param dataList - * @param statDayEntity + * @param orderDetailResultEntity * @param lastMonth * @return */ - private IoStatMonthEntity getStatData(List dataList, IoStatDayEntity statDayEntity, DateTime lastMonth) { + private IoStatMonthEntity getStatData(List dataList, IoOrderDetailResultEntity orderDetailResultEntity, DateTime lastMonth) { + if (CollUtil.isNotEmpty(dataList)) { - for (IoStatMonthEntity statMonthEntity : dataList) { - if (statMonthEntity.getRelIdFk().equals(statDayEntity.getRelIdFk())) { - if ((StrUtil.isNotBlank(statMonthEntity.getBatchNo()) && StrUtil.isNotBlank(statDayEntity.getRelIdFk())) && statMonthEntity.getBatchNo().equals(statDayEntity.getBatchNo())) { - return statMonthEntity; + for (IoStatMonthEntity statDayEntity : dataList) { + if (Long.valueOf(statDayEntity.getRelIdFk()).equals(orderDetailResultEntity.getBindRlFk())) { + if ((StrUtil.isNotBlank(statDayEntity.getBatchNo()) && StrUtil.isNotBlank(orderDetailResultEntity.getBatchNo())) && statDayEntity.getBatchNo().equals(orderDetailResultEntity.getBatchNo())) { + 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.setQuarter(lastMonth.quarter()); statData.setMonth(lastMonth.monthBaseOne()); - statData.setRelIdFk(statDayEntity.getRelIdFk()); - statData.setNameCode(statDayEntity.getNameCode()); - statData.setProductName(statDayEntity.getProductName()); - statData.setGgxh(statDayEntity.getGgxh()); - statData.setBatchNo(statDayEntity.getBatchNo()); + statData.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk())); + statData.setNameCode(orderDetailResultEntity.getNameCode()); + statData.setProductName(orderDetailResultEntity.getCoName()); + statData.setGgxh(orderDetailResultEntity.getSpec()); + statData.setBatchNo(orderDetailResultEntity.getBatchNo()); //设置结余价格 - statData.setBalancePrice(statDayEntity.getBalancePrice()); + statData.setBalancePrice(orderDetailResultEntity.getPrice()); //设置初始化出入库数量和价格 statData.setInCount(0); - statData.setInPrice(statDayEntity.getInPrice()); + statData.setInPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice()); statData.setInAmount(BigDecimal.ZERO); statData.setOutCount(0); - statData.setOutPrice(statDayEntity.getOutPrice()); + statData.setOutPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice()); statData.setOutAmount(BigDecimal.ZERO); //设置期初数据 - IoStatMonthEntity statMonthEntity = statMonthDao.selectOne(buildQueryWrapper(statDayEntity, lastMonth)); + IoStatMonthEntity statMonthEntity = statMonthDao.selectOne(buildQueryWrapper(orderDetailResultEntity, lastMonth)); if (null == statMonthEntity) { //第一次汇总月度数据 statData.setBeginCount(0); - statData.setBeginPrice(statDayEntity.getBalancePrice()); + statData.setBeginPrice(null == orderDetailResultEntity.getPrice() ? BigDecimal.ZERO : orderDetailResultEntity.getPrice()); statData.setBeginAmount(BigDecimal.ZERO); statData.setBalanceCount(0); @@ -190,12 +221,12 @@ public class IoStatMonthServiceImpl implements IoStatMonthService { statData.setBeginPrice(statMonthEntity.getBalancePrice()); statData.setBeginAmount(statMonthEntity.getBalanceAmount()); - statData.setBalanceCount(statDayEntity.getBalanceCount()); + statData.setBalanceCount(statMonthEntity.getBalanceCount()); statData.setBalanceAmount(statMonthEntity.getBalanceAmount()); } //设置结余价格 - statData.setBalancePrice(statDayEntity.getBalancePrice()); + statData.setBalancePrice(statData.getBeginPrice()); dataList.add(statData); return statData; @@ -204,11 +235,11 @@ public class IoStatMonthServiceImpl implements IoStatMonthService { /** * 构造查询条件 * - * @param statDayEntity + * @param ioOrderDetailResultEntity * @param lastMonth * @return */ - private Wrapper buildQueryWrapper(IoStatDayEntity statDayEntity, DateTime lastMonth) { + private Wrapper buildQueryWrapper(IoOrderDetailResultEntity ioOrderDetailResultEntity, DateTime lastMonth) { QueryWrapper wrapper = new QueryWrapper<>(); if (lastMonth.monthBaseOne() == 1) { //当前汇总的记录为1月,上一月份的时间取前一年的12月 @@ -219,9 +250,68 @@ public class IoStatMonthServiceImpl implements IoStatMonthService { .eq("month", lastMonth.monthBaseOne() - 1);//取上上月的数据 } - wrapper.eq("relIdFk", statDayEntity.getRelIdFk()) - .eq(StrUtil.isNotBlank(statDayEntity.getBatchNo()), "batchNo", statDayEntity.getBatchNo()) - .eq(StrUtil.isNotBlank(statDayEntity.getNameCode()), "nameCode", statDayEntity.getNameCode()); + wrapper.eq("relIdFk", ioOrderDetailResultEntity.getBindRlFk()); + wrapper.eq(StrUtil.isNotBlank(ioOrderDetailResultEntity.getBatchNo()), "batchNo", ioOrderDetailResultEntity.getBatchNo()); + wrapper.eq(StrUtil.isNotBlank(ioOrderDetailResultEntity.getNameCode()), "nameCode", ioOrderDetailResultEntity.getNameCode()); return wrapper; } + + private List getNewOrOldDate(List newIoStatDayEntity, List oldIoStatDayEntity) { + + // 计算出两个集合之间产品批次号组成的差异 +// List ioStatMonthEntityList = oldIoStatDayEntity.stream().filter(notComment -> { +// List 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 ioStatMonthEntityList = oldIoStatDayEntity.stream() + .filter(notComment -> { + List 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; + } + } diff --git a/src/main/java/com/glxp/api/task/IoStatOrderTask.java b/src/main/java/com/glxp/api/task/IoStatOrderTask.java index f2931a488..d1136cfb1 100644 --- a/src/main/java/com/glxp/api/task/IoStatOrderTask.java +++ b/src/main/java/com/glxp/api/task/IoStatOrderTask.java @@ -3,7 +3,9 @@ package com.glxp.api.task; import cn.hutool.core.thread.ThreadUtil; 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.SystemParamConfigEntity; import com.glxp.api.req.system.ScheduledRequest; import com.glxp.api.service.inout.IoStatDayService; import com.glxp.api.service.inout.IoStatMonthService; @@ -17,6 +19,8 @@ import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; /** @@ -36,6 +40,8 @@ public class IoStatOrderTask implements SchedulingConfigurer { private IoStatQuarterService statQuarterService; @Resource private IoStatYearService statYearService; + @Resource + private SystemParamConfigDao systemParamConfigDao; @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { @@ -53,7 +59,15 @@ public class IoStatOrderTask implements SchedulingConfigurer { } 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)) { //年初第一天,依次生成 日 -> 月 -> 季度 -> 年度 汇总数据 diff --git a/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml b/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml index d115f99c7..a13bd129f 100644 --- a/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml +++ b/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml @@ -54,10 +54,12 @@ AND relKey = #{relKey} - 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') - 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') AND `action` in @@ -139,27 +141,27 @@ select t.billNo 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 t.status = 7 - and exportStatus = 0 + and exportStatus = 0 AND t1.thirdSys = #{thirdSys} @@ -435,4 +437,23 @@ WHERE billNo = #{billNo} + + + + diff --git a/src/main/resources/mybatis/mapper/inout/IoOrderDetailResultDao.xml b/src/main/resources/mybatis/mapper/inout/IoOrderDetailResultDao.xml index 023f89c4d..9bb799ab7 100644 --- a/src/main/resources/mybatis/mapper/inout/IoOrderDetailResultDao.xml +++ b/src/main/resources/mybatis/mapper/inout/IoOrderDetailResultDao.xml @@ -86,7 +86,14 @@ price, reCount from io_order_detail_result - where orderIdFk in - (select billNo from io_order where date_format(updateTime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')) + + + orderIdFk in + + #{item} + + +