Commit 097d80a1 LN

1053报表Movement Summary修改

1 个父辈 442d14ab
......@@ -79,7 +79,7 @@ public class DataLogDaoImpl extends AbstractBaseDao implements IDataLogDao {
Aggregation.match(criteria),
Aggregation.project().and("updateDate").extractDayOfYear().as("label"),
Aggregation.group("label").count().as("value"),
Aggregation.project("value").and("searchType").previousOperation()
Aggregation.project("value").and("label").previousOperation()
);
AggregationResults<SpDailyLog> results = getMongoTemplate().aggregate(agg, getEntityClass(), SpDailyLog.class);
return results.getMappedResults();
......
......@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
......@@ -81,46 +82,54 @@ public class MicronReportController {
return result;
}
@ApiOperation("Material count 每天的出入库数量统计")
@ApiOperation("Movement Summary 每天的出入库数量统计")
@GetMapping("/dailyLog")
@AnonymousAccess
public List<SpDailyLogDto> queryDailyLog(SpReportQueryCondition criteria ) {
Criteria c = null;
Date start=null;
Date end=new Date();
if (criteria.getUpdateDate().getFrom() != null && criteria.getUpdateDate().getTo() != null) {
Date start = null;
Date end = new Date();
if (criteria.getUpdateDate()!=null&&criteria.getUpdateDate().getFrom() != null && criteria.getUpdateDate().getTo() != null) {
c = Criteria.where("createDate").gte(criteria.getUpdateDate().getFrom()).lte(criteria.getUpdateDate().getTo());
start=criteria.getUpdateDate().getFrom() ;
end=criteria.getUpdateDate().getTo();
start = criteria.getUpdateDate().getFrom();
end = criteria.getUpdateDate().getTo();
} else {
//过去一月
Calendar time = Calendar.getInstance();
time.setTime(new Date());
time.add(Calendar.MONTH, -1);
time.add(Calendar.MONTH, -2);
start = time.getTime();
c = Criteria.where("createDate").gte(time.getTime()).lte(new Date());
}
List<SpDailyLog> results = dataLogManager.getSpDailyLogs(start,end,"");
HashMap<String,SpDailyLogDto> dailyLogDtos=new HashMap<String,SpDailyLogDto>();
List<String> types=new ArrayList<>();
List<SpDailyLog> results = dataLogManager.getSpDailyLogs(start, end, "");
HashMap<String, SpDailyLogDto> dailyLogDtos = new HashMap<String, SpDailyLogDto>();
List<String> types = new ArrayList<>();
types.add(MInOutType.OFFLINE);
types.add(MInOutType.DESPOSIT);
types.add(MInOutType.REMOVED);
types.add(MInOutType.RETURNED);
types.add(MInOutType.WITHDRAWN);
for (String type :types) {
for (String type : types) {
List<SpDailyLog> logs=dataLogManager.getSpDailyLogs(start,end,type );
List<SpDailyLog> logs = dataLogManager.getSpDailyLogs(start, end, type);
for (SpDailyLog log :
logs) {
SpDailyLogDto dto= dailyLogDtos.getOrDefault(log.getLabel(),new SpDailyLogDto());
SpDailyLogDto dto = dailyLogDtos.getOrDefault(log.getLabel(), new SpDailyLogDto());
if(dto.getTypeCounts()==null){
dto.setDayOfYear(log.getLabel());
Date date = new Date();
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_YEAR, Integer.valueOf(log.getLabel()));
String time = f.format(ca.getTime());
dto.setTime(time);
if (dto.getTypeCounts() == null) {
dto.setTypeCounts(new HashMap<>());
}
dto.getTypeCounts().put(type,log.getValue());
dailyLogDtos.put(log.getLabel(),dto);
dto.getTypeCounts().put(type, log.getValue());
dailyLogDtos.put(log.getLabel(), dto);
}
}
return new ArrayList<>(dailyLogDtos.values());
......
......@@ -12,6 +12,8 @@ public class SpDailyLogDto implements Serializable {
@ApiModelProperty("日期")
private String time;
private String dayOfYear;
private HashMap<String,Integer> typeCounts;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!