机具一览表

This commit is contained in:
mashuai 2025-03-28 11:16:07 +08:00
parent 93574630ed
commit 32822b3f6a
10 changed files with 857 additions and 108 deletions

View File

@ -1,8 +1,8 @@
package com.bonus.material.main.controller; package com.bonus.material.main.controller;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.main.domain.DemandAndSupplyVo; import com.bonus.material.main.domain.DemandAndSupplyVo;
import com.bonus.material.main.domain.MaTypeHomeVo;
import com.bonus.material.main.service.MainService; import com.bonus.material.main.service.MainService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -12,8 +12,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import static com.bonus.common.core.web.domain.AjaxResult.success; import static com.bonus.common.core.web.domain.AjaxResult.success;
@ -28,50 +26,112 @@ public class MainController {
private MainService mainService; private MainService mainService;
/** /**
* 查询机具设备管理列表 * 查询机具需求供应情况
*/ */
@GetMapping("/demandAndSupply") @GetMapping("/demandAndSupply")
public AjaxResult demandAndSupply(DemandAndSupplyVo demandAndSupplyVo) public AjaxResult demandAndSupply(DemandAndSupplyVo demandAndSupplyVo)
{ {
//Long userId = SecurityUtils.getUserId();
//demandAndSupplyVo.setUserId(userId == 0 ? null : userId);
if (demandAndSupplyVo.getStartTime() ==null || demandAndSupplyVo.getStartTime() ==" "){
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//获取当前时间
LocalDate currentDate = LocalDate.now();
String currentDateStr = currentDate.format(formatter);
// 获取本月第一天的日期
LocalDate firstDayOfMonth = currentDate.withDayOfMonth(1);
String firstDayOfMonthStr = firstDayOfMonth.format(formatter);
demandAndSupplyVo.setStartTime(firstDayOfMonthStr);
demandAndSupplyVo.setEndTime(currentDateStr);
}
DemandAndSupplyVo demandAndSupplyVoRes = new DemandAndSupplyVo(); DemandAndSupplyVo demandAndSupplyVoRes = new DemandAndSupplyVo();
//需求量 try {
BigDecimal demandNum = mainService.getDemandNum(demandAndSupplyVo); //需求量
//需求增长量 BigDecimal demandNum = mainService.getDemandNum(demandAndSupplyVo);
BigDecimal demandIncrease = mainService.getDemandIncrease(demandAndSupplyVo); //需求增长量
//已供应数量 BigDecimal demandIncrease = mainService.getDemandIncrease(demandAndSupplyVo);
BigDecimal suppliedQuantityNum = mainService.getSuppliedQuantityNum(demandAndSupplyVo); //已供应数量
//已供应增长量 BigDecimal suppliedQuantityNum = mainService.getSuppliedQuantityNum(demandAndSupplyVo);
BigDecimal suppliedQuantityIncrease = mainService.getSuppliedQuantityIncrease(demandAndSupplyVo); //已供应增长量
//待供应量 BigDecimal suppliedQuantityIncrease = mainService.getSuppliedQuantityIncrease(demandAndSupplyVo);
BigDecimal suppliedToBeQuantityNum = mainService.getSuppliedToBeQuantityNum(demandAndSupplyVo); //待供应量
//待供应量增长量 BigDecimal suppliedToBeQuantityNum = mainService.getSuppliedToBeQuantityNum(demandAndSupplyVo);
BigDecimal suppliedToBeQuantityIncrease = mainService.getSuppliedToBeQuantityIncrease(demandAndSupplyVo); //待供应量增长量
//工程总数量 BigDecimal suppliedToBeQuantityIncrease = mainService.getSuppliedToBeQuantityIncrease(demandAndSupplyVo);
Integer projectNum = mainService.getProjectNum(demandAndSupplyVo); //获取未结算工程总数量
//供应总件数 Integer projectNum = mainService.getProjectNum(demandAndSupplyVo);
//供应总件数(机具出库数量不带条件查询)
demandAndSupplyVoRes.setDemandNum(demandNum); BigDecimal outNum = mainService.getSuppliedQuantityNum(new DemandAndSupplyVo());
demandAndSupplyVoRes.setDemandIncrease(demandIncrease); // 供应总价值
demandAndSupplyVoRes.setSuppliedQuantityNum(suppliedQuantityNum); BigDecimal suppliedQuantityPrice = mainService.getSuppliedQuantityPrice(new DemandAndSupplyVo());
demandAndSupplyVoRes.setSuppliedQuantityIncrease(suppliedQuantityIncrease); demandAndSupplyVoRes.setDemandNum(demandNum);
demandAndSupplyVoRes.setSuppliedToBeQuantityNum(suppliedToBeQuantityNum); demandAndSupplyVoRes.setDemandIncrease(demandIncrease);
demandAndSupplyVoRes.setSuppliedToBeQuantityIncrease(suppliedToBeQuantityIncrease); demandAndSupplyVoRes.setSuppliedQuantityNum(suppliedQuantityNum);
demandAndSupplyVoRes.setProjectNum(projectNum); demandAndSupplyVoRes.setSuppliedQuantityIncrease(suppliedQuantityIncrease);
demandAndSupplyVoRes.setSuppliedToBeQuantityNum(suppliedToBeQuantityNum);
demandAndSupplyVoRes.setSuppliedToBeQuantityIncrease(suppliedToBeQuantityIncrease);
demandAndSupplyVoRes.setProjectNum(projectNum);
demandAndSupplyVoRes.setSuppliedQuantityAllNum(outNum);
demandAndSupplyVoRes.setSuppliedQuantityPrice(suppliedQuantityPrice);
} catch (Exception e) {
return AjaxResult.error("查询机具需求供应情况失败");
}
return success(demandAndSupplyVoRes); return success(demandAndSupplyVoRes);
} }
/**
* 查询机具仓储状态首页
* @param dto
* @return
*/
@GetMapping("/getMaTypeHomeList")
public AjaxResult getMaTypeHome(MaTypeHomeVo dto) {
// 根据时间段查询当前仓储状态详情数据
try {
return mainService.getInStockNum(dto);
} catch (Exception e) {
return AjaxResult.error("查询机具仓储状态首页失败");
}
}
/**
* todo 查询机具状态统计占比饼图暂时弃用
* @param dto
* @return
*/
@GetMapping("/getMaTypeStatusTotal")
public AjaxResult getMaTypeStatusTotal(MaTypeHomeVo dto) {
// 根据时间段查询当前仓储状态详情数据
try {
return mainService.getMaTypeStatusTotal(dto);
} catch (Exception e) {
return AjaxResult.error("查询机具状态统计占比饼图失败");
}
}
/**
* 查询机具需求供应情况统计占比饼图
* @param demandAndSupplyVo
* @return
*/
@GetMapping("/getDemandTotal")
public AjaxResult getDemandTotal(DemandAndSupplyVo demandAndSupplyVo) {
DemandAndSupplyVo vo = null;
try {
vo = new DemandAndSupplyVo();
//需求量
BigDecimal demandNum = mainService.getDemandNum(demandAndSupplyVo);
//已供应数量
BigDecimal suppliedQuantityNum = mainService.getSuppliedQuantityNum(demandAndSupplyVo);
//待供应量
BigDecimal suppliedToBeQuantityNum = mainService.getSuppliedToBeQuantityNum(demandAndSupplyVo);
vo.setDemandNum(demandNum);
vo.setSuppliedQuantityNum(suppliedQuantityNum);
vo.setSuppliedToBeQuantityNum(suppliedToBeQuantityNum);
} catch (Exception e) {
return AjaxResult.error("查询机具需求供应情况统计占比饼图失败");
}
return success(vo);
}
/**
* 查询机具需求供应情况统计柱状图
* @param demandAndSupplyVo
* @return
*/
@GetMapping("/getDemandList")
public AjaxResult getDemandList(DemandAndSupplyVo demandAndSupplyVo) {
try {
return mainService.getDemandList(demandAndSupplyVo);
} catch (Exception e) {
return AjaxResult.error("查询机具需求供应情况统计柱状图失败");
}
}
} }

