|
|
|
@ -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,7 +59,7 @@ public class IoStatDayServiceImpl implements IoStatDayService {
|
|
|
|
|
//查询单号
|
|
|
|
|
List<String> orderIdFkList = new ArrayList<>();
|
|
|
|
|
orderIdFkList = orderDao.selectOrderIdList(yesterday.toString("yyyy-MM-dd"));
|
|
|
|
|
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
|
|
|
|
|
List<IoOrderDetailStatRsponse> orderDetailResultEntities = new ArrayList<>();
|
|
|
|
|
if (orderIdFkList.size() > 0) {
|
|
|
|
|
orderDetailResultEntities = ioOrderDetailResultDao.selectStatDataByTime(orderIdFkList);
|
|
|
|
|
}
|
|
|
|
@ -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,7 +233,10 @@ 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); //取前天的时间
|
|
|
|
|
wrapper.eq("year", dateTime.year())
|
|
|
|
|