瀏覽代碼

feat:首页改版;

Joburgess 4 年之前
父節點
當前提交
e8674bc070

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/IndexBaseMonthDataService.java

@@ -9,7 +9,7 @@ import com.ym.mec.common.service.BaseService;
 
 public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMonthData> {
 
-    List<IndexBaseDto> getIndexBaseData(String dataType, String organIds, String startMonth, String endMonth);
+    List<IndexBaseDto> getIndexBaseData(String dataType, String organIds, Integer year);
 
     Map<String, List<IndexBaseDto>> indexBaseDataTask(String month);
 

+ 13 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -46,15 +46,19 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 	}
 
 	@Override
-	public List<IndexBaseDto> getIndexBaseData(String dataTypesStr, String organIdsStr, String startMonth, String endMonth) {
+	public List<IndexBaseDto> getIndexBaseData(String dataTypesStr, String organIdsStr, Integer year) {
 		List<IndexBaseDto> result = new ArrayList<>();
 
-		LocalDate nowDateTime = LocalDate.now();
-		nowDateTime.withDayOfMonth(1);
-		if(StringUtils.isBlank(startMonth)){
-			startMonth = nowDateTime.getYear() + "-01";
-			endMonth = null;
+		DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM");
+		LocalDate startDate = LocalDate.now();
+		if(Objects.nonNull(year)){
+			startDate = startDate.withYear(year);
 		}
+		startDate = startDate.withMonth(1);
+		startDate = startDate.withDayOfMonth(1);
+
+		LocalDate endDate = startDate.withMonth(12);
+
 		Set<Integer> organIds = null;
 		if(StringUtils.isNotBlank(organIdsStr)){
 			organIds = Arrays.stream(organIdsStr.split(",")).map(Integer::new).collect(Collectors.toSet());
@@ -64,18 +68,16 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			dataTypes = Arrays.stream(dataTypesStr.split(",")).collect(Collectors.toSet());
 		}
 
-		List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getIndexBaseData(organIds, dataTypes, startMonth, endMonth);
+		List<IndexBaseMonthData> indexBaseDatas = indexBaseMonthDataDao.getIndexBaseData(organIds, dataTypes, df.format(startDate), df.format(endDate));
 		if(CollectionUtils.isEmpty(indexBaseDatas)){
 			return result;
 		}
 
-		LocalDate startMonthDate = LocalDate.parse(startMonth + "-01", DateUtil.dateFormatter);
-
 		Map<IndexDataType, List<IndexBaseMonthData>> typeDateMap = indexBaseDatas.stream().collect(Collectors.groupingBy(IndexBaseMonthData::getDataType));
 		for (Map.Entry<IndexDataType, List<IndexBaseMonthData>> typeDateMapEntry : typeDateMap.entrySet()) {
 			Set<String> hasMonths = typeDateMapEntry.getValue().stream().map(d -> DateUtil.dateToString(d.getMonth(), "yyyy-MM-dd")).collect(Collectors.toSet());
-			LocalDate currentMonthDate = startMonthDate;
-			while (currentMonthDate.compareTo(nowDateTime)<=0){
+			LocalDate currentMonthDate = startDate;
+			while (currentMonthDate.compareTo(endDate)<=0){
 				if(hasMonths.contains(currentMonthDate.toString())){
 					currentMonthDate = currentMonthDate.plusMonths(1);
 					continue;

+ 4 - 4
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -150,8 +150,8 @@
 			del_flag_=0
 		  	AND organ_id_ IS NOT NULL
 			AND user_type_ LIKE '%STUDENT%'
-			AND YEAR(create_time_)=YEAR(#{month})
-			AND MONTH(create_time_)&lt;=MONTH(#{month})
+			AND YEAR(create_time_)=YEAR(CONCAT(#{month}, '-01'))
+			AND MONTH(create_time_)&lt;=MONTH(CONCAT(#{month}, '-01'))
 		GROUP BY organ_id_
 		ORDER BY organ_id_;
 	</select>
@@ -181,8 +181,8 @@
 		LEFT JOIN sys_user su ON sees.student_id_=su.id_
 		WHERE su.del_flag_=0
 			AND su.organ_id_ IS NOT NULL
-			AND YEAR(sees.monday_)=YEAR(#{month})
-			AND MONTH(sees.monday_)&lt;=MONTH(#{month})
+			AND YEAR(sees.monday_)=YEAR(CONCAT(#{month}, '-01'))
+			AND MONTH(sees.monday_)&lt;=MONTH(CONCAT(#{month}, '-01'))
 		GROUP BY su.organ_id_
 		ORDER BY su.organ_id_
 	</select>

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/IndexController.java

@@ -116,7 +116,7 @@ public class IndexController extends BaseController {
 	}
 
 	@GetMapping("/newIndex")
-	public HttpResponseResult newIndex(String dataTypes, String organIds, String startMonth, String endMonth){
+	public HttpResponseResult newIndex(String dataTypes, String organIds, Integer year){
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		if (sysUser == null) {
 			return failed("用户信息获取失败");
@@ -134,6 +134,6 @@ public class IndexController extends BaseController {
 				}
 			}
 		}
-		return succeed(indexService.getIndexBaseData(dataTypes , organIds, startMonth, endMonth));
+		return succeed(indexService.getIndexBaseData(dataTypes , organIds, year));
 	}
 }