View File

@ -5,6 +5,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List;
@Data @Data
public class DemandAndSupplyVo { public class DemandAndSupplyVo {
@ -70,4 +71,48 @@ public class DemandAndSupplyVo {
* 当前时间 * 当前时间
*/ */
private LocalDate currentDate; private LocalDate currentDate;
@ApiModelProperty(value = "往来单位id")
private Long unitId;
@ApiModelProperty(value = "工程id")
private Long projectId;
@ApiModelProperty(value = "设备单价")
private BigDecimal buyPrice;
/**
* 设备类型id
*/
private Long typeId;
/**
* 设备类型名称
*/
private String typeName;
/**
* 规格型号
*/
private String typeModelName;
/**
* 设备类型名称集合
*/
private List<String> typeNameList;
/**
* 需求量集合
*/
private List<BigDecimal> demandNumList;
/**
* 已供应量集合
*/
private List<BigDecimal> suppliedQuantityNumList;
/**
* 待供应量集合
*/
private List<BigDecimal> suppliedToBeQuantityNumList;
} }

View File

@ -0,0 +1,102 @@
package com.bonus.material.main.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 首页仓储状态供应一览表
* @Author ma_sh
* @create 2025/3/27 14:25
*/
@Data
public class MaTypeHomeVo {
/**
* 在库数量
*/
private BigDecimal inStockNum;
/**
* 在库增长量
*/
private BigDecimal inStockIncrease;
/**
* 在用数量
*/
private BigDecimal inUseNum;
/**
* 在用增长量
*/
private BigDecimal inUseIncrease;
/**
* 在修数量
*/
private BigDecimal inRepairNum;
/**
* 在修增长量
*/
private BigDecimal inRepairIncrease;
/**
* 新购待入库量
*/
private BigDecimal newPurchaseNum;
/**
* 新购待入库增长量
*/
private BigDecimal newPurchaseIncrease;
/**
* 修饰待入库量
*/
private BigDecimal newRepairNum;
/**
* 修饰待入库增长量
*/
private BigDecimal newRepairIncrease;
/**
* 在库量占比
*/
private BigDecimal inStockProportion;
/**
* 在用量占比
*/
private BigDecimal inUseProportion;
/**
* 在修量占比
*/
private BigDecimal inRepairProportion;
/**
* 新购待入库量占比
*/
private BigDecimal newPurchaseProportion;
/**
* 修饰待入库量占比
*/
private BigDecimal newRepairProportion;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "往来单位id")
private Long unitId;
@ApiModelProperty(value = "工程id")
private Long projectId;
}

View File

