|
@@ -9,6 +9,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
+import org.jeecg.modules.Index.mapper.IndexMapper;
|
|
|
import org.jeecg.modules.Index.util.AuthMark;
|
|
|
import org.jeecg.modules.Index.util.CacheKey;
|
|
|
import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
|
|
@@ -38,7 +39,6 @@ import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
@Service
|
|
|
public class IndexServiceImpl implements IndexService {
|
|
|
-
|
|
|
@Autowired
|
|
|
private ISysBaseAPI sysBaseApi;
|
|
|
|
|
@@ -73,6 +73,13 @@ public class IndexServiceImpl implements IndexService {
|
|
|
private ISysDepartService sysDepartService;
|
|
|
|
|
|
/**
|
|
|
+ * indexMapper
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IndexMapper indexMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
* 科研任务信息表
|
|
|
*/
|
|
|
@Autowired
|
|
@@ -87,6 +94,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
private IProjectCostService projectCostService;
|
|
|
|
|
|
|
|
|
+
|
|
|
private static final String YEAR = "year";
|
|
|
|
|
|
private static final String MONTH = "month";
|
|
@@ -887,11 +895,11 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 计算某部门某段时间的利润额
|
|
|
+ * 根据任务号计算利润额
|
|
|
*
|
|
|
* @return taskNoListNew
|
|
|
*/
|
|
|
- public BigDecimal countLre(List<String> taskNoListNew) {
|
|
|
+ public BigDecimal countLreByTaskNo(List<String> taskNoListNew) {
|
|
|
//3.根据任务号taskno查找需要计算的所有数据list
|
|
|
List<ProjectCost> costList = new ArrayList<>();
|
|
|
for (String taskNo1 : taskNoListNew) {
|
|
@@ -1019,6 +1027,49 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据需要的日期来取任务号tasknolist
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getTaskNoListFDepTime(String timeStatus) {
|
|
|
+ //获取需要的时间范围
|
|
|
+ //int:0当年范围 1去年同期 2当月 3上个月 4 去年同期月份
|
|
|
+// HashMap<String, Date> timeRangeMap = getTimeRange(0);
|
|
|
+
|
|
|
+ //2.根据部门名称(zrbm、jycs)和实际完成时间(目前是当年)查询taskno
|
|
|
+ List<String> taskNoList = new ArrayList<>();
|
|
|
+ switch (timeStatus) {
|
|
|
+ case "0"://当年的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByCurrYear();
|
|
|
+ break;
|
|
|
+ case "1"://上一年的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByLastYear();
|
|
|
+ break;
|
|
|
+ case "2"://当月的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByCurrMonth();
|
|
|
+ break;
|
|
|
+ case "3"://上个月的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByLastMonth();
|
|
|
+ break;
|
|
|
+ case "4"://上一年同月的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByTqMonth();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ System.out.println("默认没有任务");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //新建一个list来给list中的数据去重 防止责任部门和下达部门都为一个部门,可能会信息重复
|
|
|
+ List<String> taskNoListNew = new ArrayList<>();
|
|
|
+ for (String taskNo : taskNoList) {
|
|
|
+ if (!taskNoListNew.contains(taskNo)) {
|
|
|
+ taskNoListNew.add(taskNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return taskNoListNew;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据部门和需要的日期(某年某月)来取任务号tasknolist
|
|
|
*
|
|
|
* @return
|
|
@@ -1056,6 +1107,36 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据部门和需要的日期(某年某月)来取任务号tasknolist
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getTaskNoListFDepTime2(String timeType, String timeRange){
|
|
|
+ //2.根据部门名称(zrbm、jycs)和实际完成时间查询taskno
|
|
|
+ List<String> taskNoList = new ArrayList<>();
|
|
|
+ switch (timeType) {
|
|
|
+ case "year"://某年的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByYear2(timeRange);
|
|
|
+ break;
|
|
|
+ case "month"://某月的所有任务
|
|
|
+ taskNoList = kyTaskInfoService.getKyTaskNoByMonth2(timeRange);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ System.out.println("默认没有任务");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //新建一个list来给list中的数据去重 防止责任部门和下达部门都为一个部门,可能会信息重复
|
|
|
+ List<String> taskNoListNew = new ArrayList<>();
|
|
|
+ for (String taskNo : taskNoList) {
|
|
|
+ if (!taskNoListNew.contains(taskNo)) {
|
|
|
+ taskNoListNew.add(taskNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return taskNoListNew;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 计算当年的年总利润额、上一年同期总利润额、年同比增长、当月总利润额、当月同比、当月环比
|
|
|
*
|
|
|
* @return
|
|
@@ -1078,7 +1159,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<String> taskNoListNew = getTaskNoListFDepTime(sysDepartNames, "0");
|
|
|
System.out.println("当年的任务号列表:");
|
|
|
System.out.println(taskNoListNew);
|
|
|
- BigDecimal sumLreYear = countLre(taskNoListNew);
|
|
|
+ BigDecimal sumLreYear = countLreByTaskNo(taskNoListNew);
|
|
|
System.out.println("当年的利润额为:");
|
|
|
System.out.println(sumLreYear);
|
|
|
if (sumLreYear == null) {
|
|
@@ -1091,7 +1172,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<String> taskNoListNew2 = getTaskNoListFDepTime(sysDepartNames, "1");
|
|
|
System.out.println("上一年的任务号列表:");
|
|
|
System.out.println(taskNoListNew2);
|
|
|
- BigDecimal sumLreLastYear = countLre(taskNoListNew2);
|
|
|
+ BigDecimal sumLreLastYear = countLreByTaskNo(taskNoListNew2);
|
|
|
System.out.println("上一年的利润额为:");
|
|
|
System.out.println(sumLreLastYear);
|
|
|
if (sumLreLastYear == null) {
|
|
@@ -1115,7 +1196,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<String> taskNoListNew3 = getTaskNoListFDepTime(sysDepartNames, "2");
|
|
|
System.out.println("当月的任务号列表:");
|
|
|
System.out.println(taskNoListNew3);
|
|
|
- BigDecimal sumLreCurrMonth = countLre(taskNoListNew3);
|
|
|
+ BigDecimal sumLreCurrMonth = countLreByTaskNo(taskNoListNew3);
|
|
|
System.out.println("当月的利润额为:");
|
|
|
System.out.println(sumLreCurrMonth);
|
|
|
if (sumLreCurrMonth == null) {
|
|
@@ -1128,7 +1209,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<String> taskNoListNew4 = getTaskNoListFDepTime(sysDepartNames, "3");
|
|
|
System.out.println("上个月的任务号列表:");
|
|
|
System.out.println(taskNoListNew4);
|
|
|
- BigDecimal sumLreLastMonth = countLre(taskNoListNew4);
|
|
|
+ BigDecimal sumLreLastMonth = countLreByTaskNo(taskNoListNew4);
|
|
|
System.out.println("上个月的利润额为:");
|
|
|
System.out.println(sumLreLastMonth);
|
|
|
if (sumLreLastMonth == null) {
|
|
@@ -1151,7 +1232,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
List<String> taskNoListNew5 = getTaskNoListFDepTime(sysDepartNames, "4");
|
|
|
System.out.println("去年同期月份的任务号列表:");
|
|
|
System.out.println(taskNoListNew5);
|
|
|
- BigDecimal sumLreTqMonth = countLre(taskNoListNew5);
|
|
|
+ BigDecimal sumLreTqMonth = countLreByTaskNo(taskNoListNew5);
|
|
|
System.out.println("去年同期月份的利润额为:");
|
|
|
System.out.println(sumLreTqMonth);
|
|
|
if (sumLreTqMonth == null) {
|
|
@@ -1173,6 +1254,124 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 所长查看所有
|
|
|
+ * 计算当年的年总利润额、上一年同期总利润额、年同比增长、当月总利润额、当月同比、当月环比
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndexTotalVo countLreAll(){
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0);
|
|
|
+ IndexTotalVo lreDataInfoVo = new IndexTotalVo();
|
|
|
+ lreDataInfoVo.setYearTotal(initValue);
|
|
|
+ lreDataInfoVo.setYearTq(initValue);
|
|
|
+ lreDataInfoVo.setYearTb(initValue);
|
|
|
+ lreDataInfoVo.setMonthTotal(initValue);
|
|
|
+ lreDataInfoVo.setMonthTb(initValue);
|
|
|
+ lreDataInfoVo.setMonthHb(initValue);
|
|
|
+
|
|
|
+ BigDecimal eValue = new BigDecimal("1");
|
|
|
+
|
|
|
+ //1.通过登录的用户找到相应的部门,可能一个或两个
|
|
|
+ List<String> sysDepartNames = getDepNameBySysUser();
|
|
|
+ //2.计算当年的总利润额
|
|
|
+ List<String> taskNoListNew = getTaskNoListFDepTime("0");
|
|
|
+ System.out.println("当年的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew);
|
|
|
+ BigDecimal sumLreYear = countLreByTaskNo(taskNoListNew);
|
|
|
+ System.out.println("当年的利润额为:");
|
|
|
+ System.out.println(sumLreYear);
|
|
|
+ if(sumLreYear == null){
|
|
|
+ sumLreYear = initValue;
|
|
|
+ }
|
|
|
+ lreDataInfoVo.setYearTotal(sumLreYear);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+
|
|
|
+ //2.计算上一年的总利润额
|
|
|
+ List<String> taskNoListNew2 = getTaskNoListFDepTime("1");
|
|
|
+ System.out.println("上一年的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew2);
|
|
|
+ BigDecimal sumLreLastYear = countLreByTaskNo(taskNoListNew2);
|
|
|
+ System.out.println("上一年的利润额为:");
|
|
|
+ System.out.println(sumLreLastYear);
|
|
|
+ if(sumLreLastYear == null){
|
|
|
+ sumLreLastYear = initValue;
|
|
|
+ }
|
|
|
+ lreDataInfoVo.setYearTq(sumLreLastYear);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+
|
|
|
+ //2.计算年同比增长率
|
|
|
+ try {
|
|
|
+ BigDecimal tbGrowthYear = ((sumLreYear.subtract(sumLreLastYear)).divide(sumLreLastYear, 2, RoundingMode.HALF_UP));
|
|
|
+ System.out.println("年利润同比增长率为:");
|
|
|
+ System.out.println(tbGrowthYear);
|
|
|
+ lreDataInfoVo.setYearTb(tbGrowthYear);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+ } catch (Exception e) {
|
|
|
+ lreDataInfoVo.setYearTb(eValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.计算当月的总利润额
|
|
|
+ List<String> taskNoListNew3 = getTaskNoListFDepTime("2");
|
|
|
+ System.out.println("当月的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew3);
|
|
|
+ BigDecimal sumLreCurrMonth = countLreByTaskNo(taskNoListNew3);
|
|
|
+ System.out.println("当月的利润额为:");
|
|
|
+ System.out.println(sumLreCurrMonth);
|
|
|
+ if(sumLreCurrMonth == null){
|
|
|
+ sumLreCurrMonth = initValue;
|
|
|
+ }
|
|
|
+ lreDataInfoVo.setMonthTotal(sumLreCurrMonth);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+
|
|
|
+ //2.计算上个月的总利润额
|
|
|
+ List<String> taskNoListNew4 = getTaskNoListFDepTime("3");
|
|
|
+ System.out.println("上个月的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew4);
|
|
|
+ BigDecimal sumLreLastMonth = countLreByTaskNo(taskNoListNew4);
|
|
|
+ System.out.println("上个月的利润额为:");
|
|
|
+ System.out.println(sumLreLastMonth);
|
|
|
+ if(sumLreLastMonth == null){
|
|
|
+ sumLreLastMonth = initValue;
|
|
|
+ }
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+
|
|
|
+ //2.计算月环比增长率
|
|
|
+ try {
|
|
|
+ BigDecimal hbGrowthMonth = ((sumLreCurrMonth.subtract(sumLreLastMonth)).divide(sumLreLastMonth, 2, RoundingMode.HALF_UP));
|
|
|
+ lreDataInfoVo.setMonthHb(hbGrowthMonth);
|
|
|
+ System.out.println("月环比为:");
|
|
|
+ System.out.println(hbGrowthMonth);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+ } catch (Exception e) {
|
|
|
+ lreDataInfoVo.setMonthHb(eValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.计算去年同期月份的总利润额
|
|
|
+ List<String> taskNoListNew5 = getTaskNoListFDepTime("4");
|
|
|
+ System.out.println("去年同期月份的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew5);
|
|
|
+ BigDecimal sumLreTqMonth = countLreByTaskNo(taskNoListNew5);
|
|
|
+ System.out.println("去年同期月份的利润额为:");
|
|
|
+ System.out.println(sumLreTqMonth);
|
|
|
+ if(sumLreTqMonth == null){
|
|
|
+ sumLreTqMonth = initValue;
|
|
|
+ }
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+
|
|
|
+ //2.计算月同比增长率
|
|
|
+ try {
|
|
|
+ BigDecimal tbGrowthMonth = ((sumLreCurrMonth.subtract(sumLreTqMonth)).divide(sumLreTqMonth, 2, RoundingMode.HALF_UP));
|
|
|
+ lreDataInfoVo.setMonthTb(tbGrowthMonth);
|
|
|
+ System.out.println("月同比为:");
|
|
|
+ System.out.println(tbGrowthMonth);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+ } catch (Exception e) {
|
|
|
+ lreDataInfoVo.setMonthTb(eValue);
|
|
|
+ }
|
|
|
+ return lreDataInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 通过登录的用户找到相应的部门,可能一个或两个
|
|
|
*
|
|
|
* @return
|
|
@@ -1228,13 +1427,14 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 部门领导查部门
|
|
|
* 首页二层:前端传送IndexInfoParamDto 有三个参数,都是string类型 time 年/月 beginDate 开始日期 endDate结束日期
|
|
|
* 跟据time来按月查或按年查
|
|
|
*
|
|
|
* @param indexInfoParamDto
|
|
|
* @return IndexChartInfoVo<BigDecimal>
|
|
|
*/
|
|
|
- public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ public IndexChartInfoVo<BigDecimal> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
//1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
|
|
@@ -1259,7 +1459,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
// System.out.println("获取的日期列表为:");
|
|
|
// System.out.println(timeRangeList);
|
|
|
- if (timeRangeList.isEmpty()) return Result.OK(indexChartInfoVo);//日期为空,直接传回两个空list
|
|
|
+ if (timeRangeList.isEmpty()) return indexChartInfoVo;//日期为空,直接传回两个空list
|
|
|
//根据日期长度初始化纵坐标值 0
|
|
|
for (String timeRange : timeRangeList) {
|
|
|
seriesDataList.add(initValue);
|
|
@@ -1271,7 +1471,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
//3.通过登录的用户找到相应的部门,可能一个或两个
|
|
|
List<String> sysDepartNames = getDepNameBySysUser();
|
|
|
- if (sysDepartNames.isEmpty()) return Result.OK(indexChartInfoVo);
|
|
|
+ if (sysDepartNames.isEmpty()) return indexChartInfoVo;
|
|
|
|
|
|
ArrayList<String> tasknoList = new ArrayList<>();
|
|
|
List<String> ZrbmTasknoList = projectCostMapper.queryZrbmTasknoListbydepartNames(sysDepartNames);
|
|
@@ -1280,7 +1480,81 @@ public class IndexServiceImpl implements IndexService {
|
|
|
tasknoList.addAll(XdbmTasknoList);
|
|
|
System.out.println("查到的所有部门对应的任务号列表:");
|
|
|
System.out.println(tasknoList);
|
|
|
- if (tasknoList.isEmpty()) return Result.OK(indexChartInfoVo);
|
|
|
+ if (tasknoList.isEmpty()) return indexChartInfoVo;
|
|
|
+// System.out.println(indexChartInfoVo);
|
|
|
+
|
|
|
+ //4.计算该时间列表中某年或某月对应的总利润额
|
|
|
+ List<BigDecimal> seriesDataList2 = new ArrayList<>();
|
|
|
+ for(String timeRange2:timeRangeList){
|
|
|
+ //根据日期和当前部门对应的任务号查询,部门某年或某月的年收入
|
|
|
+ if(timeType.equals("year")){
|
|
|
+ BigDecimal yearTotal = exchangeMapper.getReceivedByYear(tasknoList, timeRange2);
|
|
|
+ if(yearTotal == null){
|
|
|
+ yearTotal = initValue;
|
|
|
+ }
|
|
|
+ seriesDataList2.add(yearTotal);
|
|
|
+ }
|
|
|
+ else if(timeType.equals("month")){
|
|
|
+ BigDecimal yearTotal = exchangeMapper.getReceivedByYMonth(tasknoList, timeRange2);
|
|
|
+ if(yearTotal == null){
|
|
|
+ yearTotal = initValue;
|
|
|
+ }
|
|
|
+ seriesDataList2.add(yearTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加纵坐标列表
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList2);
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 所长查所有
|
|
|
+ * 首页二层:前端传送IndexInfoParamDto 有三个参数,都是string类型 time 年/月 beginDate 开始日期 endDate结束日期
|
|
|
+ * 跟据time来按月查或按年查
|
|
|
+ *
|
|
|
+ * @param indexInfoParamDto
|
|
|
+ * @return IndexChartInfoVo<BigDecimal>
|
|
|
+ */
|
|
|
+ public IndexChartInfoVo<BigDecimal> countTotalReceivedAllByDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
+ //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
+ IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
|
|
|
+ //创建一个String列表用来存储横坐标日期
|
|
|
+ List<String> timeRangeList = new ArrayList<>();
|
|
|
+ //创建一个BigDecimal列表用来存储纵坐标利润
|
|
|
+ List<BigDecimal> seriesDataList = new ArrayList<>();
|
|
|
+ //初始化传一个空列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+ //2.计算时间列表 横坐标时间string列表
|
|
|
+ //年/月
|
|
|
+ String timeType = indexInfoParamDto.getTime();
|
|
|
+ //起始时间
|
|
|
+ String startString = indexInfoParamDto.getBeginDate();
|
|
|
+ //结束时间
|
|
|
+ String endString = indexInfoParamDto.getEndDate();
|
|
|
+ if(timeType.equals("year")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
|
|
|
+ }
|
|
|
+ else if (timeType.equals("month")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy-MM", timeType);
|
|
|
+ }
|
|
|
+// System.out.println("获取的日期列表为:");
|
|
|
+// System.out.println(timeRangeList);
|
|
|
+ if (timeRangeList.isEmpty()) return indexChartInfoVo;//日期为空,直接传回两个空list
|
|
|
+ //根据日期长度初始化纵坐标值 0
|
|
|
+ for(String timeRange:timeRangeList){
|
|
|
+ seriesDataList.add(initValue);
|
|
|
+ }
|
|
|
+ //添加横坐标列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ //添加纵坐标列表
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ List<String> tasknoList = projectCostMapper.queryTasknoListAll();
|
|
|
+ System.out.println("查到的所有部门对应的任务号列表:");
|
|
|
+ System.out.println(tasknoList);
|
|
|
+ if (tasknoList.isEmpty()) return indexChartInfoVo;
|
|
|
// System.out.println(indexChartInfoVo);
|
|
|
|
|
|
//4.计算该时间列表中某年或某月对应的总利润额
|
|
@@ -1303,7 +1577,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
//添加纵坐标列表
|
|
|
indexChartInfoVo.setSeriesData(seriesDataList2);
|
|
|
- return Result.OK(indexChartInfoVo);
|
|
|
+ return indexChartInfoVo;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1313,7 +1587,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ public IndexChartInfoVo<BigDecimal> countLreByDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
//1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,利润额为0
|
|
@@ -1341,7 +1615,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
System.out.println("获取的日期列表为:");
|
|
|
System.out.println(timeRangeList);
|
|
|
|
|
|
- if (timeRangeList.isEmpty()) return Result.OK(indexChartInfoVo);//日期为空,直接传回两个空list
|
|
|
+ if (timeRangeList.isEmpty()) return indexChartInfoVo;//日期为空,直接传回两个空list
|
|
|
//根据日期长度初始化纵坐标值 0
|
|
|
for (String timeRange : timeRangeList) {
|
|
|
seriesDataList.add(initValue);
|
|
@@ -1354,7 +1628,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
//3.通过登录的用户找到相应的部门,可能一个或两个
|
|
|
List<String> sysDepartNames = getDepNameBySysUser();
|
|
|
- if (sysDepartNames.isEmpty()) return Result.OK(indexChartInfoVo);
|
|
|
+ if (sysDepartNames.isEmpty()) return indexChartInfoVo;
|
|
|
//4.计算该时间列表中某年或某月对应的总利润额
|
|
|
List<BigDecimal> seriesDataList2 = new ArrayList<>();
|
|
|
for (String timeRange : timeRangeList) {
|
|
@@ -1363,7 +1637,77 @@ public class IndexServiceImpl implements IndexService {
|
|
|
System.out.println(timeRange + "的任务号列表:");
|
|
|
System.out.println(taskNoListNew);
|
|
|
if (taskNoListNew.size() != 0) {
|
|
|
- BigDecimal sumLreYear = countLre(taskNoListNew);
|
|
|
+ BigDecimal sumLreYear = countLreByTaskNo(taskNoListNew);
|
|
|
+ System.out.println(timeRange + "的利润额为:");
|
|
|
+ System.out.println(sumLreYear);
|
|
|
+ seriesDataList2.add(sumLreYear);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+ } else {
|
|
|
+ System.out.println(timeRange + "的利润额为:" + initValue);
|
|
|
+ seriesDataList2.add(initValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加纵坐标列表
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList2);
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 所长查看所有
|
|
|
+ * 首页二层:前端传送IndexInfoParamDto 有三个参数,都是string类型 time 年/月 beginDate 开始日期 endDate结束日期
|
|
|
+ * 跟据time来按月查或按年查
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndexChartInfoVo<BigDecimal> countLreAllByDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
+ //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
+ IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,利润额为0
|
|
|
+ //创建一个String列表用来存储横坐标日期
|
|
|
+ List<String> timeRangeList = new ArrayList<>();
|
|
|
+ //创建一个BigDecimal列表用来存储纵坐标利润
|
|
|
+ List<BigDecimal> seriesDataList = new ArrayList<>();
|
|
|
+ //初始化横纵列表都是一个空列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ //2.计算时间列表 横坐标时间string列表
|
|
|
+ //年/月
|
|
|
+ String timeType = indexInfoParamDto.getTime();
|
|
|
+ //起始时间
|
|
|
+ String startString = indexInfoParamDto.getBeginDate();
|
|
|
+ //结束时间
|
|
|
+ String endString = indexInfoParamDto.getEndDate();
|
|
|
+
|
|
|
+ if(timeType.equals("year")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
|
|
|
+ }
|
|
|
+ else if (timeType.equals("month")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy-MM", timeType);
|
|
|
+ }
|
|
|
+ System.out.println("获取的日期列表为:");
|
|
|
+ System.out.println(timeRangeList);
|
|
|
+
|
|
|
+ if (timeRangeList.isEmpty()) return indexChartInfoVo;//日期为空,直接传回两个空list
|
|
|
+ //根据日期长度初始化纵坐标值 0
|
|
|
+ for(String timeRange:timeRangeList){
|
|
|
+ seriesDataList.add(initValue);
|
|
|
+ }
|
|
|
+ //初始化横坐标有日期时,相应的纵坐标先赋一个0
|
|
|
+ //添加横坐标列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ //添加纵坐标列表
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ //4.计算该时间列表中某年或某月对应的总利润额
|
|
|
+ List<BigDecimal> seriesDataList2 = new ArrayList<>();
|
|
|
+ for(String timeRange:timeRangeList) {
|
|
|
+ //根据时间和部门去查找任务号
|
|
|
+ List<String> taskNoListNew = getTaskNoListFDepTime2(timeType, timeRange);
|
|
|
+ System.out.println(timeRange + "的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew);
|
|
|
+ if (taskNoListNew.size() != 0) {
|
|
|
+ BigDecimal sumLreYear = countLreByTaskNo(taskNoListNew);
|
|
|
System.out.println(timeRange + "的利润额为:");
|
|
|
System.out.println(sumLreYear);
|
|
|
seriesDataList2.add(sumLreYear);
|
|
@@ -1375,7 +1719,152 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
//添加纵坐标列表
|
|
|
indexChartInfoVo.setSeriesData(seriesDataList2);
|
|
|
- return Result.OK(indexChartInfoVo);
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*直接在数据库一步查询用户所在的部门列表*/
|
|
|
+// public List<String> getDepListFUid(){
|
|
|
+// // 获取登录人用户信息 V2.0版本:
|
|
|
+// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+// // 获取用户id
|
|
|
+// String userId = sysUser.getId();
|
|
|
+// //根据用户id去找部门id
|
|
|
+// List<String> sysDepartNames = indexMapper.getDepListFUid(userId);
|
|
|
+// System.out.println("用户所在部门列表为:");
|
|
|
+// System.out.println(sysDepartNames);
|
|
|
+// return sysDepartNames;
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过登录的用户找到角色
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getRolesBySysUser() {
|
|
|
+ // 获取登录人用户信息 V2.0版本:
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ // 获取用户名称
|
|
|
+ String userName = sysUser.getUsername();
|
|
|
+ //根据用户名称去查找用户角色
|
|
|
+// List<String> roleId = sysBaseApi.getRoleIdsByUsername(userName);
|
|
|
+ return sysBaseApi.getRoleIdsByUsername(userName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页一层 利润额
|
|
|
+ * 年总利润、上一年同期总利润、年同比、当月总利润、当月同比、当月环比
|
|
|
+ * 通过登录的用户找到角色,根据角色来判断部门,根据部门和实际完成时间选择任务列表,根据任务列表计算利润额
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndexTotalVo getLreByRole() {
|
|
|
+ //初始化
|
|
|
+ IndexTotalVo indexTotalVo = new IndexTotalVo();
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0);
|
|
|
+ indexTotalVo.setYearTotal(initValue);
|
|
|
+ indexTotalVo.setYearTq(initValue);
|
|
|
+ indexTotalVo.setYearTb(initValue);
|
|
|
+ indexTotalVo.setMonthTotal(initValue);
|
|
|
+ indexTotalVo.setMonthTb(initValue);
|
|
|
+ indexTotalVo.setMonthHb(initValue);
|
|
|
+
|
|
|
+// //获取角色
|
|
|
+// List<String> roleId = getRolesBySysUser();
|
|
|
+// //如果是所长,查看所有 部门领导查看本部门 员工后期增加
|
|
|
+// if(roleId.contains(AuthMark.BOSS)){
|
|
|
+// indexTotalVo = countLreAll();
|
|
|
+// }
|
|
|
+// else if(roleId.contains(AuthMark.DEPT_LEADER)){
|
|
|
+// indexTotalVo = countLre();
|
|
|
+// }
|
|
|
+ //获取角色
|
|
|
+ // 获取登录人用户信息 V2.0版本:
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String role = commonMethod.getRole(sysUser.getUsername());
|
|
|
+ if(role == null){
|
|
|
+ return indexTotalVo;
|
|
|
+ }
|
|
|
+ //如果是所长,查看所有 部门领导查看本部门 员工后期增加
|
|
|
+ if(role.equals(AuthMark.BOSS)){
|
|
|
+ System.out.println("当前账户权限:所长");
|
|
|
+ indexTotalVo = countLreAll();
|
|
|
+ } else if (role.equals(AuthMark.DEPT_LEADER)) {
|
|
|
+ System.out.println("当前账户权限:部门领导");
|
|
|
+ indexTotalVo = countLre();
|
|
|
+ }
|
|
|
+ return indexTotalVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页二层 利润额
|
|
|
+ * 通过登录的用户找到角色,根据角色来判断部门,根据部门和实际完成时间选择任务列表,根据任务列表计算利润额
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndexChartInfoVo<BigDecimal> getLreDetailByRole(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ //初始化
|
|
|
+ IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
+ //创建一个String列表用来存储横坐标日期
|
|
|
+ List<String> timeRangeList = new ArrayList<>();
|
|
|
+ //创建一个BigDecimal列表用来存储纵坐标利润
|
|
|
+ List<BigDecimal> seriesDataList = new ArrayList<>();
|
|
|
+ //初始化横纵列表都是一个空列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ //获取角色
|
|
|
+ // 获取登录人用户信息 V2.0版本:
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String role = commonMethod.getRole(sysUser.getUsername());
|
|
|
+ if(role == null){
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+ //如果是所长,查看所有 部门领导查看本部门 员工后期增加
|
|
|
+ if(role.equals(AuthMark.BOSS)){
|
|
|
+ System.out.println("当前账户权限:所长");
|
|
|
+ indexChartInfoVo = countLreAllByDate(indexInfoParamDto);
|
|
|
+ } else if (role.equals(AuthMark.DEPT_LEADER)) {
|
|
|
+ System.out.println("当前账户权限:部门领导");
|
|
|
+ indexChartInfoVo = countLreByDate(indexInfoParamDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页二层:已收款
|
|
|
+ * 通过登录的用户找到角色,根据角色来判断部门,根据部门和实际完成时间选择任务列表,根据任务列表计算利润额
|
|
|
+ * 前端传送IndexInfoParamDto 有三个参数,都是string类型 time 年/月 beginDate 开始日期 endDate结束日期
|
|
|
+ * 跟据time来按月查或按年查
|
|
|
+ *
|
|
|
+ * @param indexInfoParamDto
|
|
|
+ * @return IndexChartInfoVo<BigDecimal>
|
|
|
+ */
|
|
|
+ public IndexChartInfoVo<BigDecimal> getReceivedDetailByRoleDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
+ //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
+ IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
|
|
|
+ //创建一个String列表用来存储横坐标日期
|
|
|
+ List<String> timeRangeList = new ArrayList<>();
|
|
|
+ //创建一个BigDecimal列表用来存储纵坐标利润
|
|
|
+ List<BigDecimal> seriesDataList = new ArrayList<>();
|
|
|
+ //初始化传一个空列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ // 获取登录人用户信息 V2.0版本:
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String role = commonMethod.getRole(sysUser.getUsername());
|
|
|
+ if(role == null){
|
|
|
+ return indexChartInfoVo;
|
|
|
+ }
|
|
|
+ //如果是所长,查看所有 部门领导查看本部门 员工后期增加
|
|
|
+ if(role.equals(AuthMark.BOSS)){
|
|
|
+ indexChartInfoVo = countTotalReceivedAllByDate(indexInfoParamDto);
|
|
|
+ } else if (role.equals(AuthMark.DEPT_LEADER)) {
|
|
|
+ indexChartInfoVo = countTotalReceivedByDate(indexInfoParamDto);
|
|
|
+ }
|
|
|
+ return indexChartInfoVo;
|
|
|
}
|
|
|
|
|
|
}
|