|
@@ -3,14 +3,18 @@ package com.fjhx.stock.service.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
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.stock.mapper.StockWaterMapper;
|
|
|
import com.fjhx.stock.service.StockWaterService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.BigDecimalUtil;
|
|
|
import com.fjhx.utils.WrapperUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -535,6 +539,102 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
return baseMapper.receiptList(purchaseBillNo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> issue(Condition condition) {
|
|
|
+ Date date = condition.getDate("date");
|
|
|
+ String account = condition.getStr("account", "账号不能为空");
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.getWater(Wrappers.query()
|
|
|
+ .between("swd.CreatedTime", date, DateUtil.offsetDay(date, 1))
|
|
|
+ .in("swd.StockChangeType", 20, 23)
|
|
|
+ .eq("aa.AccountNo", account)
|
|
|
+ .likeRight("m.Code", "01.")
|
|
|
+ );
|
|
|
+
|
|
|
+ return format(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> materialReturn(Condition condition) {
|
|
|
+ Date date = condition.getDate("date");
|
|
|
+ String account = condition.getStr("account", "账号不能为空");
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.getMaterialReturn(Wrappers.query()
|
|
|
+ .between("sb.checker_time", date, DateUtil.offsetDay(date, 1))
|
|
|
+ .eq("sb.operator_id", account)
|
|
|
+ .likeRight("m.Code", "01."));
|
|
|
+
|
|
|
+ return format(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> transferIn(Condition condition) {
|
|
|
+ Date date = condition.getDate("date");
|
|
|
+ String account = condition.getStr("account", "账号不能为空");
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.getTransferPickingList(Wrappers.query()
|
|
|
+ .between("st.submit_time", date, DateUtil.offsetDay(date, 1))
|
|
|
+ .eq("st.status", StatusConstant.YES)
|
|
|
+ .eq("st.del_flag", 0)
|
|
|
+ .eq("aa.AccountNo", account)
|
|
|
+ );
|
|
|
+
|
|
|
+ return format(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> transferOut(Condition condition) {
|
|
|
+ Date date = condition.getDate("date");
|
|
|
+ String account = condition.getStr("account", "账号不能为空");
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.getTransferBackList(Wrappers.query()
|
|
|
+ .between("st.submit_time", date, DateUtil.offsetDay(date, 1))
|
|
|
+ .eq("st.status", StatusConstant.YES)
|
|
|
+ .eq("st.del_flag", 0)
|
|
|
+ .eq("st.submit_user", account)
|
|
|
+ );
|
|
|
+
|
|
|
+ return format(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<JSONObject> format(List<Map<String, Object>> list) {
|
|
|
+ Map<String, JSONObject> collect = list.stream().collect(Collectors.toMap(
|
|
|
+ item -> item.get("materialCode").toString(),
|
|
|
+ item -> {
|
|
|
+ Object changeNum = item.get("changeNum");
|
|
|
+
|
|
|
+ JSONObject map = new JSONObject();
|
|
|
+ map.put("materialCode", item.get("materialCode"));
|
|
|
+ map.put("materialName", item.get("materialName"));
|
|
|
+ map.put("count", 1);
|
|
|
+ map.put("quantity", changeNum);
|
|
|
+ map.put("area", BigDecimalUtil.init(changeNum)
|
|
|
+ .multiply(item.get("width")).divideTry(100, 2).getValue());
|
|
|
+
|
|
|
+ JSONObject materialMap = new JSONObject();
|
|
|
+ materialMap.put("quantity", changeNum);
|
|
|
+ materialMap.put("rfid", item.get("rfid"));
|
|
|
+ map.put("materialList", Collections.singletonList(materialMap));
|
|
|
+
|
|
|
+ return map;
|
|
|
+ },
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.put("count", v1.getInteger("count") + v2.getInteger("count"));
|
|
|
+ v1.put("quantity", v1.getBigDecimal("quantity").add(v2.getBigDecimal("quantity")));
|
|
|
+ v1.put("area", v1.getBigDecimal("area").add(v2.getBigDecimal("area")));
|
|
|
+
|
|
|
+ List<JSONObject> newList = new ArrayList<>();
|
|
|
+ newList.addAll((List<JSONObject>) v1.get("materialList"));
|
|
|
+ newList.addAll((List<JSONObject>) v2.get("materialList"));
|
|
|
+
|
|
|
+ v1.put("materialList", newList);
|
|
|
+ return v1;
|
|
|
+ }
|
|
|
+ ));
|
|
|
+
|
|
|
+ return new ArrayList<>(collect.values());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private QueryWrapper<?> createRemainingTodayWrapper(Map<String, String> condition) {
|
|
|
QueryWrapper<?> wrapper = WrapperUtil.init(condition)
|
|
@@ -547,7 +647,7 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
wrapper.and(q -> q.likeRight("m.code", "01.").or().likeRight("m.code", "03.008."));
|
|
|
|
|
|
String inventoryResults = condition.get("inventoryResults");
|
|
|
- if ("0".equals(inventoryResults)) {
|
|
|
+ if ("0" .equals(inventoryResults)) {
|
|
|
wrapper.eq("IF( a.CheckTagCount = a.TagQuantity AND a.CheckTagCount = a.HandTagCount, 1, 0)", inventoryResults);
|
|
|
}
|
|
|
|