@ -2,16 +2,71 @@ package com.bonus.material.main.mapper;
import com.bonus.common.biz.domain.lease.LeasePublishInfo; import com.bonus.common.biz.domain.lease.LeasePublishInfo;
import com.bonus.material.main.domain.DemandAndSupplyVo; import com.bonus.material.main.domain.DemandAndSupplyVo;
import com.bonus.material.main.domain.MaTypeHomeVo;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
public interface MainMapper { public interface MainMapper {
List<LeasePublishInfo> getPublishList(DemandAndSupplyVo demandAndSupplyVo); /**
* 获取领料需求数量
* @param demandAndSupplyVo
* @return
*/
LeasePublishInfo getPublishList(DemandAndSupplyVo demandAndSupplyVo);
/**
* 获取领用发布数量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getPublishListNew(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getPublishListNew(DemandAndSupplyVo demandAndSupplyVo);
/**
* 获取领料已出库数量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo);
/**
* 获取工程总数
* @return
*/
Integer getProjectNum(); Integer getProjectNum();
/**
* 供应总价值
* @param demandAndSupplyVo
* @return
*/
List<DemandAndSupplyVo> getSuppliedQuantityPrice(DemandAndSupplyVo demandAndSupplyVo);
/**
* 查询领料需求列表
* @param demandAndSupplyVo
* @return
*/
List<DemandAndSupplyVo> getDemandList(DemandAndSupplyVo demandAndSupplyVo);
/**
* 查询领用需求列表
* @param demandAndSupplyVo
* @return
*/
List<DemandAndSupplyVo> getUseList(DemandAndSupplyVo demandAndSupplyVo);
/**
* 查询领用已出库列表
* @param demandAndSupplyVo
* @return
*/
List<DemandAndSupplyVo> getSuppliedQuantityList(DemandAndSupplyVo demandAndSupplyVo);
/**
* 获取所选当前时间数据
* @param dto
* @return
*/
MaTypeHomeVo getInStockNum(MaTypeHomeVo dto);
} }

View File

@ -1,21 +1,86 @@
package com.bonus.material.main.service; package com.bonus.material.main.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.main.domain.DemandAndSupplyVo; import com.bonus.material.main.domain.DemandAndSupplyVo;
import com.bonus.material.main.domain.MaTypeHomeVo;
import java.math.BigDecimal; import java.math.BigDecimal;
public interface MainService { public interface MainService {
/**
* 需求数量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getDemandNum(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getDemandNum(DemandAndSupplyVo demandAndSupplyVo);
/**
* 需求数量增长量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getDemandIncrease(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getDemandIncrease(DemandAndSupplyVo demandAndSupplyVo);
/**
* 已供应数量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo);
/**
* 已供应数量增长量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedQuantityIncrease(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getSuppliedQuantityIncrease(DemandAndSupplyVo demandAndSupplyVo);
/**
* 待供应数量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedToBeQuantityNum(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getSuppliedToBeQuantityNum(DemandAndSupplyVo demandAndSupplyVo);
/**
* 待供应数量增长量
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedToBeQuantityIncrease(DemandAndSupplyVo demandAndSupplyVo); BigDecimal getSuppliedToBeQuantityIncrease(DemandAndSupplyVo demandAndSupplyVo);
/**
* 未结算工程数量
* @param demandAndSupplyVo
* @return
*/
Integer getProjectNum(DemandAndSupplyVo demandAndSupplyVo); Integer getProjectNum(DemandAndSupplyVo demandAndSupplyVo);
/**
* 供应总价值
* @param demandAndSupplyVo
* @return
*/
BigDecimal getSuppliedQuantityPrice(DemandAndSupplyVo demandAndSupplyVo);
/**
* 根据时间段查询当前仓储状态详情数据
* @param dto
* @return
*/
AjaxResult getInStockNum(MaTypeHomeVo dto);
/**
* 需求列表
* @param demandAndSupplyVo
* @return
*/
AjaxResult getDemandList(DemandAndSupplyVo demandAndSupplyVo);
/**
* 查询机具状态统计占比饼图
* @param dto
* @return
*/
AjaxResult getMaTypeStatusTotal(MaTypeHomeVo dto);
} }

View File

