|
|
|
@ -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,8 +59,8 @@ 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){
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
@ -192,9 +192,16 @@ public class IoStatDayServiceImpl implements IoStatDayService {
|
|
|
|
|
* 保存日汇总数据到数据库
|
|
|
|
|
*
|
|
|
|
|
* @param date 生成日期
|
|
|
|
|
* @param dataList 数据集合
|
|
|
|
|
*/
|
|
|
|
|
private void saveData(Date date, List<IoStatDayEntity> dataList) {
|
|
|
|
|
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();
|
|
|
|
|
//生成记录号
|
|
|
|
@ -202,12 +209,12 @@ public class IoStatDayServiceImpl implements IoStatDayService {
|
|
|
|
|
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);
|
|
|
|
@ -219,7 +226,6 @@ public class IoStatDayServiceImpl implements IoStatDayService {
|
|
|
|
|
//计算结余数据
|
|
|
|
|
statDayEntity.setBalanceCount(statDayEntity.getBalanceCount() + statDayEntity.getInCount() - statDayEntity.getOutCount());
|
|
|
|
|
statDayEntity.setBalanceAmount(statDayEntity.getBalanceAmount().add(statDayEntity.getInAmount()).subtract(statDayEntity.getOutAmount()));
|
|
|
|
|
|
|
|
|
|
mapper.insert(statDayEntity);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -227,9 +233,12 @@ public class IoStatDayServiceImpl implements IoStatDayService {
|
|
|
|
|
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()
|
|
|
|
|