首页接口
This commit is contained in:
parent
76f8d8793e
commit
e2c495003a
|
|
@ -0,0 +1,96 @@
|
|||
package com.bonus.gzcar.business.backstage.controller;
|
||||
|
||||
/**
|
||||
* @className:HomeIndexController
|
||||
* @author:cwchen
|
||||
* @date:2025-01-15-16:22
|
||||
* @version:1.0
|
||||
* @description:首页
|
||||
*/
|
||||
|
||||
import com.bonus.gzcar.business.backstage.entity.BackParamsDto;
|
||||
import com.bonus.gzcar.business.backstage.entity.HomeProDetailVo;
|
||||
import com.bonus.gzcar.business.backstage.service.HomeIndexService;
|
||||
import com.bonus.gzcar.manager.annotation.DecryptAndVerify;
|
||||
import com.bonus.gzcar.manager.core.entity.EncryptedReq;
|
||||
import com.bonus.gzcar.manager.webResult.ServerResponse;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "首页")
|
||||
@RestController
|
||||
@RequestMapping("/backstage/homeIndex/")
|
||||
@Slf4j
|
||||
public class HomeIndexController {
|
||||
|
||||
@Resource(name = "HomeIndexService")
|
||||
private HomeIndexService service;
|
||||
|
||||
@ApiOperation(value = "首页-数据预览")
|
||||
@PostMapping("getDataPreviewData")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getDataPreviewData(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getDataPreviewData(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-用车数量")
|
||||
@PostMapping("getVehiclesUsedNum")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getVehiclesUsedNum(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getVehiclesUsedNum(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-工程排名")
|
||||
@PostMapping("getProRanking")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getProRanking(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getProRanking(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-供应商统计")
|
||||
@PostMapping("getSupStatistics")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getSupStatistics(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getSupStatistics(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-租赁金额(运输车辆)")
|
||||
@PostMapping("getLeaseMoneyByCar")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getLeaseMoneyByCar(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getLeaseMoneyByCar(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-租赁金额(吊车)")
|
||||
@PostMapping("getLeaseMoneyByCrane")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getLeaseMoneyByCrane(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getLeaseMoneyByCrane(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-二级页面-分公司数据")
|
||||
@PostMapping("getCompanyData")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public ServerResponse getCompanyData(EncryptedReq<BackParamsDto> dto) {
|
||||
return service.getCompanyData(dto.getData());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "首页-二级页面-工程详情")
|
||||
@GetMapping("getProDetails")
|
||||
@DecryptAndVerify(decryptedClass = BackParamsDto.class)
|
||||
public PageInfo<HomeProDetailVo> getProDetails(EncryptedReq<BackParamsDto> dto) {
|
||||
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
||||
List<HomeProDetailVo> list = service.getProDetails(dto.getData());;
|
||||
return new PageInfo<>(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:BackParamsDto
|
||||
* @author:cwchen
|
||||
* @date:2024-12-17-10:52
|
||||
* @version:1.0
|
||||
* @description:web-接受参数
|
||||
*/
|
||||
@Data
|
||||
public class BackParamsDto {
|
||||
|
||||
/**分公司*/
|
||||
private String companyId;
|
||||
/**派车状态 1.已派车 2.待派车*/
|
||||
private String dispatchStatus;
|
||||
/**年份*/
|
||||
private String year;
|
||||
/**月份*/
|
||||
private String month;
|
||||
/**年月*/
|
||||
private String yearMonth;
|
||||
/**付款状态 1.已付款 2.未付款*/
|
||||
private String payStatus;
|
||||
/**类型 1.车辆 2.吊车*/
|
||||
private String type;
|
||||
/**工程名称*/
|
||||
private String proName;
|
||||
/**计划编号*/
|
||||
private String code;
|
||||
/**供应商名称*/
|
||||
private String supName;
|
||||
/**名称*/
|
||||
private String name;
|
||||
/**规格*/
|
||||
private String model;
|
||||
/**开始日期*/
|
||||
private String startTime;
|
||||
/**结束日期*/
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:HomeDataPreviewVo
|
||||
* @author:cwchen
|
||||
* @date:2025-01-15-18:36
|
||||
* @version:1.0
|
||||
* @description:首页-数据预览-vo
|
||||
*/
|
||||
@Data
|
||||
public class HomeDataPreviewVo {
|
||||
|
||||
/**工程数量*/
|
||||
private int proNum;
|
||||
/**工程数量-今日领用工程数量*/
|
||||
private int lyProNum;
|
||||
|
||||
/**需求计划数*/
|
||||
private int planNum;
|
||||
/**需求计划数-今日新增*/
|
||||
private int addPlanNum;
|
||||
|
||||
/**运输车量*/
|
||||
private int carNum;
|
||||
/**运输车量-待派车量*/
|
||||
private int noDispatchCarNum;
|
||||
|
||||
/**吊车量*/
|
||||
private int craneNum;
|
||||
/**吊车量-待派车量*/
|
||||
private int noDispatchCraneNum;
|
||||
|
||||
/**已付款金额*/
|
||||
private double payMoney;
|
||||
/**已付款金额-需求计划*/
|
||||
private int payPlanNum;
|
||||
|
||||
/**预估金额*/
|
||||
private double estimateMoney;
|
||||
/**已付款金额-需求计划*/
|
||||
private int estimatePlanNum;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:HomeLeaseMoneyVo
|
||||
* @author:cwchen
|
||||
* @date:2025-01-16-15:44
|
||||
* @version:1.0
|
||||
* @description:首页-租赁金额
|
||||
*/
|
||||
@Data
|
||||
public class HomeLeaseMoneyVo {
|
||||
|
||||
/**合同金额*/
|
||||
private double contractMoney;
|
||||
/**付款金额*/
|
||||
private double payMoney;
|
||||
/**付款金额/合同金额 比率*/
|
||||
private double progress;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:HomeProDetailVo
|
||||
* @author:cwchen
|
||||
* @date:2025-01-16-16:34
|
||||
* @version:1.0
|
||||
* @description:首页-工程详情-vo
|
||||
*/
|
||||
@Data
|
||||
public class HomeProDetailVo {
|
||||
|
||||
/**工程ID*/
|
||||
private String proId;
|
||||
/**工程名称*/
|
||||
@Excel(name = "序号", width = 10.0, orderNum = "0")
|
||||
private String proName;
|
||||
/**计划数*/
|
||||
private int planNum;
|
||||
/**已派车计划*/
|
||||
private int dispatchPlanNum;
|
||||
/**待派车计划*/
|
||||
private int noDispatchPlanNum;
|
||||
/**派车状态*/
|
||||
private String dispatchStatus;
|
||||
/**应派车数量*/
|
||||
private int shouldDispatchNum;
|
||||
/**已派车数量*/
|
||||
private int dispatchNum;
|
||||
/**待派车数量*/
|
||||
private int noDispatchNum;
|
||||
/**已派车金额*/
|
||||
private double money;
|
||||
/**所属分公司*/
|
||||
private String companyName;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:HomeProRankingVo
|
||||
* @author:cwchen
|
||||
* @date:2025-01-16-14:19
|
||||
* @version:1.0
|
||||
* @description:工程排名-vo
|
||||
*/
|
||||
@Data
|
||||
public class HomeProRankingVo {
|
||||
/**工程id*/
|
||||
private String proId;
|
||||
/**工程名称*/
|
||||
private String proName;
|
||||
/**申请量*/
|
||||
private int applyNum;
|
||||
/**派车量*/
|
||||
private int dispatchNum;
|
||||
/**待派量*/
|
||||
private int noDispatchNum;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.gzcar.business.backstage.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:HomeSupStatisticsVo
|
||||
* @author:cwchen
|
||||
* @date:2025-01-16-14:48
|
||||
* @version:1.0
|
||||
* @description:首页-供应商统计
|
||||
*/
|
||||
@Data
|
||||
public class HomeSupStatisticsVo {
|
||||
|
||||
/**合同ID*/
|
||||
private Long id;
|
||||
/**合同类型 1.车辆 2.吊车*/
|
||||
private int type;
|
||||
/**供应商名称*/
|
||||
private String supName;
|
||||
/**供应商合同占比*/
|
||||
private double contractRatio;
|
||||
/**供应商合同金额*/
|
||||
private double contractMoney;
|
||||
/**已租赁数量*/
|
||||
private int leaseNum;
|
||||
/**已租赁金额*/
|
||||
private double leaseMoney;
|
||||
/**租赁进度*/
|
||||
private double leaseProgress;
|
||||
/**最新派车时间*/
|
||||
private String dispatchTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.bonus.gzcar.business.backstage.mapper;
|
||||
|
||||
import com.bonus.gzcar.business.backstage.entity.BackParamsDto;
|
||||
import com.bonus.gzcar.business.backstage.entity.HomeProRankingVo;
|
||||
import com.bonus.gzcar.business.backstage.entity.HomeSupStatisticsVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @className:HomeIndexMapper
|
||||
* @author:cwchen
|
||||
* @date:2025-01-15-16:24
|
||||
* @version:1.0
|
||||
* @description:首页
|
||||
*/
|
||||
@Repository(value = "HomeIndexMapper")
|
||||
public interface HomeIndexMapper {
|
||||
/**
|
||||
* 数据预览-工程数量
|
||||
*
|
||||
* @param dto
|
||||
* @return Integer
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 9:27
|
||||
*/
|
||||
List<Integer> getProNum(BackParamsDto dto);
|
||||
|
||||
/**
|
||||
* 数据预览-需求计划数
|
||||
*
|
||||
* @param dto
|
||||
* @return Integer
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 9:27
|
||||
*/
|
||||
List<Integer> getNeedNum(BackParamsDto dto);
|
||||
|
||||
/**
|
||||
* 数据预览-运输车量
|
||||
*
|
||||
* @param dto
|
||||
* @param type
|
||||
* @return Integer
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 9:27
|
||||
*/
|
||||
List<Map<String, Integer>> getCarNumList(@Param("params") BackParamsDto dto, @Param("type") String type);
|
||||
|
||||
/**
|
||||
* 首页-用车数量
|
||||
*
|
||||
* @param dto
|
||||
* @param yearMonth
|
||||
* @return Integer
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 13:34
|
||||
*/
|
||||
List<Integer> getVehiclesUsedNum(@Param("params") BackParamsDto dto, @Param("yearMonth") String yearMonth, @Param("type") String type);
|
||||
|
||||
/**
|
||||
* 首页-工程排名
|
||||
*
|
||||
* @param dto
|
||||
* @return List<HomeProRankingVo>
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 14:24
|
||||
*/
|
||||
List<HomeProRankingVo> getProRanking(BackParamsDto dto);
|
||||
|
||||
/**
|
||||
* 首页-供应商统计
|
||||
*
|
||||
* @param data
|
||||
* @return List<HomeSupStatisticsVo>
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 14:53
|
||||
*/
|
||||
List<HomeSupStatisticsVo> getSupStatistics(BackParamsDto data);
|
||||
|
||||
/**
|
||||
* 首页-租赁金额(运输车辆)、吊车
|
||||
*
|
||||
* @param dto
|
||||
* @param type
|
||||
* @return HomeLeaseMoneyVo
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 15:49
|
||||
*/
|
||||
List<String> getLeaseMoney(@Param("params") BackParamsDto dto, @Param("type") int type);
|
||||
|
||||
/**
|
||||
* 首页-二级页面-分公司数据
|
||||
* @param dto
|
||||
* @return List<Map<String,String>>
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 16:41
|
||||
*/
|
||||
List<Map<String, String>> getCompanyData(BackParamsDto dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package com.bonus.gzcar.business.backstage.service;
|
||||
|
||||
import com.bonus.gzcar.business.backstage.entity.BackParamsDto;
|
||||
import com.bonus.gzcar.business.backstage.entity.HomeProDetailVo;
|
||||
import com.bonus.gzcar.manager.webResult.ServerResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:HomeIndexService
|
||||
* @author:cwchen
|
||||
* @date:2025-01-15-16:22
|
||||
* @version:1.0
|
||||
* @description:首页
|
||||
*/
|
||||
public interface HomeIndexService {
|
||||
/**
|
||||
* 首页-数据预览
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/15 18:34
|
||||
*/
|
||||
ServerResponse getDataPreviewData(BackParamsDto data);
|
||||
|
||||
/**
|
||||
* 首页-用车数量
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 13:09
|
||||
*/
|
||||
ServerResponse getVehiclesUsedNum(BackParamsDto data);
|
||||
|
||||
/**
|
||||
* 首页-工程排名
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 14:18
|
||||
*/
|
||||
ServerResponse getProRanking(BackParamsDto data);
|
||||
|
||||
/**
|
||||
* 首页-供应商统计
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 14:47
|
||||
*/
|
||||
ServerResponse getSupStatistics(BackParamsDto data);
|
||||
|
||||
/**
|
||||
*首页-租赁金额(运输车辆)
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 15:43
|
||||
*/
|
||||
ServerResponse getLeaseMoneyByCar(BackParamsDto data);
|
||||
|
||||
/**
|
||||
*首页-租赁金额(吊车)
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 15:43
|
||||
*/
|
||||
ServerResponse getLeaseMoneyByCrane(BackParamsDto data);
|
||||
|
||||
|
||||
/**
|
||||
* 首页-二级页面-分公司数据
|
||||
* @param data
|
||||
* @return ServerResponse
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 16:39
|
||||
*/
|
||||
ServerResponse getCompanyData(BackParamsDto data);
|
||||
|
||||
/**
|
||||
* 首页-二级页面-工程详情
|
||||
* @param data
|
||||
* @return List<HomeProDetailVo>
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 16:37
|
||||
*/
|
||||
List<HomeProDetailVo> getProDetails(BackParamsDto data);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,348 @@
|
|||
package com.bonus.gzcar.business.backstage.service;
|
||||
|
||||
import com.bonus.gzcar.business.backstage.entity.*;
|
||||
import com.bonus.gzcar.business.backstage.mapper.HomeIndexMapper;
|
||||
import com.bonus.gzcar.manager.common.util.DateTimeHelper;
|
||||
import com.bonus.gzcar.manager.webResult.ServerResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @className:HomeIndexServiceImpl
|
||||
* @author:cwchen
|
||||
* @date:2025-01-15-16:23
|
||||
* @version:1.0
|
||||
* @description:首页
|
||||
*/
|
||||
@Service(value = "HomeIndexService")
|
||||
@Slf4j
|
||||
public class HomeIndexServiceImpl implements HomeIndexService {
|
||||
|
||||
@Resource(name = "HomeIndexMapper")
|
||||
private HomeIndexMapper mapper;
|
||||
|
||||
@Resource(name = "testTaskExecutor")
|
||||
private ThreadPoolTaskExecutor testTaskExecutor;
|
||||
|
||||
@Override
|
||||
public ServerResponse getDataPreviewData(BackParamsDto dto) {
|
||||
HomeDataPreviewVo vo = new HomeDataPreviewVo();
|
||||
List<Integer> fList = new ArrayList<>(2);
|
||||
List<Integer> fList2 = new ArrayList<>(2);
|
||||
List<Integer> fList3 = new ArrayList<>(2);
|
||||
List<Integer> fList4 = new ArrayList<>(2);
|
||||
List<Object> fList5 = new ArrayList<>(2);
|
||||
List<Object> fList6 = new ArrayList<>(2);
|
||||
try {
|
||||
Future<List<Integer>> future = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-工程数量{}", Thread.currentThread().getName());
|
||||
List<Integer> dataList = new ArrayList<>(2);
|
||||
dataList = mapper.getProNum(dto);
|
||||
return dataList;
|
||||
});
|
||||
Future<List<Integer>> future2 = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-需求计划数{}", Thread.currentThread().getName());
|
||||
List<Integer> dataList = new ArrayList<>(2);
|
||||
dataList = mapper.getNeedNum(dto);
|
||||
return dataList;
|
||||
});
|
||||
Future<List<Integer>> future3 = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-运输车量{}", Thread.currentThread().getName());
|
||||
List<Integer> dataList = new ArrayList<>(2);
|
||||
List<Map<String, Integer>> carNumList = mapper.getCarNumList(dto, "1");
|
||||
if (CollectionUtils.isNotEmpty(carNumList)) {
|
||||
int carNum = 0, noDispatchCarNum = 0;
|
||||
for (Map<String, Integer> map : carNumList) {
|
||||
Integer needNum = map.get("needNum");
|
||||
Integer dispatchNum = map.get("dispatchNum");
|
||||
carNum += needNum;
|
||||
noDispatchCarNum += (needNum - dispatchNum);
|
||||
}
|
||||
dataList.add(0, carNum);
|
||||
dataList.add(1, noDispatchCarNum);
|
||||
} else {
|
||||
dataList.add(0, 0);
|
||||
dataList.add(1, 0);
|
||||
}
|
||||
return dataList;
|
||||
});
|
||||
Future<List<Integer>> future4 = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-吊车量{}", Thread.currentThread().getName());
|
||||
List<Integer> dataList = new ArrayList<>(2);
|
||||
List<Map<String, Integer>> carNumList = mapper.getCarNumList(dto, "2");
|
||||
if (CollectionUtils.isNotEmpty(carNumList)) {
|
||||
int craneNum = 0, noDispatchCraneNum = 0;
|
||||
for (Map<String, Integer> map : carNumList) {
|
||||
Integer needNum = map.get("needNum");
|
||||
Integer dispatchNum = map.get("dispatchNum");
|
||||
craneNum += needNum;
|
||||
noDispatchCraneNum += (needNum - dispatchNum);
|
||||
}
|
||||
dataList.add(0, craneNum);
|
||||
dataList.add(1, noDispatchCraneNum);
|
||||
} else {
|
||||
dataList.add(0, 0);
|
||||
dataList.add(1, 0);
|
||||
}
|
||||
return dataList;
|
||||
});
|
||||
Future<List<Object>> future5 = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-已付款金额{}", Thread.currentThread().getName());
|
||||
List<Object> dataList = new ArrayList<>(2);
|
||||
dataList.add(0, 0.0);
|
||||
dataList.add(1, 0);
|
||||
return dataList;
|
||||
});
|
||||
Future<List<Object>> future6 = testTaskExecutor.submit(() -> {
|
||||
log.info("数据概览-应付款金额{}", Thread.currentThread().getName());
|
||||
List<Object> dataList = new ArrayList<>(2);
|
||||
dataList.add(0, 0.0);
|
||||
dataList.add(1, 0);
|
||||
return dataList;
|
||||
});
|
||||
fList = future.get();
|
||||
fList2 = future2.get();
|
||||
fList3 = future3.get();
|
||||
fList4 = future4.get();
|
||||
fList5 = future5.get();
|
||||
fList6 = future6.get();
|
||||
vo = setHomeDataPreviewVo(vo, fList, fList2, fList3, fList4, fList5, fList6);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据预览赋值
|
||||
*
|
||||
* @param vo
|
||||
* @param fList
|
||||
* @param fList2
|
||||
* @param fList3
|
||||
* @param fList4
|
||||
* @param fList5
|
||||
* @param fList6
|
||||
* @return HomeDataPreviewVo
|
||||
* @author cwchen
|
||||
* @date 2025/1/16 9:21
|
||||
*/
|
||||
public HomeDataPreviewVo setHomeDataPreviewVo(HomeDataPreviewVo vo, List<Integer> fList,
|
||||
List<Integer> fList2, List<Integer> fList3,
|
||||
List<Integer> fList4, List<Object> fList5, List<Object> fList6) {
|
||||
vo.setProNum(fList.get(0));
|
||||
vo.setLyProNum(fList.get(1));
|
||||
vo.setPlanNum(fList2.get(0));
|
||||
vo.setAddPlanNum(fList2.get(1));
|
||||
vo.setCarNum(fList3.get(0));
|
||||
vo.setNoDispatchCarNum(fList3.get(1));
|
||||
vo.setCraneNum(fList4.get(0));
|
||||
vo.setNoDispatchCraneNum(fList4.get(1));
|
||||
vo.setPayMoney((Double) fList5.get(0));
|
||||
vo.setPayPlanNum((Integer) fList5.get(1));
|
||||
vo.setEstimateMoney((Double) fList6.get(0));
|
||||
vo.setEstimatePlanNum((Integer) fList6.get(1));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getVehiclesUsedNum(BackParamsDto dto) {
|
||||
List<Map<String, Object>> dataList = new ArrayList<>(12);
|
||||
List<String> yearMonthList = DateTimeHelper.getYearMonthByNear12();
|
||||
for (String yearMonth : yearMonthList) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("yearMonth", yearMonth);
|
||||
try {
|
||||
Future<List<Integer>> future = testTaskExecutor.submit(new Callable<List<Integer>>() {
|
||||
@Override
|
||||
public List<Integer> call() throws Exception {
|
||||
List<Integer> valueList = new ArrayList<>(2);
|
||||
List<Integer> list = mapper.getVehiclesUsedNum(dto, yearMonth, "1");
|
||||
List<Integer> list2 = mapper.getVehiclesUsedNum(dto, yearMonth, "2");
|
||||
valueList.add(0, handleValueList(list));
|
||||
valueList.add(1, handleValueList(list2));
|
||||
return valueList;
|
||||
}
|
||||
});
|
||||
List<Integer> valueList = future.get();
|
||||
map.put("value", valueList.get(0));
|
||||
map.put("value2", valueList.get(1));
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
dataList.add(map);
|
||||
}
|
||||
return ServerResponse.createSuccess(dataList);
|
||||
}
|
||||
|
||||
public static Integer handleValueList(List<Integer> list) {
|
||||
int valueData = 0;
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (Integer value : list) {
|
||||
valueData += value;
|
||||
}
|
||||
}
|
||||
return valueData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getProRanking(BackParamsDto dto) {
|
||||
List<HomeProRankingVo> dataList = new ArrayList<HomeProRankingVo>();
|
||||
List<HomeProRankingVo> sortList = new ArrayList<HomeProRankingVo>();
|
||||
List<HomeProRankingVo> list = new ArrayList<HomeProRankingVo>();
|
||||
try {
|
||||
list = mapper.getProRanking(dto);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
Map<String, List<HomeProRankingVo>> mapData = list.stream().collect(Collectors.groupingBy(item -> {
|
||||
return (String) item.getProId();
|
||||
}));
|
||||
mapData.forEach((k, v) -> {
|
||||
HomeProRankingVo vo = new HomeProRankingVo();
|
||||
// 申请量、派车量、待派车量累加
|
||||
int applyNum = 0, dispatchNum = 0, noDispatchNum = 0;
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
applyNum += v.get(i).getApplyNum();
|
||||
dispatchNum += v.get(i).getDispatchNum();
|
||||
noDispatchNum += v.get(i).getApplyNum() - v.get(i).getDispatchNum();
|
||||
}
|
||||
vo.setProId(v.get(0).getProId());
|
||||
vo.setProName(v.get(0).getProName());
|
||||
vo.setApplyNum(applyNum);
|
||||
vo.setDispatchNum(dispatchNum);
|
||||
vo.setNoDispatchNum(noDispatchNum);
|
||||
dataList.add(vo);
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
sortList = dataList.stream().sorted(Comparator.comparing(HomeProRankingVo::getApplyNum).reversed()).collect(Collectors.toList());
|
||||
return ServerResponse.createSuccess(sortList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getSupStatistics(BackParamsDto data) {
|
||||
List<Map<String, Object>> sortList = new ArrayList<>();
|
||||
List<HomeSupStatisticsVo> list = new ArrayList<HomeSupStatisticsVo>();
|
||||
try {
|
||||
list = mapper.getSupStatistics(data);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
Map<Long, List<HomeSupStatisticsVo>> mapData = list.stream().collect(Collectors.groupingBy(item -> {
|
||||
return item.getId();
|
||||
}));
|
||||
mapData.forEach((k, v) -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<HomeSupStatisticsVo> dataList = new ArrayList<>();
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
HomeSupStatisticsVo vo = v.get(i);
|
||||
vo.setDispatchTime(vo.getDispatchTime() == null ? "--" : vo.getDispatchTime());
|
||||
dataList.add(vo);
|
||||
}
|
||||
map.put("id", v.get(0).getId());
|
||||
map.put("type", v.get(0).getType());
|
||||
map.put("list", dataList);
|
||||
sortList.add(map);
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(sortList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getLeaseMoneyByCar(BackParamsDto dto) {
|
||||
HomeLeaseMoneyVo vo = new HomeLeaseMoneyVo();
|
||||
try {
|
||||
// 合同金额
|
||||
List<String> list = mapper.getLeaseMoney(dto, 1);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
double v = handleMoney(list);
|
||||
vo.setContractMoney(v);
|
||||
}
|
||||
double progress = handleProgress(vo.getContractMoney(), vo.getPayMoney());
|
||||
vo.setProgress(progress);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getLeaseMoneyByCrane(BackParamsDto dto) {
|
||||
HomeLeaseMoneyVo vo = new HomeLeaseMoneyVo();
|
||||
try {
|
||||
// 合同金额
|
||||
List<String> list = mapper.getLeaseMoney(dto, 2);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
double v = handleMoney(list);
|
||||
vo.setContractMoney(v);
|
||||
}
|
||||
double progress = handleProgress(vo.getContractMoney(), vo.getPayMoney());
|
||||
vo.setProgress(progress);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createSuccess(vo);
|
||||
}
|
||||
|
||||
public double handleMoney(List<String> list) {
|
||||
BigDecimal initBd = new BigDecimal("0");
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (String money : list) {
|
||||
initBd = initBd.add(new BigDecimal(money));
|
||||
}
|
||||
}
|
||||
return initBd.doubleValue();
|
||||
}
|
||||
|
||||
public double handleProgress(double value, double value2) {
|
||||
if (value > 0) {
|
||||
// value 合同金额 value2 付款金额
|
||||
BigDecimal a = BigDecimal.valueOf(value);
|
||||
BigDecimal b = BigDecimal.valueOf(value2);
|
||||
// 设置保留两位小数,并进行四舍五入
|
||||
BigDecimal result = b.divide(a, 2, RoundingMode.HALF_UP);
|
||||
return result.doubleValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getCompanyData(BackParamsDto dto) {
|
||||
List<Map<String,String>> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.getCompanyData(dto);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createSuccess(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HomeProDetailVo> getProDetails(BackParamsDto data) {
|
||||
List<HomeProDetailVo> list = new ArrayList<>();
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import org.apache.commons.lang3.time.DateUtils;
|
|||
|
||||
import java.text.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -788,4 +789,18 @@ public class DateTimeHelper {
|
|||
}
|
||||
return 0 + "小时" + 0 + "分钟";
|
||||
}
|
||||
|
||||
public static List<String> getYearMonthByNear12(){
|
||||
List<String> yearMonthList = new ArrayList<>(12);
|
||||
// 获取当前年月
|
||||
YearMonth currentYearMonth = YearMonth.now();
|
||||
yearMonthList.add(0, currentYearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
|
||||
// 获取前十一个月的年月
|
||||
for (int i = 0; i < 11; i++) {
|
||||
YearMonth previousYearMonth = currentYearMonth.minusMonths(i + 1);
|
||||
String yearMonth = previousYearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
yearMonthList.add(i + 1, yearMonth);
|
||||
}
|
||||
return yearMonthList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
package com.bonus.gzcar.manager.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author cw chen
|
||||
* @description TODO
|
||||
* @date 2022-08-22 14:42
|
||||
*/
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
public class SpringThreadPoolConfig {
|
||||
/**
|
||||
* 核心线程数(默认线程数)
|
||||
*/
|
||||
private int corePoolSize = 10;
|
||||
|
||||
/**
|
||||
* 最大线程数
|
||||
*/
|
||||
private int maxPoolSize = 10;
|
||||
|
||||
/**
|
||||
* 允许线程空闲时间(单位:默认为秒)
|
||||
*/
|
||||
private int keepAliveTime = 10;
|
||||
|
||||
/**
|
||||
* 缓冲队列数
|
||||
*/
|
||||
private int queueCapacity = 200;
|
||||
|
||||
/**
|
||||
* 线程池名前缀
|
||||
*/
|
||||
private String threadNamePrefix = "custom-executor";
|
||||
|
||||
@Bean("testTaskExecutor")
|
||||
public ThreadPoolTaskExecutor taskExecutor1() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
//设置核心线程数
|
||||
executor.setCorePoolSize(corePoolSize);
|
||||
//设置最大线程数
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
//线程池所使用的缓冲队列
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
//等待任务在关机时完成--表明等待所有线程执行完
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
// 等待时间 (默认为0,此时立即停止),并没等待xx秒后强制停止
|
||||
executor.setKeepAliveSeconds(keepAliveTime);
|
||||
// 线程名称前缀
|
||||
executor.setThreadNamePrefix(threadNamePrefix);
|
||||
// 线程池对拒绝任务的处理策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 初始化
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.gzcar.business.backstage.mapper.HomeIndexMapper">
|
||||
|
||||
<!--数据预览-工程数量-->
|
||||
<select id="getProNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(DISTINCT pro_id)
|
||||
FROM car_plan_apply cpa
|
||||
<where>
|
||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||
AND DATE_FORMAT(cpa.create_time,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1'
|
||||
</where>
|
||||
UNION ALL
|
||||
SELECT COUNT(DISTINCT pro_id)
|
||||
FROM car_plan_apply cpa
|
||||
<where>
|
||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||
AND DATE_FORMAT(cpa.create_time,'%Y-%m-%d') = CURRENT_DATE
|
||||
</if>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--数据预览-需求计划数-->
|
||||
<select id="getNeedNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM car_plan_apply cpa
|
||||
<where>
|
||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||
AND DATE_FORMAT(cpa.create_time,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1'
|
||||
</where>
|
||||
UNION ALL
|
||||
SELECT COUNT(*)
|
||||
FROM car_plan_apply cpa
|
||||
<where>
|
||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||
AND DATE_FORMAT(cpa.create_time,'%Y-%m-%d') = CURRENT_DATE
|
||||
</if>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--数据预览-运输车量/吊车量-->
|
||||
<select id="getCarNumList" resultType="java.util.Map">
|
||||
SELECT cpa.need_num AS needNum,dispatch_num AS dispatchNum
|
||||
FROM car_plan_apply cpa
|
||||
<where>
|
||||
<if test="params.startTime!=null and params.startTime!='' and params.endTime!=null and params.endTime!=''">
|
||||
AND DATE_FORMAT(cpa.create_time,'%Y-%m-%d') BETWEEN #{params.startTime} AND #{params.endTime}
|
||||
</if>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1' AND cpa.type = #{type}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--首页-用车数量-->
|
||||
<select id="getVehiclesUsedNum" resultType="java.lang.Integer">
|
||||
SELECT dispatch_num AS num
|
||||
FROM car_plan_out cpo
|
||||
<where>
|
||||
AND DATE_FORMAT(STR_TO_DATE(cpo.out_time, '%Y-%m-%d'), '%Y-%m') = #{yearMonth}
|
||||
AND cpo.`status` = '1' AND cpo.type = #{type}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--首页-工程排名-->
|
||||
<select id="getProRanking" resultType="com.bonus.gzcar.business.backstage.entity.HomeProRankingVo">
|
||||
SELECT bp.name AS proName,
|
||||
cpa.pro_id AS proId,
|
||||
cpa.need_num AS applyNum,
|
||||
cpa.dispatch_num AS dispatchNum
|
||||
FROM car_plan_apply cpa
|
||||
LEFT JOIN bm_project bp ON cpa.pro_id = bp.bid_id
|
||||
<where>
|
||||
AND cpa.`status` = '2' AND cpa.status_type = '1'
|
||||
</where>
|
||||
</select>
|
||||
<!--首页-供应商统计-->
|
||||
<select id="getSupStatistics" resultType="com.bonus.gzcar.business.backstage.entity.HomeSupStatisticsVo">
|
||||
SELECT cc.id,
|
||||
ccr.ratio AS contractRatio,
|
||||
ccr.ratio_money AS contractMoney,
|
||||
ccr.sup_name AS supName,
|
||||
cc.type AS type
|
||||
FROM car_contract cc
|
||||
LEFT JOIN car_contract_relation ccr ON cc.id = ccr.contract_id
|
||||
WHERE cc.is_active = '1'
|
||||
ORDER BY cc.create_time DESC
|
||||
</select>
|
||||
|
||||
<!--首页-租赁金额 type:1(运输车辆)、2.吊车-->
|
||||
<select id="getLeaseMoney" resultType="java.lang.String">
|
||||
<if test="type == 1">
|
||||
SELECT money
|
||||
FROM car_contract cc
|
||||
WHERE type = 1 AND is_active = '1'
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
SELECT money
|
||||
FROM car_contract cc
|
||||
WHERE type = 2 AND is_active = '1'
|
||||
</if>
|
||||
</select>
|
||||
<!--首页-二级页面-分公司数据-->
|
||||
<select id="getCompanyData" resultType="java.util.Map">
|
||||
SELECT bc.ID AS `id`,
|
||||
bc.NAME AS `name`
|
||||
FROM bm_company bc
|
||||
WHERE IS_ACTIVE = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue