|
@@ -10,10 +10,13 @@ import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconst
|
|
|
import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionRealnameuserMapper;
|
|
|
import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionViewMapper;
|
|
|
import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionViewService;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -340,4 +343,48 @@ public class CenterdataTHousingconstructionViewServiceImpl extends BaseServiceIm
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @DataScopeMutiDept(deptAlias = "d")
|
|
|
+ public List<Map<String, Object>> getNewUserSumByEnterpriseId(CenterdataTHousingconstructionSteelcylinder steelcylinder) {
|
|
|
+ setSookaDataBase(steelcylinder);
|
|
|
+ List<Map<String, Object>> getData = centerdataTHousingconstructionViewMapper.getNewUserSumByEnterpriseId(steelcylinder);
|
|
|
+ Map<String, Map<String, Object>> data = new HashMap<>();
|
|
|
+ for (Map<String, Object> resultDatum : getData) {
|
|
|
+ data.put(MapUtils.getString(resultDatum,"month"), resultDatum);
|
|
|
+ }
|
|
|
+ List<String> twelveMonths = getTwelveMonths();
|
|
|
+
|
|
|
+ List<Map<String, Object>> resultData = new ArrayList<>();
|
|
|
+ twelveMonths.forEach(month->{
|
|
|
+ if(!data.containsKey(month)){
|
|
|
+ HashMap<String, Object> newMonth = new HashMap<>();
|
|
|
+ newMonth.put("sum",0);
|
|
|
+ newMonth.put("month",month);
|
|
|
+ resultData.add(newMonth);
|
|
|
+ }else{
|
|
|
+ resultData.add(data.get(month));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> getTwelveMonths(){
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+
|
|
|
+ // 存储过去12个月的月份
|
|
|
+ List<String> lastTwelveMonths = new ArrayList<>();
|
|
|
+
|
|
|
+ // 设置日期格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
+
|
|
|
+ for (int i = 0; i < 12; i++) {
|
|
|
+ // 计算月份
|
|
|
+ LocalDate date = currentDate.minusMonths(i);
|
|
|
+ // 格式化并添加到列表
|
|
|
+ lastTwelveMonths.add(date.format(formatter));
|
|
|
+ }
|
|
|
+ return lastTwelveMonths;
|
|
|
+ }
|
|
|
}
|