@ -1,9 +1,9 @@
package com.bonus.material.main.service.impl; package com.bonus.material.main.service.impl;
import com.bonus.common.biz.domain.lease.LeasePublishInfo; import com.bonus.common.biz.domain.lease.LeasePublishInfo;
import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.main.domain.DemandAndSupplyVo; import com.bonus.material.main.domain.DemandAndSupplyVo;
import com.bonus.material.main.domain.MaTypeHomeVo;
import com.bonus.material.main.mapper.MainMapper; import com.bonus.material.main.mapper.MainMapper;
import com.bonus.material.main.service.MainService; import com.bonus.material.main.service.MainService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -16,9 +16,11 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.bonus.common.core.web.domain.AjaxResult.success;
@Service @Service
@Slf4j @Slf4j
public class MainServiceImpl implements MainService { public class MainServiceImpl implements MainService {
@ -34,9 +36,8 @@ public class MainServiceImpl implements MainService {
@Override @Override
public BigDecimal getDemandNum(DemandAndSupplyVo demandAndSupplyVo) { public BigDecimal getDemandNum(DemandAndSupplyVo demandAndSupplyVo) {
//获取领料的需求数量 //获取领料的需求数量
List<LeasePublishInfo> list = mainMapper.getPublishList(demandAndSupplyVo); LeasePublishInfo leasePublishInfo = mainMapper.getPublishList(demandAndSupplyVo);
BigDecimal preCountNum = list.stream().map(LeasePublishInfo::getPreCountNum) BigDecimal preCountNum = leasePublishInfo.getPreCountNum();
.reduce(BigDecimal.ZERO, BigDecimal::add);
//获取领用的需求数量 //获取领用的需求数量
BigDecimal preCountNumNew = mainMapper.getPublishListNew(demandAndSupplyVo); BigDecimal preCountNumNew = mainMapper.getPublishListNew(demandAndSupplyVo);
preCountNum = preCountNum.add(preCountNumNew); preCountNum = preCountNum.add(preCountNumNew);
@ -70,9 +71,11 @@ public class MainServiceImpl implements MainService {
BigDecimal lastPreCountNum = this.getDemandNum(demandAndSupplyVoNew); BigDecimal lastPreCountNum = this.getDemandNum(demandAndSupplyVoNew);
//计算增长量 //计算增长量
BigDecimal demandIncrease= BigDecimal.ZERO; BigDecimal demandIncrease= BigDecimal.ZERO;
if (lastPreCountNum.compareTo(BigDecimal.ZERO)==0){ if (lastPreCountNum.compareTo(BigDecimal.ZERO)==0 && preCountNum.compareTo(BigDecimal.ZERO) > 0){
demandIncrease = BigDecimal.valueOf(100); demandIncrease = BigDecimal.valueOf(100);
}else { }else if (preCountNum.compareTo(BigDecimal.ZERO)==0 && lastPreCountNum.compareTo(BigDecimal.ZERO) > 0){
demandIncrease = BigDecimal.valueOf(-100);
}else if (lastPreCountNum.compareTo(BigDecimal.ZERO) > 0){
demandIncrease = preCountNum.subtract(lastPreCountNum).divide(lastPreCountNum, 4, RoundingMode.HALF_UP); demandIncrease = preCountNum.subtract(lastPreCountNum).divide(lastPreCountNum, 4, RoundingMode.HALF_UP);
demandIncrease = demandIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP); demandIncrease = demandIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
} }
@ -88,8 +91,7 @@ public class MainServiceImpl implements MainService {
@Override @Override
public BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo) { public BigDecimal getSuppliedQuantityNum(DemandAndSupplyVo demandAndSupplyVo) {
//已供应量 //已供应量
BigDecimal suppliedQuantityNum = mainMapper.getSuppliedQuantityNum(demandAndSupplyVo); return mainMapper.getSuppliedQuantityNum(demandAndSupplyVo);
return suppliedQuantityNum;
} }
/** /**
@ -119,9 +121,11 @@ public class MainServiceImpl implements MainService {
BigDecimal lastSuppliedQuantityNum = this.getSuppliedQuantityNum(demandAndSupplyVoNew); BigDecimal lastSuppliedQuantityNum = this.getSuppliedQuantityNum(demandAndSupplyVoNew);
//计算增长量 //计算增长量
BigDecimal suppliedQuantityIncrease = BigDecimal.ZERO; BigDecimal suppliedQuantityIncrease = BigDecimal.ZERO;
if (lastSuppliedQuantityNum.compareTo(BigDecimal.ZERO)==0){ if (lastSuppliedQuantityNum.compareTo(BigDecimal.ZERO)==0 && suppliedQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedQuantityIncrease = BigDecimal.valueOf(100); suppliedQuantityIncrease = BigDecimal.valueOf(100);
}else { }else if (suppliedQuantityNum.compareTo(BigDecimal.ZERO)==0 && lastSuppliedQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedQuantityIncrease = BigDecimal.valueOf(-100);
} else if (lastSuppliedQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedQuantityIncrease = suppliedQuantityNum.subtract(lastSuppliedQuantityNum).divide(lastSuppliedQuantityNum, 4, RoundingMode.HALF_UP); suppliedQuantityIncrease = suppliedQuantityNum.subtract(lastSuppliedQuantityNum).divide(lastSuppliedQuantityNum, 4, RoundingMode.HALF_UP);
suppliedQuantityIncrease = suppliedQuantityIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP); suppliedQuantityIncrease = suppliedQuantityIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
} }
@ -172,9 +176,11 @@ public class MainServiceImpl implements MainService {
BigDecimal lastSuppliedToBeQuantityNum = this.getSuppliedToBeQuantityNum(demandAndSupplyVoNew); BigDecimal lastSuppliedToBeQuantityNum = this.getSuppliedToBeQuantityNum(demandAndSupplyVoNew);
//计算增长量 //计算增长量
BigDecimal suppliedToBeQuantityIncrease = BigDecimal.ZERO; BigDecimal suppliedToBeQuantityIncrease = BigDecimal.ZERO;
if (lastSuppliedToBeQuantityNum.compareTo(BigDecimal.ZERO)==0){ if (lastSuppliedToBeQuantityNum.compareTo(BigDecimal.ZERO)==0 && suppliedToBeQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedToBeQuantityIncrease = BigDecimal.valueOf(100); suppliedToBeQuantityIncrease = BigDecimal.valueOf(100);
}else { }else if (suppliedToBeQuantityNum.compareTo(BigDecimal.ZERO)==0 && lastSuppliedToBeQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedToBeQuantityIncrease = BigDecimal.valueOf(-100);
}else if (lastSuppliedToBeQuantityNum.compareTo(BigDecimal.ZERO) > 0){
suppliedToBeQuantityIncrease = suppliedToBeQuantityNum.subtract(lastSuppliedToBeQuantityNum).divide(lastSuppliedToBeQuantityNum, 4, RoundingMode.HALF_UP); suppliedToBeQuantityIncrease = suppliedToBeQuantityNum.subtract(lastSuppliedToBeQuantityNum).divide(lastSuppliedToBeQuantityNum, 4, RoundingMode.HALF_UP);
suppliedToBeQuantityIncrease = suppliedToBeQuantityIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP); suppliedToBeQuantityIncrease = suppliedToBeQuantityIncrease.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
} }
@ -182,7 +188,7 @@ public class MainServiceImpl implements MainService {
} }
/** /**
* 工程总量 * 获取未结算工程总数
* @param demandAndSupplyVo * @param demandAndSupplyVo
* @return * @return
*/ */
@ -190,4 +196,240 @@ public class MainServiceImpl implements MainService {
public Integer getProjectNum(DemandAndSupplyVo demandAndSupplyVo) { public Integer getProjectNum(DemandAndSupplyVo demandAndSupplyVo) {
return mainMapper.getProjectNum(); return mainMapper.getProjectNum();
} }
/**
* 供应总价值
* @param demandAndSupplyVo
* @return
*/
@Override
public BigDecimal getSuppliedQuantityPrice(DemandAndSupplyVo demandAndSupplyVo) {
BigDecimal supplyPrice = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
List<DemandAndSupplyVo> list = mainMapper.getSuppliedQuantityPrice(demandAndSupplyVo);
if (!CollectionUtils.isEmpty(list)) {
for (DemandAndSupplyVo andSupplyVo : list) {
supplyPrice = supplyPrice.add(andSupplyVo.getSuppliedQuantityNum().multiply(andSupplyVo.getBuyPrice()));
}
// 总计算结果换算为万元
supplyPrice = supplyPrice.divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP);
}
return supplyPrice;
}
/**
* 根据时间段查询当前仓储状态详情数据
* @param dto
* @return
*/
@Override
public AjaxResult getInStockNum(MaTypeHomeVo dto) {
// 根据时间段查询当前仓储状态详情数据
// 获取所选当前时间数据
MaTypeHomeVo resultVo = mainMapper.getInStockNum(dto);
// 根据所选时间段查询上一个月的数据
if (dto.getStartTime() != null && !dto.getStartTime().isEmpty() && dto.getEndTime() != null && !dto.getEndTime().isEmpty()) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
LocalDate startDate = LocalDate.parse(dto.getStartTime(), formatter);
LocalDate endDate = LocalDate.parse(dto.getEndTime(), formatter);
// 获取上月同期开始时间
LocalDate lastMonthStart = startDate.minusMonths(1);
// 获取上月同期结束时间
LocalDate lastMonthEnd = endDate.minusMonths(1);
dto.setStartTime(lastMonthStart.format(formatter));
dto.setEndTime(lastMonthEnd.format(formatter));
MaTypeHomeVo lastMonthResultVo = mainMapper.getInStockNum(dto);
// 计算各项增长量
resultVo.setInStockIncrease(calculateIncrease(resultVo.getInStockNum(), lastMonthResultVo.getInStockNum()));
resultVo.setInUseIncrease(calculateIncrease(resultVo.getInUseNum(), lastMonthResultVo.getInUseNum()));
resultVo.setInRepairIncrease(calculateIncrease(resultVo.getInRepairNum(), lastMonthResultVo.getInRepairNum()));
resultVo.setNewPurchaseIncrease(calculateIncrease(resultVo.getNewPurchaseNum(), lastMonthResultVo.getNewPurchaseNum()));
resultVo.setNewRepairIncrease(calculateIncrease(resultVo.getNewRepairNum(), lastMonthResultVo.getNewRepairNum()));
} catch (Exception e) {
// 处理日期解析异常
throw new RuntimeException("日期解析出错", e);
}
}
return success(resultVo);
}
/**
* 获取机具设备状态总数据
* @param dto
* @return
*/
@Override
public AjaxResult getMaTypeStatusTotal(MaTypeHomeVo dto) {
BigDecimal totalNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
BigDecimal inStockProportion = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
BigDecimal inUseProportion = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
BigDecimal inRepairProportion = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
BigDecimal newPurchaseProportion = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
BigDecimal newRepairProportion = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
// 获取所选当前时间数据
MaTypeHomeVo resultVo = mainMapper.getInStockNum(dto);
if (resultVo != null) {
totalNum = totalNum.add(resultVo.getInStockNum()).add(resultVo.getInUseNum()).add(resultVo.getInRepairNum()).add(resultVo.getNewPurchaseNum()).add(resultVo.getNewRepairNum());
// 计算需求量百分占比结果保留2位小数
if (totalNum.compareTo(BigDecimal.ZERO) != 0) {
inStockProportion = resultVo.getInStockNum().divide(totalNum, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
inUseProportion = resultVo.getInUseNum().divide(totalNum, 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100));
inRepairProportion = resultVo.getInRepairNum().divide(totalNum, 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100));
newPurchaseProportion = resultVo.getNewPurchaseNum().divide(totalNum, 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100));
newRepairProportion = resultVo.getNewRepairNum().divide(totalNum, 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100));
}
}
resultVo.setInStockProportion(inStockProportion);
resultVo.setInUseProportion(inUseProportion);
resultVo.setInRepairProportion(inRepairProportion);
resultVo.setNewPurchaseProportion(newPurchaseProportion);
resultVo.setNewRepairProportion(newRepairProportion);
return success(resultVo);
}
/**
* 计算增长量
* @param currentNum
* @param lastMonthNum
* @return
*/
private BigDecimal calculateIncrease(BigDecimal currentNum, BigDecimal lastMonthNum) {
if (lastMonthNum.compareTo(BigDecimal.ZERO) == 0 && currentNum.compareTo(BigDecimal.ZERO) > 0) {
return BigDecimal.valueOf(100);
} else if (currentNum.compareTo(BigDecimal.ZERO) == 0 && lastMonthNum.compareTo(BigDecimal.ZERO) > 0) {
return BigDecimal.valueOf(-100);
} else if (lastMonthNum.compareTo(BigDecimal.ZERO) > 0) {
return currentNum.subtract(lastMonthNum)
.divide(lastMonthNum, 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100))
.setScale(2, RoundingMode.HALF_UP);
}
return BigDecimal.ZERO;
}
/**
* 需求列表
* @param demandAndSupplyVo
* @return
*/
@Override
public AjaxResult getDemandList(DemandAndSupplyVo demandAndSupplyVo) {
DemandAndSupplyVo resultVo = new DemandAndSupplyVo();
List<String> typeNameList = new ArrayList<>();
List<BigDecimal> demandNumList = new ArrayList<>();
List<BigDecimal> suppliedQuantityNumList = new ArrayList<>();
List<BigDecimal> suppliedToBeQuantityNumList = new ArrayList<>();
// 查询列表
List<DemandAndSupplyVo> demandList = mainMapper.getDemandList(demandAndSupplyVo);
List<DemandAndSupplyVo> useList = mainMapper.getUseList(demandAndSupplyVo);
List<DemandAndSupplyVo> suppliedQuantityList = mainMapper.getSuppliedQuantityList(demandAndSupplyVo);
// 过滤 suppliedQuantityNum 0 的数据
suppliedQuantityList = filterZeroSuppliedQuantity(suppliedQuantityList);
// 合并 demandNum
mergeDemandNum(demandList, useList);
// 提取需求量排名前 10 的数据
demandList = getTop10DemandList(demandList);
// 构建结果列表
buildResultLists(demandList, suppliedQuantityList, typeNameList, demandNumList, suppliedQuantityNumList, suppliedToBeQuantityNumList);
// 设置结果
resultVo.setTypeNameList(typeNameList);
resultVo.setDemandNumList(demandNumList);
resultVo.setSuppliedQuantityNumList(suppliedQuantityNumList);
resultVo.setSuppliedToBeQuantityNumList(suppliedToBeQuantityNumList);
return success(resultVo);
}
/**
* 过滤数量为0的数据
* @param suppliedQuantityList
* @return
*/
private static List<DemandAndSupplyVo> filterZeroSuppliedQuantity(List<DemandAndSupplyVo> suppliedQuantityList) {
return suppliedQuantityList.stream()
.filter(item -> item.getSuppliedQuantityNum().compareTo(BigDecimal.ZERO) != 0)
.collect(Collectors.toList());
}
/**
* 合并总需求量
* @param demandList
* @param useList
*/
private static void mergeDemandNum(List<DemandAndSupplyVo> demandList, List<DemandAndSupplyVo> useList) {
// 创建一个 Map 用于存储 typeId 对应的 DemandAndSupplyVo 对象
Map<Long, DemandAndSupplyVo> typeIdMap = new HashMap<>();
// demandList 中的元素放入 Map
for (DemandAndSupplyVo vo : demandList) {
typeIdMap.put(vo.getTypeId(), vo);
}
// 遍历 useList合并 demandNum
for (DemandAndSupplyVo vo : useList) {
Long typeId = vo.getTypeId();
if (typeIdMap.containsKey(typeId)) {
// 如果 Map 中已经存在该 typeId则合并 demandNum
DemandAndSupplyVo existingVo = typeIdMap.get(typeId);
existingVo.setDemandNum(existingVo.getDemandNum().add(vo.getDemandNum()));
} else {
// 如果 Map 中不存在该 typeId则将该元素添加到 Map
typeIdMap.put(typeId, vo);
}
}
demandList.clear();
demandList.addAll(typeIdMap.values());
}
/**
* 去总数量前10的数据
* @param demandList
* @return
*/
private static List<DemandAndSupplyVo> getTop10DemandList(List<DemandAndSupplyVo> demandList) {
return demandList.stream()
.sorted(Comparator.comparing(DemandAndSupplyVo::getDemandNum).reversed())
.limit(10)
.collect(Collectors.toList());
}
/**
* 构建数据
* @param demandList
* @param suppliedQuantityList
* @param typeNameList
* @param demandNumList
* @param suppliedQuantityNumList
* @param suppliedToBeQuantityNumList
*/
private static void buildResultLists(List<DemandAndSupplyVo> demandList, List<DemandAndSupplyVo> suppliedQuantityList,
List<String> typeNameList, List<BigDecimal> demandNumList,
List<BigDecimal> suppliedQuantityNumList, List<BigDecimal> suppliedToBeQuantityNumList) {
Map<Long, DemandAndSupplyVo> suppliedQuantityMap = suppliedQuantityList.stream()
.collect(Collectors.toMap(DemandAndSupplyVo::getTypeId, vo -> vo, (existing, replacement) -> existing));
for (DemandAndSupplyVo demandVo : demandList) {
Long typeId = demandVo.getTypeId();
if (suppliedQuantityMap.containsKey(typeId)) {
DemandAndSupplyVo suppliedQuantityVo = suppliedQuantityMap.get(typeId);
typeNameList.add(demandVo.getTypeName() + demandVo.getTypeModelName());
demandNumList.add(demandVo.getDemandNum());
suppliedQuantityNumList.add(suppliedQuantityVo.getSuppliedQuantityNum());
suppliedToBeQuantityNumList.add(demandVo.getDemandNum().subtract(suppliedQuantityVo.getSuppliedQuantityNum()));
} else {
typeNameList.add(demandVo.getTypeName() + demandVo.getTypeModelName());
demandNumList.add(demandVo.getDemandNum());
suppliedQuantityNumList.add(BigDecimal.ZERO);
suppliedToBeQuantityNumList.add(demandVo.getDemandNum());
}
}
}
} }

