Commit 097d80a1 LN

1053报表Movement Summary修改

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