Commit b2c15dd3 zshaohui

1.看板增加7天出入库统计数量

2.出入库数量计算修改
1 个父辈 9a8217b9
...@@ -36,6 +36,7 @@ import com.neotel.smfcore.core.system.util.DevicesStatusUtil; ...@@ -36,6 +36,7 @@ import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -913,7 +914,7 @@ public class DataCache { ...@@ -913,7 +914,7 @@ public class DataCache {
} }
private InOutData getLastSaveInOutData(String cid, String storageId) { private InOutData getLastSaveInOutData(String cid, String storageId) {
InOutData inOutData = inOutDataManager.findOneByQuery(new Query(Criteria.where("cid").is(cid).and("storageId").is(storageId))); InOutData inOutData = inOutDataManager.findOneByCidAndStorageId(cid,storageId);
if (inOutData == null) { if (inOutData == null) {
inOutData = new InOutData(); inOutData = new InOutData();
} else { } else {
......
...@@ -5,9 +5,12 @@ import com.neotel.smfcore.core.inout.service.po.InOutData; ...@@ -5,9 +5,12 @@ import com.neotel.smfcore.core.inout.service.po.InOutData;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import java.util.Date; import java.util.Date;
import java.util.List;
public interface IInOutDataManager extends IBaseManager<InOutData> { public interface IInOutDataManager extends IBaseManager<InOutData> {
InOutData findOneByDate(Date startDate,Date endDate); List<InOutData> findByDate(Date startDate, Date endDate);
InOutData findOneByQuery(Query query); InOutData findOne(Query query);
InOutData findOneByCidAndStorageId(String cid, String storageId);
} }
...@@ -48,19 +48,21 @@ public class InOutDataManagerImpl implements IInOutDataManager { ...@@ -48,19 +48,21 @@ public class InOutDataManagerImpl implements IInOutDataManager {
} }
@Override @Override
public InOutData findOneByDate(Date startDate,Date endDate) { public List<InOutData> findByDate(Date startDate,Date endDate) {
Query q = new Query(); Query q = new Query();
Criteria c = Criteria.where("createDate").gte(startDate); Criteria c = Criteria.where("createDate").gte(startDate).lt(endDate);
if (endDate != null){
c.and("createDate").lt(endDate);
}
Sort s = Sort.by(Sort.Direction.DESC, "createDate"); Sort s = Sort.by(Sort.Direction.DESC, "createDate");
return inOutDataDao.findOne(q.addCriteria(c).with(s)); return inOutDataDao.findByQuery(q.addCriteria(c).with(s));
} }
@Override @Override
public InOutData findOneByQuery(Query query) { public InOutData findOne(Query query) {
query.with(Sort.by(Sort.Direction.DESC,"createDate")); return inOutDataDao.findOne(query);
}
@Override
public InOutData findOneByCidAndStorageId(String cid, String storageId) {
Query query = new Query(Criteria.where("cid").is(cid).and("storageId").is(storageId)).with(Sort.by(Sort.Direction.DESC, "createDate"));
return inOutDataDao.findOne(query); return inOutDataDao.findOne(query);
} }
} }
...@@ -3,11 +3,14 @@ package com.neotel.smfcore.custom.sungya20456.kanban; ...@@ -3,11 +3,14 @@ package com.neotel.smfcore.custom.sungya20456.kanban;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inout.service.manager.IInOutDataManager;
import com.neotel.smfcore.core.inout.service.po.InOutData;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage; import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.custom.sungya20456.kanban.bean.ExpireDto; import com.neotel.smfcore.custom.sungya20456.kanban.bean.dto.ExpireDto;
import com.neotel.smfcore.custom.sungya20456.kanban.bean.SluggishDto; import com.neotel.smfcore.custom.sungya20456.kanban.bean.dto.InOutDataDto;
import com.neotel.smfcore.custom.sungya20456.kanban.bean.dto.SluggishDto;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -18,9 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,9 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
...@@ -35,6 +40,9 @@ public class KanbanController { ...@@ -35,6 +40,9 @@ public class KanbanController {
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired
private IInOutDataManager inOutDataManager;
@ApiOperation("过期信息") @ApiOperation("过期信息")
@RequestMapping("/getExpiredInfo") @RequestMapping("/getExpiredInfo")
@AnonymousAccess @AnonymousAccess
...@@ -112,4 +120,40 @@ public class KanbanController { ...@@ -112,4 +120,40 @@ public class KanbanController {
} }
return usage; return usage;
} }
@ApiOperation("近7日出入库统计")
@RequestMapping("/getServenInOutData")
@AnonymousAccess
public InOutDataDto getServenInOutData() {
InOutDataDto dto = new InOutDataDto();
List<String> dateStrList = new ArrayList<>();
List<Integer> inDataList = new ArrayList<>();
List<Integer> outDataList = new ArrayList<>();
int days = 7;
//1.获取当前日期
String currentDateStr = DateUtil.toDateString(new Date(), "yyyy-MM-dd");
Date currentDate = DateUtil.toDate(currentDateStr,"yyyy-MM-dd");
//2.开始处理 7天数据
for (int day = 1; day <= days; day++) {
Date startDate = DateUtil.addDays(currentDate, day - days);
Date endDate = DateUtil.addDays(currentDate, day - days + 1);
List<InOutData> inOutDataList = inOutDataManager.findByDate(startDate, endDate);
int inData = 0;
int outData = 0;
if (inOutDataList != null && !inOutDataList.isEmpty()) {
inData = inOutDataList.stream().mapToInt(InOutData :: getInCount).sum();
outData = inOutDataList.stream().mapToInt(InOutData :: getOutCount).sum();
}
dateStrList.add(DateUtil.toDateString(startDate,"MM/dd"));
inDataList.add(inData);
outDataList.add(outData);
}
dto.setDateStrList(dateStrList);
dto.setInDataList(inDataList);
dto.setOutDataList(outDataList);
return dto;
}
} }
package com.neotel.smfcore.custom.sungya20456.kanban.bean; package com.neotel.smfcore.custom.sungya20456.kanban.bean.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
......
package com.neotel.smfcore.custom.sungya20456.kanban.bean.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class InOutDataDto {
@ApiModelProperty("日期集合")
private List<String> dateStrList;
@ApiModelProperty("入库数据集合")
private List<Integer> inDataList;
@ApiModelProperty("出库数据集合")
private List<Integer> outDataList;
}
package com.neotel.smfcore.custom.sungya20456.kanban.bean; package com.neotel.smfcore.custom.sungya20456.kanban.bean.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!