|
@@ -11,9 +11,13 @@ 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.StockDetail;
|
|
|
+import com.fjhx.entity.stock.StockTag;
|
|
|
import com.fjhx.entity.stock.StockWater;
|
|
|
import com.fjhx.entity.stock.StockWaterdetial;
|
|
|
import com.fjhx.stock.mapper.StockWaterMapper;
|
|
|
+import com.fjhx.stock.service.StockDetailService;
|
|
|
+import com.fjhx.stock.service.StockTagService;
|
|
|
import com.fjhx.stock.service.StockWaterService;
|
|
|
import com.fjhx.stock.service.StockWaterdetialService;
|
|
|
import com.fjhx.utils.Assert;
|
|
@@ -23,6 +27,7 @@ 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 org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -43,15 +48,20 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
@Autowired
|
|
|
private StockWaterdetialService stockWaterdetialService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StockDetailService stockDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StockTagService stockTagService;
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getPickingStatistics(Map<String, String> condition) {
|
|
|
|
|
|
QueryWrapper<?> wrapper = WrapperUtil.init(condition)
|
|
|
- .periodOfTime("sw.CreatedTime") // 时间段查询
|
|
|
+ // 时间段查询
|
|
|
+ .periodOfTime("sw.CreatedTime")
|
|
|
.getWrapper();
|
|
|
-
|
|
|
- wrapper.eq("sw.IsDelete", 0); // 未删除
|
|
|
+ wrapper.eq("sw.IsDelete", 0);
|
|
|
wrapper.in("sw.StockChangeType", 15, 20, 23);
|
|
|
|
|
|
// 获取统计数据
|
|
@@ -616,23 +626,7 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
@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);
|
|
|
+ Page<Map<String, Object>> page = baseMapper.outPage(condition.getPage(), getWrapper(condition));
|
|
|
|
|
|
List<Map<String, Object>> records = page.getRecords();
|
|
|
if (records.size() == 0) {
|
|
@@ -640,7 +634,7 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
}
|
|
|
|
|
|
// 查询出库明细
|
|
|
- List<String> waterIdList = records.stream().map(item -> Convert.toStr(item.get("WaterId")))
|
|
|
+ List<String> waterIdList = records.stream().map(item -> Convert.toStr(item.get("waterId")))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
Map<String, List<StockWaterdetial>> waterIdGroup = stockWaterdetialService.getKGroup(
|
|
@@ -650,7 +644,7 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
.eq(StockWaterdetial::getIsDelete, 0));
|
|
|
|
|
|
records.forEach(item -> {
|
|
|
- String waterId = Convert.toStr(item.get("WaterId"));
|
|
|
+ String waterId = Convert.toStr(item.get("waterId"));
|
|
|
List<StockWaterdetial> stockWaterdetials = waterIdGroup.get(waterId);
|
|
|
item.put("detailsList", stockWaterdetials);
|
|
|
});
|
|
@@ -658,6 +652,66 @@ public class StockWaterServiceImpl extends ServiceImpl<StockWaterMapper, StockWa
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> outStatistics(Condition condition) {
|
|
|
+ return baseMapper.outStatistics(getWrapper(condition));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void swap(Condition condition) {
|
|
|
+ String oldRfid = condition.getStr("oldRfid");
|
|
|
+ String newRfid = condition.getStr("newRfid");
|
|
|
+
|
|
|
+ StockDetail stockDetail = stockDetailService.getOne(
|
|
|
+ q -> q.eq(StockDetail::getIsdelete, 0).eq(StockDetail::getRfidcode, oldRfid));
|
|
|
+
|
|
|
+ if (stockDetail != null) {
|
|
|
+ stockDetailService.removeById(stockDetail);
|
|
|
+
|
|
|
+ stockDetail.setId(null);
|
|
|
+ stockDetail.setRfidcode(newRfid);
|
|
|
+ stockDetailService.save(stockDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ StockTag stockTag = stockTagService.getOne(
|
|
|
+ q -> q.eq(StockTag::getIsDelete, 0).eq(StockTag::getRfidCode, oldRfid));
|
|
|
+
|
|
|
+ if (stockTag != null) {
|
|
|
+ stockTagService.removeById(stockTag);
|
|
|
+
|
|
|
+ stockTag.setId(null);
|
|
|
+ stockTag.setRfidCode(newRfid);
|
|
|
+ stockTagService.save(stockTag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private IWrapper<Object> getWrapper(Condition condition) {
|
|
|
+
|
|
|
+ String beginTime = condition.getStr("beginTime");
|
|
|
+ String endTime = condition.getStr("endTime");
|
|
|
+
|
|
|
+ IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
|
|
|
+ wrapper.eq("sw.IsDelete", 0)
|
|
|
+ .func(q -> {
|
|
|
+ Integer stockChangeType = condition.getInt("stockChangeType");
|
|
|
+ if (ObjectUtil.isEmpty(stockChangeType)) {
|
|
|
+ q.in("sw.StockChangeType", 20, 23, 26, 27);
|
|
|
+ } else {
|
|
|
+ if (stockChangeType == 20) {
|
|
|
+ q.in("sw.StockChangeType", 20, 23);
|
|
|
+ } else {
|
|
|
+ q.eq("sw.StockChangeType", 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");
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
private List<JSONObject> format(List<Map<String, Object>> list) {
|
|
|
Map<String, JSONObject> collect = list.stream().collect(Collectors.toMap(
|
|
|
item -> item.get("materialCode").toString(),
|