综合查询
This commit is contained in:
parent
5c0f5e4173
commit
7cf78012b0
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.bonus.material.basic.controller;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingDto;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||||
|
import com.bonus.material.basic.domain.vo.ProjUsingVo;
|
||||||
|
import com.bonus.material.basic.service.ComplexQueryService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 10:52
|
||||||
|
*/
|
||||||
|
@Api(tags = "综合查询")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/complex_query")
|
||||||
|
public class ComplexQueryController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ComplexQueryService complexQueryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "综合查询--工程机具使用列表")
|
||||||
|
@GetMapping("/getProjUsingRecordList")
|
||||||
|
public AjaxResult getProjUsingRecordList(ProjUsingRecord bean) {
|
||||||
|
startPage();
|
||||||
|
List<ProjUsingRecord> pageList = complexQueryService.getProjUsingRecordList(bean);
|
||||||
|
return AjaxResult.success(getDataTable(pageList));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程机具使用列表不带分页
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "综合查询--工程机具使用列表不带分页")
|
||||||
|
@GetMapping("/getProjUsingRecordListNoPage")
|
||||||
|
public AjaxResult getProjUsingRecordListNoPage(ProjUsingRecord bean) {
|
||||||
|
List<ProjUsingRecord> list = complexQueryService.exportProjUsingRecord(bean);
|
||||||
|
ProjUsingDto projUsingDto = new ProjUsingDto();
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
ProjUsingRecord projUsingRecord = list.get(0);
|
||||||
|
projUsingDto.setTotalLeaseNum(projUsingRecord.getLeaseNum());
|
||||||
|
projUsingDto.setTotalBackNum(projUsingRecord.getBackNum());
|
||||||
|
projUsingDto.setTotalUsNum(projUsingRecord.getUsNum());
|
||||||
|
projUsingDto.setTotalUsPrice(projUsingRecord.getUsPrice());
|
||||||
|
projUsingDto.setTotalTotalPrice(projUsingRecord.getTotalPrice());
|
||||||
|
}
|
||||||
|
return AjaxResult.success(projUsingDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出工程机具使用列表
|
||||||
|
* @param response
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出综合查询工程机具使用列表")
|
||||||
|
@PostMapping("/exportProjUsingRecord")
|
||||||
|
public void exportProjUsingRecord(HttpServletResponse response, ProjUsingRecord bean)
|
||||||
|
{
|
||||||
|
List<ProjUsingRecord> list = complexQueryService.exportProjUsingRecord(bean);
|
||||||
|
ExcelUtil<ProjUsingRecord> util = new ExcelUtil<>(ProjUsingRecord.class);
|
||||||
|
util.exportExcel(response, list, "综合查询--工程机具使用查询");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备使用追溯查询
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "综合查询--设备使用追溯查询")
|
||||||
|
@GetMapping("/getMachineHistoryRecordList")
|
||||||
|
public AjaxResult getMachineHistoryRecordList(MachineHistoryRecordBean bean) {
|
||||||
|
startPage();
|
||||||
|
List<MachineHistoryRecordBean> list = complexQueryService.getMachineHistoryRecordList(bean);
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出综合查询设备使用追溯查询")
|
||||||
|
@PostMapping("/exportMachineHistoryRecord")
|
||||||
|
public void exportMachineHistoryRecord(HttpServletResponse response, MachineHistoryRecordBean bean)
|
||||||
|
{
|
||||||
|
List<MachineHistoryRecordBean> list = complexQueryService.getMachineHistoryRecordList(bean);
|
||||||
|
ExcelUtil<MachineHistoryRecordBean> util = new ExcelUtil<>(MachineHistoryRecordBean.class);
|
||||||
|
util.exportExcel(response, list, "综合查询--设备使用追溯查询");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.bonus.material.basic.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 14:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MachineHistoryRecordBean {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议id")
|
||||||
|
private Integer agreementId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议号")
|
||||||
|
@Excel(name = "协议号")
|
||||||
|
private String agreementCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程Id")
|
||||||
|
private Integer proId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程名称")
|
||||||
|
@Excel(name = "工程名称")
|
||||||
|
private String proName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位Id")
|
||||||
|
private Integer unitId;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位")
|
||||||
|
@Excel(name = "往来单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "物资名称")
|
||||||
|
@Excel(name = "物资名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "规格ID")
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格型号")
|
||||||
|
@Excel(name = "规格型号")
|
||||||
|
private String typeModelName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "计量单位")
|
||||||
|
@Excel(name = "计量单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备编码")
|
||||||
|
@Excel(name = "设备编码")
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "领用人员")
|
||||||
|
@Excel(name = "领用人员")
|
||||||
|
private String leaseMan;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "领用时间")
|
||||||
|
@Excel(name = "领用时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date leaseDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "退料人员")
|
||||||
|
@Excel(name = "退料人员")
|
||||||
|
private String backMan;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "退料时间")
|
||||||
|
@Excel(name = "退料时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date backDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态")
|
||||||
|
@Excel(name = "当前状态")
|
||||||
|
private String statusName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="开始时间")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="结束时间")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="关键字")
|
||||||
|
private String keyWord;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.bonus.material.basic.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 13:44
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ProjUsingDto {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "领用数量")
|
||||||
|
@Excel(name = "领用数量")
|
||||||
|
private BigDecimal totalLeaseNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "归还数量")
|
||||||
|
@Excel(name = "归还数量")
|
||||||
|
private BigDecimal totalBackNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用数量")
|
||||||
|
@Excel(name = "在用数量")
|
||||||
|
private BigDecimal totalUsNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用总价值")
|
||||||
|
@Excel(name = "在用总价值(元)")
|
||||||
|
private BigDecimal totalUsPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "投入总价值")
|
||||||
|
@Excel(name = "投入总价值(元)")
|
||||||
|
private BigDecimal totalTotalPrice;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.bonus.material.basic.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 综合查询--退料查询
|
||||||
|
* @author hay
|
||||||
|
* @date 2024/2/26 14:51
|
||||||
|
*/
|
||||||
|
@ApiModel(description = "退料查询")
|
||||||
|
@Data
|
||||||
|
public class ProjUsingRecord {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2227217051604273598L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议号")
|
||||||
|
@Excel(name = "协议号")
|
||||||
|
private String agreementCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程Id")
|
||||||
|
private Integer proId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工程名称")
|
||||||
|
@Excel(name = "工程名称")
|
||||||
|
private String proName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位Id")
|
||||||
|
private Integer unitId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "往来单位")
|
||||||
|
@Excel(name = "往来单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@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 = "领用数量")
|
||||||
|
@Excel(name = "领用数量")
|
||||||
|
private BigDecimal leaseNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "归还数量")
|
||||||
|
@Excel(name = "归还数量")
|
||||||
|
private BigDecimal backNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用数量")
|
||||||
|
@Excel(name = "在用数量")
|
||||||
|
private BigDecimal usNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "在用总价值(元)")
|
||||||
|
@Excel(name = "在用总价值(元)")
|
||||||
|
private BigDecimal usPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "投入总价值(元)")
|
||||||
|
@Excel(name = "投入总价值(元)")
|
||||||
|
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是")
|
||||||
|
@Excel(name = "协议状态")
|
||||||
|
private String isSltName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.bonus.material.basic.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||||
|
import com.bonus.material.basic.domain.vo.ProjUsingVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 10:54
|
||||||
|
*/
|
||||||
|
public interface ComplexQueryMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getProjUsingRecordList(ProjUsingRecord bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备使用追溯查询
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MachineHistoryRecordBean> getMachineHistoryRecordList(MachineHistoryRecordBean bean);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.bonus.material.basic.service;
|
||||||
|
|
||||||
|
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||||
|
import com.bonus.material.basic.domain.vo.ProjUsingVo;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合查询
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 10:53
|
||||||
|
*/
|
||||||
|
public interface ComplexQueryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> getProjUsingRecordList(ProjUsingRecord bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备使用追溯查询
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MachineHistoryRecordBean> getMachineHistoryRecordList(MachineHistoryRecordBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出综合查询工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
List<ProjUsingRecord> exportProjUsingRecord(ProjUsingRecord bean);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.bonus.material.basic.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingDto;
|
||||||
|
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||||
|
import com.bonus.material.basic.domain.vo.ProjUsingVo;
|
||||||
|
import com.bonus.material.basic.mapper.ComplexQueryMapper;
|
||||||
|
import com.bonus.material.basic.service.ComplexQueryService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合查询服务实现类
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/12/16 10:53
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class ComplexQueryServiceImpl implements ComplexQueryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ComplexQueryMapper complexQueryMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProjUsingRecord> getProjUsingRecordList(ProjUsingRecord bean) {
|
||||||
|
return complexQueryMapper.getProjUsingRecordList(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备使用追溯查询
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MachineHistoryRecordBean> getMachineHistoryRecordList(MachineHistoryRecordBean bean) {
|
||||||
|
return complexQueryMapper.getMachineHistoryRecordList(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出工程机具使用列表
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProjUsingRecord> exportProjUsingRecord(ProjUsingRecord bean) {
|
||||||
|
// 使用 BigDecimal 常量初始化
|
||||||
|
BigDecimal totalLeaseNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||||
|
BigDecimal totalBackNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||||
|
BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||||
|
BigDecimal totalUsPrice = BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
BigDecimal totalTotalPrice = BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
List<ProjUsingRecord> list = complexQueryMapper.getProjUsingRecordList(bean);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
ProjUsingRecord projUsingRecord = new ProjUsingRecord();
|
||||||
|
for (ProjUsingRecord record : list) {
|
||||||
|
totalLeaseNum = totalLeaseNum.add(record.getLeaseNum());
|
||||||
|
totalBackNum = totalBackNum.add(record.getBackNum());
|
||||||
|
totalUsNum = totalUsNum.add(record.getUsNum());
|
||||||
|
totalUsPrice = totalUsPrice.add(record.getUsPrice());
|
||||||
|
totalTotalPrice = totalTotalPrice.add(record.getTotalPrice());
|
||||||
|
}
|
||||||
|
// 设置 ProjUsingDto 总结数据
|
||||||
|
projUsingRecord.setLeaseNum(totalLeaseNum.setScale(3, BigDecimal.ROUND_HALF_UP));
|
||||||
|
projUsingRecord.setBackNum(totalBackNum.setScale(3, BigDecimal.ROUND_HALF_UP));
|
||||||
|
projUsingRecord.setUsNum(totalUsNum.setScale(3, BigDecimal.ROUND_HALF_UP));
|
||||||
|
projUsingRecord.setUsPrice(totalUsPrice.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
projUsingRecord.setTotalPrice(totalTotalPrice.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
projUsingRecord.setUnit("合计");
|
||||||
|
list.add(0,projUsingRecord);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,233 @@
|
||||||
|
<?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.material.basic.mapper.ComplexQueryMapper">
|
||||||
|
|
||||||
|
<select id="getProjUsingRecordList" resultType="com.bonus.material.basic.domain.ProjUsingRecord">
|
||||||
|
SELECT
|
||||||
|
subquery1.agreementCode as agreementCode,
|
||||||
|
subquery1.unitName as unitName,
|
||||||
|
subquery1.proName as proName,
|
||||||
|
subquery1.typeName as typeName,
|
||||||
|
subquery1.typeModelName as typeModelName,
|
||||||
|
subquery1.unit as unit,
|
||||||
|
IFNULL(subquery1.leaseNum, 0) as leaseNum,
|
||||||
|
IFNULL(subquery2.backNum, 0) as backNum,
|
||||||
|
CASE
|
||||||
|
WHEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0) > 0
|
||||||
|
THEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0)
|
||||||
|
ELSE 0.000
|
||||||
|
END as usNum,
|
||||||
|
CASE
|
||||||
|
WHEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0) > 0 THEN
|
||||||
|
ROUND(IFNULL(subquery1.buy_price, 0) *
|
||||||
|
(IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0)), 2)
|
||||||
|
ELSE
|
||||||
|
0.00
|
||||||
|
END as usPrice,
|
||||||
|
ROUND(IFNULL(subquery1.leaseNum, 0) * IFNULL(subquery1.buy_price, 0), 2) as totalPrice,
|
||||||
|
subquery1.isSlt as isSlt,
|
||||||
|
subquery1.isSltName as isSltName
|
||||||
|
FROM (SELECT bai.agreement_id,
|
||||||
|
mt.type_id,
|
||||||
|
mt.buy_price,
|
||||||
|
bai.agreement_code AS agreementCode,
|
||||||
|
bui.unit_name AS unitName,
|
||||||
|
bpl.pro_name AS proName,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
SUM(IFNULL(lod.out_num, 0)) AS leaseNum,
|
||||||
|
sai.is_slt as isSlt,
|
||||||
|
CASE
|
||||||
|
sai.is_slt
|
||||||
|
WHEN '0' then '未结算'
|
||||||
|
WHEN '1' then '已结算'
|
||||||
|
ELSE ''
|
||||||
|
END as isSltName
|
||||||
|
FROM lease_out_details lod
|
||||||
|
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
|
||||||
|
LEFT JOIN tm_task_agreement tta ON tta.task_id = lai.task_id
|
||||||
|
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT agreement_id, is_slt
|
||||||
|
FROM slt_agreement_info
|
||||||
|
GROUP BY agreement_id
|
||||||
|
) sai ON bai.agreement_id = sai.agreement_id
|
||||||
|
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
LEFT JOIN ma_machine mm ON mm.ma_id = lod.ma_id
|
||||||
|
where 1=1
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (bai.agreement_code like concat('%',#{keyWord},'%') or
|
||||||
|
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||||
|
bpl.pro_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.unit_name like concat('%',#{keyWord},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="unitId != null">
|
||||||
|
and bui.unit_id = #{unitId}
|
||||||
|
</if>
|
||||||
|
<if test="proId != null">
|
||||||
|
and bpl.pro_id = #{proId}
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%',#{typeName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="typeModelName != null and typeModelName != ''">
|
||||||
|
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
|
AND bai.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||||
|
</if>
|
||||||
|
<if test="isSlt != null and isSlt != ''">
|
||||||
|
and sai.is_slt = #{isSlt}
|
||||||
|
</if>
|
||||||
|
GROUP BY bai.agreement_id,
|
||||||
|
mt.type_id ORDER BY bai.agreement_code) AS subquery1
|
||||||
|
LEFT JOIN (SELECT bai.agreement_id,
|
||||||
|
mt.type_id,
|
||||||
|
mt.rent_price,
|
||||||
|
bai.agreement_code AS agreementCode,
|
||||||
|
bui.unit_name AS unitName,
|
||||||
|
bpl.pro_name AS proName,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
SUM(IFNULL(bcd.back_num, 0)) backNum,
|
||||||
|
sai.is_slt as isSlt,
|
||||||
|
CASE
|
||||||
|
sai.is_slt
|
||||||
|
WHEN '0' then '未结算'
|
||||||
|
WHEN '1' then '已结算'
|
||||||
|
ELSE ''
|
||||||
|
END as isSltName
|
||||||
|
FROM back_check_details bcd
|
||||||
|
LEFT JOIN back_apply_info baif ON baif.id = bcd.parent_id
|
||||||
|
LEFT JOIN tm_task_agreement tta ON tta.task_id = baif.task_id
|
||||||
|
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT agreement_id, is_slt
|
||||||
|
FROM slt_agreement_info
|
||||||
|
GROUP BY agreement_id
|
||||||
|
) sai ON bai.agreement_id = sai.agreement_id
|
||||||
|
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
||||||
|
where 1=1 and bcd.is_finished = '1'
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (bai.agreement_code like concat('%',#{keyWord},'%') or
|
||||||
|
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||||
|
bpl.pro_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.unit_name like concat('%',#{keyWord},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="unitId != null">
|
||||||
|
and bui.unit_id = #{unitId}
|
||||||
|
</if>
|
||||||
|
<if test="proId != null">
|
||||||
|
and bpl.pro_id = #{proId}
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%',#{typeName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="typeModelName != null and typeModelName != ''">
|
||||||
|
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
|
AND bai.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||||
|
</if>
|
||||||
|
<if test="isSlt != null and isSlt != ''">
|
||||||
|
and sai.is_slt = #{isSlt}
|
||||||
|
</if>
|
||||||
|
GROUP BY bai.agreement_id,
|
||||||
|
mt.type_id ORDER BY bai.agreement_code) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||||
|
AND subquery1.agreement_id = subquery2.agreement_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getMachineHistoryRecordList" resultType="com.bonus.material.basic.domain.MachineHistoryRecordBean">
|
||||||
|
SELECT
|
||||||
|
bai.agreement_id,
|
||||||
|
mt.type_id,
|
||||||
|
bai.agreement_code AS agreementCode,
|
||||||
|
bui.unit_name AS unitName,
|
||||||
|
bpl.pro_name AS proName,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
lai.lease_person AS leaseMan,
|
||||||
|
lod.create_time AS leaseDate,
|
||||||
|
mm.ma_code AS maCode,
|
||||||
|
baif.back_person AS backMan,
|
||||||
|
bcd.create_time AS backDate,
|
||||||
|
CASE
|
||||||
|
WHEN baif.back_person IS NULL THEN '已退'
|
||||||
|
ELSE '在用'
|
||||||
|
END AS statusName
|
||||||
|
FROM
|
||||||
|
lease_out_details lod
|
||||||
|
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
|
||||||
|
LEFT JOIN tm_task_agreement tta ON tta.task_id = lai.task_id
|
||||||
|
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
|
||||||
|
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
||||||
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
LEFT JOIN ma_machine mm ON mm.ma_id = lod.ma_id
|
||||||
|
LEFT JOIN back_check_details bcd ON bcd.ma_id = lod.ma_id
|
||||||
|
LEFT JOIN back_apply_info baif ON baif.id = bcd.parent_id
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
AND lod.ma_id IS NOT NULL
|
||||||
|
<if test="keyWord != null and keyWord != ''">
|
||||||
|
and (bai.agreement_code like concat('%',#{keyWord},'%') or
|
||||||
|
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||||
|
bpl.pro_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.type_name like concat('%',#{keyWord},'%') or
|
||||||
|
mt.unit_name like concat('%',#{keyWord},'%') or
|
||||||
|
mm.ma_code like concat('%',#{keyWord},'%') or
|
||||||
|
lai.lease_person like concat('%',#{keyWord},'%') or
|
||||||
|
baif.back_person like concat('%',#{keyWord},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="unitId != null">
|
||||||
|
and bui.unit_id = #{unitId}
|
||||||
|
</if>
|
||||||
|
<if test="proId != null">
|
||||||
|
and bpl.pro_id = #{proId}
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName != ''">
|
||||||
|
and mt2.type_name like concat('%',#{typeName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="typeModelName != null and typeModelName != ''">
|
||||||
|
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||||
|
AND (lod.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||||
|
or bcd.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59'))
|
||||||
|
</if>
|
||||||
|
<if test="statusName != null and statusName != ''">
|
||||||
|
AND (
|
||||||
|
CASE
|
||||||
|
WHEN baif.back_person IS NULL THEN '已退'
|
||||||
|
ELSE '在用'
|
||||||
|
END = #{statusName}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
mm.ma_code
|
||||||
|
ORDER BY
|
||||||
|
bai.agreement_code
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue