|
@@ -34,7 +34,7 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
private final DmHaveDinnerRepository dmHaveDinnerRepository;
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject selectDiningStatements(String stateDate, String endDate, String type, Pageable pageable) {
|
|
|
+ public JSONObject selectDiningTopStatements(String stateDate, String endDate, String type, Pageable pageable) {
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
@@ -50,8 +50,6 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
|
|
|
// 前三
|
|
|
Page<List<Map<String, Object>>> top = null;
|
|
|
- // 后三
|
|
|
- Page<List<Map<String, Object>>> stop = null;
|
|
|
// 默认按月来
|
|
|
if (type == null){
|
|
|
type = "month";
|
|
@@ -64,10 +62,8 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
String StartTime = simpleDateFormat.format(instance.getTime()) + " 00:00:00";
|
|
|
if (flag){
|
|
|
top = dmHaveDinnerRepository.selectTop(stateDate,endDate,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
}else {
|
|
|
top = dmHaveDinnerRepository.selectTop(StartTime,nowTime,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(StartTime, nowTime,null);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -95,10 +91,8 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
}
|
|
|
if (flag){
|
|
|
top = dmHaveDinnerRepository.selectTop(stateDate,endDate,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
}else {
|
|
|
top = dmHaveDinnerRepository.selectTop(startTime,nowTime,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
}
|
|
|
}
|
|
|
// 按月报来
|
|
@@ -112,10 +106,8 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
String startTime = month.format(instance.getTime()) + "-01 00:00:00";
|
|
|
if (flag){
|
|
|
top = dmHaveDinnerRepository.selectTop(stateDate,endDate,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
}else {
|
|
|
top = dmHaveDinnerRepository.selectTop(startTime,nowTime,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
}
|
|
|
}
|
|
|
// 按年报来
|
|
@@ -130,18 +122,113 @@ public class DmHaveDinnerServiceImpl implements DmHaveDinnerService {
|
|
|
String startTime = year.format( instance.getTime())+ "-01-01 00:00:00";
|
|
|
if (flag){
|
|
|
top = dmHaveDinnerRepository.selectTop(stateDate,endDate,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
}else {
|
|
|
top = dmHaveDinnerRepository.selectTop(startTime,nowTime,null);
|
|
|
- stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
}
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("top", PageUtil.toPage(top));
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject selectDiningsStopStatements(String stateDate, String endDate, String type, Pageable pageable) {
|
|
|
+
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ SimpleDateFormat month = new SimpleDateFormat("yyyy-MM");
|
|
|
+
|
|
|
+ SimpleDateFormat year = new SimpleDateFormat("yyyy");
|
|
|
+
|
|
|
+ Boolean flag = false;
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(stateDate) || !StringUtils.isEmpty(endDate)){
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ // 后三
|
|
|
+ Page<List<Map<String, Object>>> stop = null;
|
|
|
+ // 默认按月来
|
|
|
+ if (type == null){
|
|
|
+ type = "month";
|
|
|
+ }
|
|
|
+ //按日报来
|
|
|
+ if (type.equals("day")){
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ //当前时间
|
|
|
+ String nowTime = simpleDateFormat.format(instance.getTime()) + " 23:59:59";
|
|
|
+ String StartTime = simpleDateFormat.format(instance.getTime()) + " 00:00:00";
|
|
|
+ if (flag){
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
+ }else {
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(StartTime, nowTime,null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 按周报来
|
|
|
+ if (type.equals("week")){
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ //判断当前时间在当前星期中事星期几 由于日历类中星期一是从周日算的
|
|
|
+ int i = instance.get(Calendar.DAY_OF_WEEK)-1;
|
|
|
+
|
|
|
+ //当前时间
|
|
|
+ String nowTime = "";
|
|
|
+ //开始时间
|
|
|
+ String startTime = "";
|
|
|
+
|
|
|
+ if (i==0){
|
|
|
+ instance.add(Calendar.DATE, 1-i);
|
|
|
+ startTime = simpleDateFormat.format(instance.getTime()) + " 00:00:00";
|
|
|
+ instance.add(Calendar.DATE, 7-1);
|
|
|
+ nowTime = simpleDateFormat.format(instance.getTime()) + " 23:59:59";
|
|
|
+ }else {
|
|
|
+ instance.add(Calendar.DATE,1-i);
|
|
|
+ startTime = simpleDateFormat.format(instance.getTime()) + " 00:00:00";
|
|
|
+ instance.add(Calendar.DATE, 7-1);
|
|
|
+ nowTime = simpleDateFormat.format(instance.getTime()) + " 23:59:59";
|
|
|
+ }
|
|
|
+ if (flag){
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
+ }else {
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按月报来
|
|
|
+ if (type.equals("month")){
|
|
|
+
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ // 当前月份最大多少天
|
|
|
+ int actualMaximum = instance.getActualMaximum(Calendar.DATE);
|
|
|
+ //当前时间
|
|
|
+ String nowTime = month.format(instance.getTime()) + "-"+actualMaximum+" 23:59:59";
|
|
|
+ String startTime = month.format(instance.getTime()) + "-01 00:00:00";
|
|
|
+ if (flag){
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
+ }else {
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按年报来
|
|
|
+ if (type.equals("year")){
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ //设置到12月用来取最大天数
|
|
|
+ instance.set(Calendar.MONTH, 11);
|
|
|
+ // 当年最大月份最大多少天
|
|
|
+ int actualMaximum = instance.getActualMaximum(Calendar.DATE);
|
|
|
+ //当前时间
|
|
|
+ String nowTime = year.format(instance.getTime())+ "-12-"+actualMaximum+" 23:59:59";
|
|
|
+ String startTime = year.format( instance.getTime())+ "-01-01 00:00:00";
|
|
|
+ if (flag){
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(stateDate, endDate,null);
|
|
|
+ }else {
|
|
|
+ stop = dmHaveDinnerRepository.selectStop(startTime, nowTime,null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("stop", PageUtil.toPage(stop));
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> selectZgHaveDinner(String stateDate, String endDate, String type, Pageable pageable) {
|
|
|
Page<DmHaveDinner> page = null;
|