This commit is contained in:
parent
6bc468201a
commit
ff05164b8b
|
|
@ -0,0 +1,134 @@
|
||||||
|
package com.bonus.material.basic;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 综合查询--退料查询
|
||||||
|
* @author hay
|
||||||
|
* @date 2024/2/26 14:51
|
||||||
|
*/
|
||||||
|
@ApiModel(description = "退料查询")
|
||||||
|
@Data
|
||||||
|
public class ProjUsingRecordExports {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2227217051604273598L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议号")
|
||||||
|
private String agreementCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程Id")
|
||||||
|
private Integer proId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程名称")
|
||||||
|
@Excel(name = "工程名称")
|
||||||
|
private String proName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位Id")
|
||||||
|
private Integer unitId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实施单位")
|
||||||
|
private String impUnitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "合同主体")
|
||||||
|
private String contractPart;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "物资名称")
|
||||||
|
@Excel(name = "物资名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格ID")
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格型号")
|
||||||
|
@Excel(name = "规格型号")
|
||||||
|
private String typeModelName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备编码")
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "计量单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "领用数量")
|
||||||
|
private BigDecimal leaseNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "归还数量")
|
||||||
|
private BigDecimal backNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "需求数量")
|
||||||
|
private String needNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "已供数量")
|
||||||
|
private String supplyNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "差值")
|
||||||
|
private String diffNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用数量")
|
||||||
|
@Excel(name = "在用数量")
|
||||||
|
private BigDecimal usNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在库数量")
|
||||||
|
private BigDecimal storeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在修数量")
|
||||||
|
private BigDecimal repairNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待入库数量")
|
||||||
|
private BigDecimal inputNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总保有量")
|
||||||
|
private BigDecimal allNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总在用数量")
|
||||||
|
private BigDecimal allUsNum;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用总价值(元)")
|
||||||
|
private BigDecimal usPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "投入总价值(元)")
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关键字")
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="开始时间")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="结束时间")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据所属组织")
|
||||||
|
private Integer companyId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "装备管理方式(0编号 1计数)")
|
||||||
|
private String manageType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否结算 0否 1是")
|
||||||
|
private String isSlt;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否结算 0否 1是")
|
||||||
|
private String isSltName;
|
||||||
|
|
||||||
|
private String externalIds;
|
||||||
|
@ApiModelProperty(value = "关联外部(第三方)的工程ID")
|
||||||
|
private String externalId;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -4,10 +4,12 @@ import cn.hutool.core.convert.Convert;
|
||||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
import com.bonus.common.biz.config.ListPagingUtil;
|
import com.bonus.common.biz.config.ListPagingUtil;
|
||||||
import com.bonus.common.core.utils.ServletUtils;
|
import com.bonus.common.core.utils.ServletUtils;
|
||||||
|
import com.bonus.common.core.utils.bean.BeanUtils;
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
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.common.security.utils.SecurityUtils;
|
||||||
|
import com.bonus.material.basic.ProjUsingRecordExports;
|
||||||
import com.bonus.material.basic.domain.*;
|
import com.bonus.material.basic.domain.*;
|
||||||
import com.bonus.material.basic.domain.vo.MaTypeSelectInfo;
|
import com.bonus.material.basic.domain.vo.MaTypeSelectInfo;
|
||||||
import com.bonus.material.basic.service.ComplexQueryService;
|
import com.bonus.material.basic.service.ComplexQueryService;
|
||||||
|
|
@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -454,4 +457,69 @@ public class ComplexQueryController extends BaseController {
|
||||||
List<RetainedEquipmentInfo> pageList = complexQueryService.getPersonNum(bean);
|
List<RetainedEquipmentInfo> pageList = complexQueryService.getPersonNum(bean);
|
||||||
return AjaxResult.success(getDataTable(pageList));
|
return AjaxResult.success(getDataTable(pageList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 施工机具需求、供应分析统计表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "施工机具需求、供应分析统计表")
|
||||||
|
@GetMapping("/getStatisticsList")
|
||||||
|
public AjaxResult getStatisticsList(ProjUsingRecord bean) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
bean.setUserId(loginUser.getUserid());
|
||||||
|
startPage();
|
||||||
|
List<ProjUsingRecord> pageList = complexQueryService.getStatisticsList(bean);
|
||||||
|
return AjaxResult.success(getDataTable(pageList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 施工机具需求、供应分析统计表二级页面---总在用工程明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "总在用工程明细")
|
||||||
|
@GetMapping("/getAllUsDetails")
|
||||||
|
public AjaxResult getAllUsDetails(ProjUsingRecord bean) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
bean.setUserId(loginUser.getUserid());
|
||||||
|
startPage();
|
||||||
|
List<ProjUsingRecord> pageList = complexQueryService.getAllUsDetails(bean);
|
||||||
|
return AjaxResult.success(getDataTable(pageList));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("导出施工机具需求、供应分析统计表")
|
||||||
|
@PostMapping("/exportStatisticsList")
|
||||||
|
public void exportStatisticsList(HttpServletResponse response, ProjUsingRecord bean)
|
||||||
|
{
|
||||||
|
List<ProjUsingRecord> list = complexQueryService.getStatisticsList(bean);
|
||||||
|
List<ProjUsingRecordExport> exportList = new ArrayList<>();
|
||||||
|
//将list复制到exportList
|
||||||
|
for (ProjUsingRecord projUsingRecord : list) {
|
||||||
|
ProjUsingRecordExport projUsingRecordExport = new ProjUsingRecordExport();
|
||||||
|
BeanUtils.copyProperties(projUsingRecord, projUsingRecordExport);
|
||||||
|
exportList.add(projUsingRecordExport);
|
||||||
|
}
|
||||||
|
ExcelUtil<ProjUsingRecordExport> util = new ExcelUtil<>(ProjUsingRecordExport.class);
|
||||||
|
util.exportExcel(response, exportList, "施工机具需求、供应分析统计表");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出总在用工程明细")
|
||||||
|
@PostMapping("/exportAllUsDetails")
|
||||||
|
public void exportAllUsDetails(HttpServletResponse response, ProjUsingRecord bean)
|
||||||
|
{
|
||||||
|
List<ProjUsingRecord> list = complexQueryService.getAllUsDetails(bean);
|
||||||
|
List<ProjUsingRecordExports> exportList = new ArrayList<>();
|
||||||
|
//将list复制到exportList
|
||||||
|
for (ProjUsingRecord projUsingRecord : list) {
|
||||||
|
ProjUsingRecordExports projUsingRecordExports = new ProjUsingRecordExports();
|
||||||
|
BeanUtils.copyProperties(projUsingRecord, projUsingRecordExports);
|
||||||
|
exportList.add(projUsingRecordExports);
|
||||||
|
}
|
||||||
|
ExcelUtil<ProjUsingRecordExports> util = new ExcelUtil<>(ProjUsingRecordExports.class);
|
||||||
|
util.exportExcel(response, exportList, "总在用工程明细");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,4 +115,29 @@ public class ProjUsingRecord {
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "需求数量")
|
||||||
|
private String needNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "已供数量")
|
||||||
|
private String supplyNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "差值")
|
||||||
|
private String diffNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在库数量")
|
||||||
|
private BigDecimal storeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在修数量")
|
||||||
|
private BigDecimal repairNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待入库数量")
|
||||||
|
private BigDecimal inputNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总保有量")
|
||||||
|
private BigDecimal allNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总在用数量")
|
||||||
|
private BigDecimal allUsNum;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
package com.bonus.material.basic.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 综合查询--退料查询
|
||||||
|
* @author hay
|
||||||
|
* @date 2024/2/26 14:51
|
||||||
|
*/
|
||||||
|
@ApiModel(description = "退料查询")
|
||||||
|
@Data
|
||||||
|
public class ProjUsingRecordExport {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2227217051604273598L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议号")
|
||||||
|
private String agreementCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程Id")
|
||||||
|
private Integer proId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程名称")
|
||||||
|
@Excel(name = "工程名称")
|
||||||
|
private String proName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位Id")
|
||||||
|
private Integer unitId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "实施单位")
|
||||||
|
private String impUnitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "合同主体")
|
||||||
|
private String contractPart;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "物资名称")
|
||||||
|
@Excel(name = "物资名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格ID")
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格型号")
|
||||||
|
@Excel(name = "规格型号")
|
||||||
|
private String typeModelName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备编码")
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "计量单位")
|
||||||
|
@Excel(name = "单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "领用数量")
|
||||||
|
private BigDecimal leaseNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "归还数量")
|
||||||
|
private BigDecimal backNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "需求数量")
|
||||||
|
@Excel(name = "需求数量")
|
||||||
|
private String needNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "已供数量")
|
||||||
|
@Excel(name = "已供数量")
|
||||||
|
private String supplyNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "差值")
|
||||||
|
@Excel(name = "差值")
|
||||||
|
private String diffNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用数量")
|
||||||
|
@Excel(name = "在用数量")
|
||||||
|
private BigDecimal usNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在库数量")
|
||||||
|
@Excel(name = "库存数量")
|
||||||
|
private BigDecimal storeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在修数量")
|
||||||
|
@Excel(name = "在修数量")
|
||||||
|
private BigDecimal repairNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待入库数量")
|
||||||
|
@Excel(name = "待入库数量")
|
||||||
|
private BigDecimal inputNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总保有量")
|
||||||
|
@Excel(name = "总保有量")
|
||||||
|
private BigDecimal allNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总在用数量")
|
||||||
|
@Excel(name = "总在用工程明细")
|
||||||
|
private BigDecimal allUsNum;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用总价值(元)")
|
||||||
|
private BigDecimal usPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "投入总价值(元)")
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关键字")
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="开始时间")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="结束时间")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据所属组织")
|
||||||
|
private Integer companyId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "装备管理方式(0编号 1计数)")
|
||||||
|
private String manageType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否结算 0否 1是")
|
||||||
|
private String isSlt;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否结算 0否 1是")
|
||||||
|
private String isSltName;
|
||||||
|
|
||||||
|
private String externalIds;
|
||||||
|
@ApiModelProperty(value = "关联外部(第三方)的工程ID")
|
||||||
|
private String externalId;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -161,5 +161,33 @@ public interface ComplexQueryMapper {
|
||||||
*/
|
*/
|
||||||
List<RetainedEquipmentInfo> getPersonNum(RetainedEquipmentInfo bean);
|
List<RetainedEquipmentInfo> getPersonNum(RetainedEquipmentInfo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 施工机具需求、供应分析统计表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getStatisticsList(ProjUsingRecord bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在用数量
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ProjUsingRecord getUsNum(ProjUsingRecord item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据typeId查询,总库存数量、总在修数量、总待入库数量、总保有量
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RetainedEquipmentInfo selectInventory(ProjUsingRecord item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有在用详情
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getAllUsDetails(ProjUsingRecord bean);
|
||||||
|
|
||||||
List<UseStorageInfo> batchSelectInfo(@Param("list") Set<Long> leaseIds);
|
List<UseStorageInfo> batchSelectInfo(@Param("list") Set<Long> leaseIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,4 +116,18 @@ public interface ComplexQueryService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<RetainedEquipmentInfo> getPersonNum(RetainedEquipmentInfo bean);
|
List<RetainedEquipmentInfo> getPersonNum(RetainedEquipmentInfo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 施工机具需求、供应分析统计表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getStatisticsList(ProjUsingRecord bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总在用工程明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getAllUsDetails(ProjUsingRecord bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -635,4 +635,52 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
||||||
bean.setUserId(userId);
|
bean.setUserId(userId);
|
||||||
return complexQueryMapper.getPersonNum(bean);
|
return complexQueryMapper.getPersonNum(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProjUsingRecord> getStatisticsList(ProjUsingRecord bean) {
|
||||||
|
try {
|
||||||
|
//1、查询工程对应的物资名称、型号、需求数量、已供数量
|
||||||
|
List<ProjUsingRecord> list = complexQueryMapper.getStatisticsList(bean);
|
||||||
|
for (ProjUsingRecord item : list){
|
||||||
|
//2、计算需求数量,已供数量的差值
|
||||||
|
//使用 BigDecimal 处理小数运算
|
||||||
|
BigDecimal needNum = new BigDecimal(item.getNeedNum());
|
||||||
|
BigDecimal supplyNum = new BigDecimal(item.getSupplyNum());
|
||||||
|
BigDecimal diffNum = needNum.subtract(supplyNum);
|
||||||
|
item.setDiffNum(diffNum.toString());
|
||||||
|
//3、查询该工程设备的在用数量
|
||||||
|
ProjUsingRecord projUsingRecord3 = complexQueryMapper.getUsNum(item);
|
||||||
|
if (projUsingRecord3 != null && projUsingRecord3.getUsNum() != null){
|
||||||
|
item.setUsNum(projUsingRecord3.getUsNum());
|
||||||
|
} else {
|
||||||
|
BigDecimal usNum = BigDecimal.ZERO;
|
||||||
|
item.setUsNum(usNum);
|
||||||
|
}
|
||||||
|
//4、根据typeId查询,总库存数量、总在修数量、总待入库数量、总保有量
|
||||||
|
RetainedEquipmentInfo bean1 = complexQueryMapper.selectInventory(item);
|
||||||
|
item.setStoreNum(bean1.getStoreNum());
|
||||||
|
item.setRepairNum(bean1.getRepairNum());
|
||||||
|
item.setAllUsNum(bean1.getUsNum());
|
||||||
|
//使用三元运算符处理null值
|
||||||
|
BigDecimal inputNum = bean1.getInputNum() != null ? bean1.getInputNum() : BigDecimal.ZERO;
|
||||||
|
BigDecimal repairInputNum = bean1.getRepairInputNum() != null ? bean1.getRepairInputNum() : BigDecimal.ZERO;
|
||||||
|
item.setInputNum(inputNum.add(repairInputNum));
|
||||||
|
item.setAllNum(bean1.getAllNum());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProjUsingRecord> getAllUsDetails(ProjUsingRecord bean) {
|
||||||
|
try {
|
||||||
|
return complexQueryMapper.getAllUsDetails(bean);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -506,6 +506,378 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and mt.type_name like concat('%',#{typeModelName},'%')
|
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getStatisticsList" resultType="com.bonus.material.basic.domain.ProjUsingRecord">
|
||||||
|
SELECT
|
||||||
|
COALESCE(t1.typeId, t2.typeId) as typeId,
|
||||||
|
COALESCE(t1.proId, t2.proId) as proId,
|
||||||
|
COALESCE(t1.proName, t2.proName) as proName,
|
||||||
|
COALESCE(t1.typeName, t2.typeName) as typeName,
|
||||||
|
COALESCE(t1.modelName, t2.modelName) as typeModelName,
|
||||||
|
COALESCE(t1.unit, t2.unit) as unit,
|
||||||
|
COALESCE(t2.num, 0) as needNum, -- 语句二的num作为needNum
|
||||||
|
COALESCE(t1.num, 0) as supplyNum -- 语句一的num作为outNum
|
||||||
|
FROM (
|
||||||
|
-- 语句一的结果作为outNum
|
||||||
|
SELECT
|
||||||
|
mt.type_id as typeId,
|
||||||
|
bp.pro_id as proId,
|
||||||
|
bp.pro_name as proName,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
SUM(sai.num) as num
|
||||||
|
FROM
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN ma_type mt on mt.type_id=sai.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
||||||
|
LEFT JOIN bm_agreement_info bai on sai.agreement_id=bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp on bai.project_id=bp.pro_id
|
||||||
|
WHERE
|
||||||
|
sai.lease_id is not null
|
||||||
|
and bp.pro_name is not null
|
||||||
|
and mt.del_flag='0'
|
||||||
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
|
AND DATE_FORMAT( sai.start_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (
|
||||||
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.unit_name like concat('%', #{keyWord}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="proName != null and proName != ''">
|
||||||
|
and bp.pro_name like concat('%', #{proName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%', #{typeName}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id, mt.type_id
|
||||||
|
) t1
|
||||||
|
LEFT JOIN (
|
||||||
|
-- 语句二的结果作为needNum
|
||||||
|
SELECT
|
||||||
|
mt.type_id as typeId,
|
||||||
|
bp.pro_id as proId,
|
||||||
|
bp.pro_name as proName,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
SUM(lad.pre_num) as num
|
||||||
|
FROM
|
||||||
|
lease_apply_details lad
|
||||||
|
LEFT JOIN lease_apply_info lai on lad.parent_id=lai.id
|
||||||
|
left join tm_task tt on lai.task_id = tt.task_id
|
||||||
|
LEFT JOIN ma_type mt on mt.type_id=lad.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
||||||
|
LEFT JOIN bm_project bp on lai.project_id=bp.pro_id
|
||||||
|
WHERE
|
||||||
|
bp.pro_name is not null
|
||||||
|
and mt.del_flag='0'
|
||||||
|
and tt.task_type = '19'
|
||||||
|
and tt.task_status in (1, 3, 4, 5)
|
||||||
|
<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="keyWord != null and keyWord != ''">
|
||||||
|
and (
|
||||||
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.unit_name like concat('%', #{keyWord}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="proName != null and proName != ''">
|
||||||
|
and bp.pro_name like concat('%', #{proName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%', #{typeName}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id, mt.type_id
|
||||||
|
) t2 ON t1.typeId = t2.typeId AND t1.proId = t2.proId
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
COALESCE(t1.typeId, t2.typeId) as typeId,
|
||||||
|
COALESCE(t1.proId, t2.proId) as proId,
|
||||||
|
COALESCE(t1.proName, t2.proName) as proName,
|
||||||
|
COALESCE(t1.typeName, t2.typeName) as typeName,
|
||||||
|
COALESCE(t1.modelName, t2.modelName) as typeModelName,
|
||||||
|
COALESCE(t1.unit, t2.unit) as unit,
|
||||||
|
COALESCE(t2.num, 0) as needNum, -- 语句二的num作为needNum
|
||||||
|
COALESCE(t1.num, 0) as supplyNum -- 语句一的num作为outNum
|
||||||
|
FROM (
|
||||||
|
-- 语句一的结果作为outNum
|
||||||
|
SELECT
|
||||||
|
mt.type_id as typeId,
|
||||||
|
bp.pro_id as proId,
|
||||||
|
bp.pro_name as proName,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
SUM(sai.num) as num
|
||||||
|
FROM
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN ma_type mt on mt.type_id=sai.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
||||||
|
LEFT JOIN bm_agreement_info bai on sai.agreement_id=bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp on bai.project_id=bp.pro_id
|
||||||
|
WHERE
|
||||||
|
sai.lease_id is not null
|
||||||
|
and bp.pro_name is not null
|
||||||
|
and mt.del_flag='0'
|
||||||
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
|
AND DATE_FORMAT( sai.start_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (
|
||||||
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.unit_name like concat('%', #{keyWord}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="proName != null and proName != ''">
|
||||||
|
and bp.pro_name like concat('%', #{proName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%', #{typeName}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id, mt.type_id
|
||||||
|
) t1
|
||||||
|
RIGHT JOIN (
|
||||||
|
-- 语句二的结果作为needNum
|
||||||
|
SELECT
|
||||||
|
mt.type_id as typeId,
|
||||||
|
bp.pro_id as proId,
|
||||||
|
bp.pro_name as proName,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
SUM(lad.pre_num) as num
|
||||||
|
FROM
|
||||||
|
lease_apply_details lad
|
||||||
|
LEFT JOIN lease_apply_info lai on lad.parent_id=lai.id
|
||||||
|
left join tm_task tt on lai.task_id = tt.task_id
|
||||||
|
LEFT JOIN ma_type mt on mt.type_id=lad.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
||||||
|
LEFT JOIN bm_project bp on lai.project_id=bp.pro_id
|
||||||
|
WHERE
|
||||||
|
bp.pro_name is not null
|
||||||
|
and mt.del_flag='0'
|
||||||
|
and tt.task_type = '19'
|
||||||
|
and tt.task_status in (1, 3, 4, 5)
|
||||||
|
<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="keyWord != null and keyWord != ''">
|
||||||
|
and (
|
||||||
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.unit_name like concat('%', #{keyWord}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="proName != null and proName != ''">
|
||||||
|
and bp.pro_name like concat('%', #{proName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%', #{typeName}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id, mt.type_id
|
||||||
|
) t2 ON t1.typeId = t2.typeId AND t1.proId = t2.proId
|
||||||
|
ORDER BY proId
|
||||||
|
</select>
|
||||||
|
<select id="getUsNum" resultType="com.bonus.material.basic.domain.ProjUsingRecord">
|
||||||
|
SELECT
|
||||||
|
ifnull(SUM( CASE WHEN sai.end_time IS NULL THEN sai.num ELSE 0 END ) , 0) AS usNum
|
||||||
|
FROM
|
||||||
|
bm_agreement_info bai
|
||||||
|
LEFT JOIN slt_agreement_info sai ON sai.agreement_id = bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
and bp.pro_id = #{proId}
|
||||||
|
and mt.type_id = #{typeId}
|
||||||
|
GROUP BY
|
||||||
|
bp.pro_id,
|
||||||
|
mt.type_id
|
||||||
|
ORDER BY
|
||||||
|
bai.agreement_code
|
||||||
|
</select>
|
||||||
|
<select id="selectInventory" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
IFNULL(subquery0.num, 0)
|
||||||
|
ELSE
|
||||||
|
IFNULL(mt.storage_num, 0)
|
||||||
|
END AS storeNum,
|
||||||
|
IFNULL(subquery1.usNum, 0) AS usNum,
|
||||||
|
IFNULL(subquery2.repairNum, 0) AS repairNum,
|
||||||
|
IFNULL(subquery3.repairInputNum, 0) AS repairInputNum,
|
||||||
|
IFNULL(subquery4.inputNum, 0) AS inputNum,
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
IFNULL(subquery0.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
|
||||||
|
+ IFNULL(subquery4.inputNum, 0) + IFNULL(subquery6.pendingScrapNum, 0)
|
||||||
|
ELSE
|
||||||
|
IFNULL(mt.storage_num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
|
||||||
|
+ IFNULL(subquery4.inputNum, 0) + IFNULL(subquery6.pendingScrapNum, 0)
|
||||||
|
END AS allNum
|
||||||
|
FROM ma_type mt
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
count(mm.ma_id) AS num
|
||||||
|
FROM ma_machine mm
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL( sai.num, 0 )) AS usNum
|
||||||
|
FROM
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
sai.`status` = '0' and sai.`is_slt` = '0'
|
||||||
|
AND sai.end_time IS NULL
|
||||||
|
AND sai.back_id IS NULL
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY mt.type_id
|
||||||
|
) AS subquery1
|
||||||
|
ON mt.type_id = subquery1.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(
|
||||||
|
IFNULL(rad.repair_num, 0) - IFNULL(rad.repaired_num, 0) -
|
||||||
|
IFNULL(rad.scrap_num, 0)) AS repairNum
|
||||||
|
FROM repair_apply_details rad
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = rad.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
rad.status = '0'
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id) AS subquery2 ON subquery2.type_id = mt.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(
|
||||||
|
IFNULL(rid.repair_num, 0) - IFNULL(rid.input_num, 0) - IFNULL(rid.reject_num, 0)) AS repairInputNum
|
||||||
|
FROM repair_input_details rid
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = rid.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE IFNULL(rid.repair_num, 0) - IFNULL(rid.input_num, 0) - IFNULL(rid.reject_num, 0) > 0
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id) AS subquery3 ON subquery3.type_id = mt.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(
|
||||||
|
IFNULL(pcd.check_num, 0) - IFNULL(pcd.input_num, 0)) AS inputNum
|
||||||
|
FROM purchase_check_details pcd
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = pcd.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE IFNULL(pcd.check_num, 0) - IFNULL(pcd.input_num, 0) > 0
|
||||||
|
and pcd.status in (3,4, 13,14)
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id) AS subquery4 ON subquery4.type_id = mt.type_id
|
||||||
|
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IF(sad.ledger_status = '0', IFNULL(sad.scrap_num, 0), 0)) AS pendingScrapNum,
|
||||||
|
SUM(IF(sad.ledger_status = '1', IFNULL(sad.scrap_num, 0), 0)) AS scrapNum
|
||||||
|
FROM scrap_apply_details sad
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sad.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id
|
||||||
|
) subquery6 ON subquery6.typeId = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||||
|
|
||||||
|
WHERE mt.del_flag = '0'
|
||||||
|
and mt.type_id =#{typeId}
|
||||||
|
LIMIT 1
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="getAllUsDetails" resultType="com.bonus.material.basic.domain.ProjUsingRecord">
|
||||||
|
SELECT
|
||||||
|
bp.pro_id as proId,
|
||||||
|
bp.pro_name as proName,
|
||||||
|
mt.type_id as typeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL(sai.num, 0 )) AS usNum
|
||||||
|
FROM
|
||||||
|
slt_agreement_info sai
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
LEFT JOIN bm_agreement_info bai on sai.agreement_id=bai.agreement_id
|
||||||
|
LEFT JOIN bm_project bp on bp.pro_id=bai.project_id
|
||||||
|
WHERE
|
||||||
|
sai.`status` = '0'
|
||||||
|
AND sai.`is_slt` = '0'
|
||||||
|
AND sai.end_time IS NULL
|
||||||
|
AND sai.back_id IS NULL
|
||||||
|
AND mt.type_id = #{typeId}
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (
|
||||||
|
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
mt.type_name like concat('%', #{keyWord}, '%') or
|
||||||
|
bp.pro_name like concat('%', #{keyWord}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getMaCodeList" resultType="com.bonus.material.basic.domain.StorageInfo">
|
<select id="getMaCodeList" resultType="com.bonus.material.basic.domain.StorageInfo">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue