|
@@ -1,5 +1,6 @@
|
|
|
package com.fjhx.stock.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -11,11 +12,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.stock.StockWater;
|
|
|
+import com.fjhx.entity.stock.StockWaterdetial;
|
|
|
import com.fjhx.stock.mapper.StockWaterMapper;
|
|
|
import com.fjhx.stock.service.StockWaterService;
|
|
|
+import com.fjhx.stock.service.StockWaterdetialService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.BigDecimalUtil;
|
|
|
import com.fjhx.utils.WrapperUtil;
|
|
|
+import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
+import com.fjhx.utils.wrapperUtil.KeywordData;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -34,6 +40,10 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWater> implements StockWaterService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StockWaterdetialService stockWaterdetialService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getPickingStatistics(Map<String, String> condition) {
|
|
|
|
|
@@ -603,6 +613,51 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
return baseMapper.getInventoryDetails(condition);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> outPage(Condition condition) {
|
|
|
+
|
|
|
+ String beginTime = condition.getStr("beginTime");
|
|
|
+ String endTime = condition.getStr("endTime");
|
|
|
+
|
|
|
+ IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
|
|
|
+ wrapper.func(q -> {
|
|
|
+ if (ObjectUtil.isEmpty(condition.getInt("stockChangeType"))) {
|
|
|
+ q.in("sw.StockChangeType", 20, 26, 27);
|
|
|
+ } else {
|
|
|
+ q.eq("sw.StockChangeType", condition.getInt("stockChangeType"));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .keyword(new KeywordData("m.name"), new KeywordData("m.code"))
|
|
|
+ .eq("sw.OperUserId", condition.getStr("operUserId"))
|
|
|
+ .between(ObjectUtil.isAllNotEmpty(beginTime, endTime), "sw.CreatedTime", beginTime, endTime)
|
|
|
+ .orderByDesc("sw.CreatedTime");
|
|
|
+
|
|
|
+ Page<Map<String, Object>> page = baseMapper.outPage(condition.getPage(), wrapper);
|
|
|
+
|
|
|
+ List<Map<String, Object>> records = page.getRecords();
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询出库明细
|
|
|
+ List<String> waterIdList = records.stream().map(item -> Convert.toStr(item.get("WaterId")))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<String, List<StockWaterdetial>> waterIdGroup = stockWaterdetialService.getKGroup(
|
|
|
+ StockWaterdetial::getWaterId,
|
|
|
+ q -> q.in(StockWaterdetial::getWaterId, waterIdList)
|
|
|
+ .select(StockWaterdetial::getWaterId, StockWaterdetial::getChangeNum, StockWaterdetial::getRfidCode)
|
|
|
+ .eq(StockWaterdetial::getIsDelete, 0));
|
|
|
+
|
|
|
+ records.forEach(item -> {
|
|
|
+ String waterId = Convert.toStr(item.get("WaterId"));
|
|
|
+ List<StockWaterdetial> stockWaterdetials = waterIdGroup.get(waterId);
|
|
|
+ item.put("detailsList", stockWaterdetials);
|
|
|
+ });
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
private List<JSONObject> format(List<Map<String, Object>> list) {
|
|
|
Map<String, JSONObject> collect = list.stream().collect(Collectors.toMap(
|
|
|
item -> item.get("materialCode").toString(),
|