View File

@ -256,11 +256,15 @@ public class RepairAuditDetailsController extends BaseController {
@ApiOperation(value = "查询修饰一览表") @ApiOperation(value = "查询修饰一览表")
@GetMapping("/getRepairHomeList") @GetMapping("/getRepairHomeList")
public AjaxResult getRepairHomeList(RepairHomeInfo dto) { public AjaxResult getRepairHomeList(RepairHomeInfo dto) {
dto.setIsExport(1); try {
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1); dto.setIsExport(1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10); Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
List<RepairHomeInfo> pageList = repairAuditDetailsService.getRepairHomeList(dto); Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, pageList)); List<RepairHomeInfo> pageList = repairAuditDetailsService.getRepairHomeList(dto);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, pageList));
} catch (Exception e) {
return error("查询修饰一览表失败, " + e.getMessage());
}
} }
/** /**
@ -271,9 +275,13 @@ public class RepairAuditDetailsController extends BaseController {
@ApiOperation(value = "查询修饰一览表总计") @ApiOperation(value = "查询修饰一览表总计")
@GetMapping("/getRepairHomeTotalList") @GetMapping("/getRepairHomeTotalList")
public AjaxResult getRepairHomeTotalList(RepairHomeInfo dto) { public AjaxResult getRepairHomeTotalList(RepairHomeInfo dto) {
dto.setIsExport(0); try {
List<RepairHomeInfo> pageList = repairAuditDetailsService.getRepairHomeTotalList(dto); dto.setIsExport(0);
return AjaxResult.success(pageList); List<RepairHomeInfo> pageList = repairAuditDetailsService.getRepairHomeTotalList(dto);
return AjaxResult.success(pageList);
} catch (Exception e) {
return error("查询修饰一览表总计失败, " + e.getMessage());
}
} }
/** /**

View File

@ -1061,32 +1061,57 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
info.setIsIncrease(true); info.setIsIncrease(true);
infos.add(info); infos.add(info);
} else if (!CollectionUtils.isEmpty(lastMonthList) && CollectionUtils.isEmpty(repairHomeList)) { } else if (!CollectionUtils.isEmpty(lastMonthList) && CollectionUtils.isEmpty(repairHomeList)) {
RepairHomeInfo lastMonthInfo = lastMonthList.get(0);
RepairHomeInfo info = new RepairHomeInfo(); RepairHomeInfo info = new RepairHomeInfo();
info.setBackNum(lastMonthInfo.getBackNum()); info.setBackNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.valueOf(100)); info.setIncrease(BigDecimal.valueOf(100));
info.setIsIncrease(false); info.setIsIncrease(false);
infos.add(info); infos.add(info);
info = new RepairHomeInfo(); info = new RepairHomeInfo();
info.setRepairedNum(lastMonthInfo.getRepairedNum()); info.setRepairedNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.valueOf(100)); info.setIncrease(BigDecimal.valueOf(100));
info.setIsIncrease(false); info.setIsIncrease(false);
infos.add(info); infos.add(info);
info = new RepairHomeInfo(); info = new RepairHomeInfo();
info.setRepairingNum(lastMonthInfo.getRepairingNum()); info.setRepairingNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.valueOf(100)); info.setIncrease(BigDecimal.valueOf(100));
info.setIsIncrease(false); info.setIsIncrease(false);
infos.add(info); infos.add(info);
info = new RepairHomeInfo(); info = new RepairHomeInfo();
info.setScrapNum(lastMonthInfo.getScrapNum()); info.setScrapNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.valueOf(100)); info.setIncrease(BigDecimal.valueOf(100));
info.setIsIncrease(false); info.setIsIncrease(false);
infos.add(info); infos.add(info);
info = new RepairHomeInfo(); info = new RepairHomeInfo();
info.setTestNum(lastMonthInfo.getTestNum()); info.setTestNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.valueOf(100)); info.setIncrease(BigDecimal.valueOf(100));
info.setIsIncrease(false); info.setIsIncrease(false);
infos.add(info); infos.add(info);
} else {
RepairHomeInfo info = new RepairHomeInfo();
info.setBackNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.ZERO);
info.setIsIncrease(true);
infos.add(info);
info = new RepairHomeInfo();
info.setRepairedNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.ZERO);
info.setIsIncrease(true);
infos.add(info);
info = new RepairHomeInfo();
info.setRepairingNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.ZERO);
info.setIsIncrease(true);
infos.add(info);
info = new RepairHomeInfo();
info.setScrapNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.ZERO);
info.setIsIncrease(true);
infos.add(info);
info = new RepairHomeInfo();
info.setTestNum(BigDecimal.ZERO);
info.setIncrease(BigDecimal.ZERO);
info.setIsIncrease(true);
infos.add(info);
} }
} }
return infos; return infos;

View File

@ -482,6 +482,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
WHERE bcd.is_finished = '1'
GROUP BY mt.type_id) AS subquery2 GROUP BY mt.type_id) AS subquery2
ON subquery1.type_id = subquery2.type_id) AS subquery1 ON subquery1.type_id = subquery2.type_id) AS subquery1
ON mt.type_id = subquery1.type_id ON mt.type_id = subquery1.type_id

View File

@ -6,67 +6,213 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getPublishList" resultType="com.bonus.common.biz.domain.lease.LeasePublishInfo"> <select id="getPublishList" resultType="com.bonus.common.biz.domain.lease.LeasePublishInfo">
select SELECT
IFNULL(sum(lad.pre_num),0) as preCountNum IFNULL( sum( lad.pre_num ), 0 ) AS preCountNum
from FROM
lease_apply_info lai lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
left join lease_apply_details lad on lai.id = lad.parent_id LEFT JOIN lease_apply_details lad ON lai.id = lad.parent_id
left join tm_task_agreement tta on lai.task_id = tta.task_id LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
left join bm_unit bu on bu.unit_id = lai.unit_id LEFT JOIN bm_agreement_info bagi on bagi.agreement_id = tta.agreement_id
left join bm_project bp on bp.pro_id = lai.project_id AND bagi.`status` = '1'
left join sys_dept sd on sd.dept_id = bp.imp_unit LEFT JOIN bm_project bp on bp.pro_id = bagi.project_id
left join sys_dict_data sda on tt.task_status = sda.dict_value AND bp.del_flag = '0'
and sda.dict_type = 'lease_task_status' LEFT JOIN bm_unit bu on bu.unit_id = bagi.unit_id
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0' AND bu.del_flag = '0'
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0' WHERE
<if test="userId != null"> tt.task_status IN (3, 4)
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId} AND tt.task_type = 2
</if>
where tt.task_status = 3
and tt.task_type =2
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
GROUP BY lai.id <if test="unitId != null ">
ORDER BY tt.task_status,tt.create_time desc AND bu.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND bp.pro_id = #{projectId}
</if>
</select> </select>
<select id="getPublishListNew" resultType="java.math.BigDecimal"> <select id="getPublishListNew" resultType="java.math.BigDecimal">
select select
IFNULL(sum(lpd.num),0) as preCountNum IFNULL(sum(lpd.num),0) as preCountNum
from from
lease_publish_details lpd lease_publish_details lpd
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId}
</if>
where 1=1 where 1=1
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lpd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} AND DATE_FORMAT( lpd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
<if test="unitId != null ">
AND lpd.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND lpd.project_id = #{projectId}
</if>
</select> </select>
<select id="getSuppliedQuantityNum" resultType="java.math.BigDecimal"> <select id="getSuppliedQuantityNum" resultType="java.math.BigDecimal">
select SELECT
IFNULL(sum(lod.out_num),0) as preCountNum IFNULL(sum(lod.out_num),0) as preCountNum
from FROM
lease_out_details lod lease_apply_info lai
<if test="userId != null"> LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
JOIN ma_type_keeper mtk ON mtk.type_id = lod.type_id AND mtk.user_id = #{userId} LEFT JOIN lease_out_details lod ON lai.id = lod.parent_id
</if> LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
where 1=1 LEFT JOIN bm_agreement_info bagi on bagi.agreement_id = tta.agreement_id
AND bagi.`status` = '1'
LEFT JOIN bm_project bp on bp.pro_id = bagi.project_id
AND bp.del_flag = '0'
LEFT JOIN bm_unit bu on bu.unit_id = bagi.unit_id
AND bu.del_flag = '0'
WHERE
tt.task_status IN (3, 4)
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lod.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} AND DATE_FORMAT( lod.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
<if test="unitId != null ">
AND bu.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND bp.pro_id = #{projectId}
</if>
</select> </select>
<select id="getProjectNum" resultType="java.lang.Integer"> <select id="getProjectNum" resultType="java.lang.Integer">
select SELECT
count(bp.pro_id) as projectNum count( DISTINCT bp.pro_id ) AS projectNum
from FROM
bm_project bp bm_project bp
where bp.pro_status in ('0','1','3') LEFT JOIN bm_agreement_info ba ON bp.pro_id = ba.project_id
LEFT JOIN ( SELECT agreement_id, is_slt FROM slt_agreement_info GROUP BY agreement_id ) a
ON a.agreement_id = ba.agreement_id
WHERE
bp.del_flag = '0'
AND a.is_slt = '0'
</select>
<select id="getSuppliedQuantityPrice" resultType="com.bonus.material.main.domain.DemandAndSupplyVo">
SELECT
IFNULL( sum( lod.out_num ), 0 ) AS suppliedQuantityNum,
IFNULL(mt.buy_price, 0) AS buyPrice
FROM
lease_out_details lod
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
GROUP BY
lod.type_id
</select>
<select id="getDemandList" resultType="com.bonus.material.main.domain.DemandAndSupplyVo">
SELECT
lad.type_id AS typeId,
mt.type_name AS typeName,
mt1.type_name AS typeModelName,
IFNULL( sum( lad.pre_num ), 0 ) AS demandNum
FROM
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN lease_apply_details lad ON lai.id = lad.parent_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
AND bagi.`status` = '1'
LEFT JOIN bm_project bp ON bp.pro_id = bagi.project_id
AND bp.del_flag = '0'
LEFT JOIN bm_unit bu ON bu.unit_id = bagi.unit_id
AND bu.del_flag = '0'
LEFT JOIN ma_type mt1 ON lad.type_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt ON mt1.parent_id = mt.type_id
AND mt.del_flag = '0'
WHERE
tt.task_status IN ( 3, 4 )
AND tt.task_type = 2
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lad.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="unitId != null ">
AND bu.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND bp.pro_id = #{projectId}
</if>
GROUP BY
lad.type_id
</select>
<select id="getUseList" resultType="com.bonus.material.main.domain.DemandAndSupplyVo">
SELECT
lpd.new_type AS typeId,
IFNULL( sum( lpd.num ), 0 ) AS demandNum,
mt.type_name AS typeName,
mt1.type_name AS typeModelName
FROM
lease_publish_details lpd
LEFT JOIN ma_type mt1 ON lpd.new_type = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt ON mt1.parent_id = mt.type_id
AND mt.del_flag = '0'
WHERE 1 = 1
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lpd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="unitId != null ">
AND lpd.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND lpd.project_id = #{projectId}
</if>
GROUP BY
lpd.new_type
</select>
<select id="getSuppliedQuantityList" resultType="com.bonus.material.main.domain.DemandAndSupplyVo">
SELECT
IFNULL( sum( lod.out_num ), 0 ) AS suppliedQuantityNum,
lod.type_id AS typeId,
mt.type_name AS typeName,
mt1.type_name AS typeModelName
FROM
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
LEFT JOIN lease_out_details lod ON lai.id = lod.parent_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
AND bagi.`status` = '1'
LEFT JOIN bm_project bp ON bp.pro_id = bagi.project_id
AND bp.del_flag = '0'
LEFT JOIN bm_unit bu ON bu.unit_id = bagi.unit_id
AND bu.del_flag = '0'
LEFT JOIN ma_type mt1 ON lod.type_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt ON mt1.parent_id = mt.type_id
AND mt.del_flag = '0'
WHERE
tt.task_status IN ( 3, 4 )
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lod.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} AND DATE_FORMAT( lod.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
<if test="unitId != null ">
AND bu.unit_id = #{unitId}
</if>
<if test="projectId != null ">
AND bp.pro_id = #{projectId}
</if>
GROUP BY
lod.type_id
</select>
<select id="getInStockNum" resultType="com.bonus.material.main.domain.MaTypeHomeVo">
SELECT
IFNULL( SUM( storage_num ), 0 ) AS inStockNum,
IFNULL( SUM( inuse_num ), 0 ) AS inUseNum,
IFNULL( SUM( repair_num ), 0 ) AS inRepairNum,
IFNULL( SUM( new_num ), 0 ) AS newPurchaseNum,
IFNULL( SUM( repaired_num ), 0 ) AS newRepairNum,
IFNULL( SUM( scrap_num ), 0 ) AS newScrapNum
FROM
ma_status_backup
WHERE 1 = 1
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT( time, '%Y-%m-%d' ) = #{endTime}
</if>
</select> </select>
</mapper> </mapper>