综合查询
This commit is contained in:
parent
3fb4ac8d17
commit
dd0dc21126
|
|
@ -26,6 +26,59 @@ public class ComplexQueryController extends BaseController {
|
|||
@Resource
|
||||
private ComplexQueryService complexQueryService;
|
||||
|
||||
/**
|
||||
* 保有设备总量查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "综合查询--保有设备总量查询")
|
||||
@GetMapping("/getRetainedEquipmentList")
|
||||
public AjaxResult getRetainedEquipmentList(RetainedEquipmentInfo bean) {
|
||||
startPage();
|
||||
List<RetainedEquipmentInfo> pageList = complexQueryService.getRetainedEquipmentList(bean);
|
||||
return AjaxResult.success(getDataTable(pageList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保有设备总量查询不带分页
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "综合查询--保有设备总量查询不带分页")
|
||||
@GetMapping("/getRetainedEquipmentListNoPage")
|
||||
public AjaxResult getRetainedEquipmentListNoPage(RetainedEquipmentInfo bean) {
|
||||
List<RetainedEquipmentInfo> list = complexQueryService.getRetainedEquipmentList(bean);
|
||||
RetainedEquipmentInfo dto = new RetainedEquipmentInfo();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
RetainedEquipmentInfo retainedEquipmentInfo = list.get(0);
|
||||
dto.setStoreNum(retainedEquipmentInfo.getStoreNum());
|
||||
dto.setUsNum(retainedEquipmentInfo.getUsNum());
|
||||
dto.setRepairNum(retainedEquipmentInfo.getRepairNum());
|
||||
dto.setInputNum(retainedEquipmentInfo.getInputNum());
|
||||
dto.setRepairInputNum(retainedEquipmentInfo.getRepairInputNum());
|
||||
dto.setAllNum(retainedEquipmentInfo.getAllNum());
|
||||
dto.setTotalPrice(retainedEquipmentInfo.getTotalPrice());
|
||||
dto.setFiveReplacementRate(retainedEquipmentInfo.getFiveReplacementRate());
|
||||
dto.setTenReplacementRate(retainedEquipmentInfo.getTenReplacementRate());
|
||||
dto.setTenPlusReplacementRate(retainedEquipmentInfo.getTenPlusReplacementRate());
|
||||
}
|
||||
return AjaxResult.success(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出综合查询保有设备总量查询
|
||||
* @param response
|
||||
* @param bean
|
||||
*/
|
||||
@ApiOperation("导出综合查询保有设备总量查询")
|
||||
@PostMapping("/exportRetainedEquipmentList")
|
||||
public void exportRetainedEquipmentList(HttpServletResponse response, RetainedEquipmentInfo bean)
|
||||
{
|
||||
List<RetainedEquipmentInfo> list = complexQueryService.getRetainedEquipmentList(bean);
|
||||
ExcelUtil<RetainedEquipmentInfo> util = new ExcelUtil<>(RetainedEquipmentInfo.class);
|
||||
util.exportExcel(response, list, "综合查询--保有设备总量查询");
|
||||
}
|
||||
|
||||
/**
|
||||
* 工程机具使用列表
|
||||
* @param bean
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
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 ma_sh
|
||||
* @date 2024/2/26 14:51
|
||||
*/
|
||||
@ApiModel(description = "保有设备总量查询")
|
||||
@Data
|
||||
public class RetainedEquipmentInfo {
|
||||
|
||||
private static final long serialVersionUID = 2227217051604273598L;
|
||||
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "仓库信息")
|
||||
@Excel(name = "仓库信息")
|
||||
private String whHouseName;
|
||||
|
||||
@ApiModelProperty(value = "施工类型")
|
||||
@Excel(name = "施工类型")
|
||||
private String constructionType;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
@Excel(name = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
@ApiModelProperty(value = "物资名称")
|
||||
@Excel(name = "物资名称")
|
||||
private String typeName;
|
||||
|
||||
@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 BigDecimal storeNum;
|
||||
|
||||
@ApiModelProperty(value = "在用数量")
|
||||
@Excel(name = "在用数量")
|
||||
private BigDecimal usNum;
|
||||
|
||||
@ApiModelProperty(value = "在修数量")
|
||||
@Excel(name = "在修数量")
|
||||
private BigDecimal repairNum;
|
||||
|
||||
@ApiModelProperty(value = "新购待入库")
|
||||
@Excel(name = "新购待入库数量")
|
||||
private BigDecimal inputNum;
|
||||
|
||||
@ApiModelProperty(value = "修试后待入库")
|
||||
@Excel(name = "修试待入库数量")
|
||||
private BigDecimal repairInputNum;
|
||||
|
||||
@ApiModelProperty(value = "总保有量")
|
||||
@Excel(name = "总保有数量")
|
||||
private BigDecimal allNum;
|
||||
|
||||
@ApiModelProperty(value = "购置单价")
|
||||
private BigDecimal buyPrice;
|
||||
|
||||
@ApiModelProperty(value = "投入总价值")
|
||||
@Excel(name = "总保有量资产(万元)")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty(value = "五年以内成新率")
|
||||
@Excel(name = "五年以内成新率")
|
||||
private String fiveReplacementRate;
|
||||
|
||||
@ApiModelProperty(value = "五年以内设备数量")
|
||||
private BigDecimal fiveReplacementNum;
|
||||
|
||||
@ApiModelProperty(value = "五年至十年成新率")
|
||||
@Excel(name = "五年至十年成新率")
|
||||
private String tenReplacementRate;
|
||||
|
||||
@ApiModelProperty(value = "五年至十年设备数量")
|
||||
private BigDecimal tenReplacementNum;
|
||||
|
||||
@ApiModelProperty(value = "十年以上成新率")
|
||||
@Excel(name = "十年以上成新率")
|
||||
private String tenPlusReplacementRate;
|
||||
|
||||
@ApiModelProperty(value = "十年以上设备数量")
|
||||
private BigDecimal tenPlusReplacementNum;
|
||||
|
||||
@ApiModelProperty(value = "管理模式")
|
||||
@Excel(name = "管理模式")
|
||||
private String manageType;
|
||||
|
||||
@ApiModelProperty(value = "创建者")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新者")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty(value = "更新时间 ")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "数据所属组织")
|
||||
private Integer companyId;
|
||||
|
||||
/** 1.机具仓储 2.调试仓储 */
|
||||
private String maType;
|
||||
|
||||
private String maTypeName;
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package com.bonus.material.basic.mapper;
|
||||
|
||||
import com.bonus.material.basic.domain.InputRecordInfo;
|
||||
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||
import com.bonus.material.basic.domain.OutRecordInfo;
|
||||
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||
import com.bonus.material.basic.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -40,4 +37,11 @@ public interface ComplexQueryMapper {
|
|||
* @return
|
||||
*/
|
||||
List<OutRecordInfo> getOutRecordList(OutRecordInfo bean);
|
||||
|
||||
/**
|
||||
* 保有设备总量查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getRetainedEquipmentList(RetainedEquipmentInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.bonus.material.basic.service;
|
||||
|
||||
import com.bonus.material.basic.domain.InputRecordInfo;
|
||||
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||
import com.bonus.material.basic.domain.OutRecordInfo;
|
||||
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||
import com.bonus.material.basic.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -47,4 +44,11 @@ public interface ComplexQueryService {
|
|||
* @return
|
||||
*/
|
||||
List<OutRecordInfo> getOutRecordList(OutRecordInfo bean);
|
||||
|
||||
/**
|
||||
* 保有设备总量查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getRetainedEquipmentList(RetainedEquipmentInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package com.bonus.material.basic.service.impl;
|
|||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.material.basic.domain.InputRecordInfo;
|
||||
import com.bonus.material.basic.domain.MachineHistoryRecordBean;
|
||||
import com.bonus.material.basic.domain.OutRecordInfo;
|
||||
import com.bonus.material.basic.domain.ProjUsingRecord;
|
||||
import com.bonus.material.basic.domain.*;
|
||||
import com.bonus.material.basic.mapper.ComplexQueryMapper;
|
||||
import com.bonus.material.basic.service.ComplexQueryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -155,4 +152,98 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保有设备总量查询
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<RetainedEquipmentInfo> getRetainedEquipmentList(RetainedEquipmentInfo bean) {
|
||||
BigDecimal totalPrice = BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalStoreNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalRepairNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalInputNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalRepairInputNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal totalAllNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal fiveReplacementNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal tenReplacementNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal tenPlusReplacementNum = BigDecimal.ZERO.setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||
String fiveReplacementRate = "0%";
|
||||
String tenReplacementRate = "0%";
|
||||
String tenPlusReplacementRate = "0%";
|
||||
List<RetainedEquipmentInfo> recordList = complexQueryMapper.getRetainedEquipmentList(bean);
|
||||
if (CollectionUtils.isNotEmpty(recordList)) {
|
||||
for (RetainedEquipmentInfo retainedEquipmentInfo : recordList) {
|
||||
totalStoreNum = totalStoreNum.add(retainedEquipmentInfo.getStoreNum());
|
||||
totalUsNum = totalUsNum.add(retainedEquipmentInfo.getUsNum());
|
||||
totalRepairNum = totalRepairNum.add(retainedEquipmentInfo.getRepairNum());
|
||||
totalInputNum = totalInputNum.add(retainedEquipmentInfo.getInputNum());
|
||||
totalRepairInputNum = totalRepairInputNum.add(retainedEquipmentInfo.getRepairInputNum());
|
||||
totalAllNum = totalAllNum.add(retainedEquipmentInfo.getAllNum());
|
||||
fiveReplacementNum = fiveReplacementNum.add(retainedEquipmentInfo.getFiveReplacementNum());
|
||||
tenReplacementNum = tenReplacementNum.add(retainedEquipmentInfo.getTenReplacementNum());
|
||||
tenPlusReplacementNum = tenPlusReplacementNum.add(retainedEquipmentInfo.getTenPlusReplacementNum());
|
||||
BigDecimal equipmentPrice = retainedEquipmentInfo.getAllNum()
|
||||
.multiply(retainedEquipmentInfo.getBuyPrice())
|
||||
.divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP);
|
||||
totalPrice = totalPrice.add(equipmentPrice);
|
||||
BigDecimal allNum = retainedEquipmentInfo.getAllNum();
|
||||
if (allNum.compareTo(BigDecimal.ZERO) == 0) {
|
||||
fiveReplacementRate = "0%";
|
||||
tenReplacementRate = "0%";
|
||||
tenPlusReplacementRate = "0%";
|
||||
} else {
|
||||
fiveReplacementRate = retainedEquipmentInfo.getFiveReplacementNum()
|
||||
.divide(allNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
tenReplacementRate = retainedEquipmentInfo.getTenReplacementNum()
|
||||
.divide(allNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
tenPlusReplacementRate = retainedEquipmentInfo.getTenPlusReplacementNum()
|
||||
.divide(allNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
}
|
||||
retainedEquipmentInfo.setFiveReplacementRate(fiveReplacementRate);
|
||||
retainedEquipmentInfo.setTenReplacementRate(tenReplacementRate);
|
||||
retainedEquipmentInfo.setTenPlusReplacementRate(tenPlusReplacementRate);
|
||||
}
|
||||
RetainedEquipmentInfo retainedEquipmentInfo = new RetainedEquipmentInfo();
|
||||
if (totalAllNum.compareTo(BigDecimal.ZERO) == 0) {
|
||||
fiveReplacementRate = "0%";
|
||||
tenReplacementRate = "0%";
|
||||
tenPlusReplacementRate = "0%";
|
||||
} else {
|
||||
fiveReplacementRate = fiveReplacementNum
|
||||
.divide(totalAllNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
tenReplacementRate = tenReplacementNum
|
||||
.divide(totalAllNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
tenPlusReplacementRate = tenPlusReplacementNum
|
||||
.divide(totalAllNum, 4, BigDecimal.ROUND_HALF_DOWN)
|
||||
.multiply(new BigDecimal(100))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
|
||||
}
|
||||
retainedEquipmentInfo.setStoreNum(totalStoreNum);
|
||||
retainedEquipmentInfo.setUsNum(totalUsNum);
|
||||
retainedEquipmentInfo.setRepairNum(totalRepairNum);
|
||||
retainedEquipmentInfo.setInputNum(totalInputNum);
|
||||
retainedEquipmentInfo.setRepairInputNum(totalRepairInputNum);
|
||||
retainedEquipmentInfo.setAllNum(totalAllNum);
|
||||
retainedEquipmentInfo.setTotalPrice(totalPrice);
|
||||
retainedEquipmentInfo.setFiveReplacementRate(fiveReplacementRate);
|
||||
retainedEquipmentInfo.setTenReplacementRate(tenReplacementRate);
|
||||
retainedEquipmentInfo.setTenPlusReplacementRate(tenPlusReplacementRate);
|
||||
retainedEquipmentInfo.setUnit("合计");
|
||||
recordList.add(0, retainedEquipmentInfo);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,25 +42,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectBmStorageLogList" resultType="com.bonus.common.biz.domain.BmStorageLog">
|
||||
SELECT
|
||||
id as id, model_title as modelTitle, method as method, type_id as typeId, pre_store_num as preStoreNum,
|
||||
in_num as inNum, out_num as outNum, back_num as backNum,
|
||||
pass_num as passNum, repair_num as repairNum,
|
||||
scrap_num as scrapNum, post_store_num as postStoreNum, task_id as taskId, agreement_id as agreementId,
|
||||
manage_type as manageType, type_name as typeName,
|
||||
type_model_name as typeModelName, result_code as resultCode,
|
||||
result_msg as resultMsg, remark as remark, status as status, json_result as jsonResult, creator as creator,
|
||||
create_time as createTime
|
||||
bs.id as id, bs.model_title as modelTitle, bs.method as method, bs.type_id as typeId, bs.pre_store_num as preStoreNum,
|
||||
bs.in_num as inNum, bs.out_num as outNum, bs.back_num as backNum,
|
||||
bs.pass_num as passNum, bs.repair_num as repairNum,
|
||||
bs.scrap_num as scrapNum, bs.post_store_num as postStoreNum, bs.task_id as taskId, bs.agreement_id as agreementId,
|
||||
bs.manage_type as manageType, mt1.type_name as typeName,
|
||||
mt.type_name as typeModelName, bs.result_code as resultCode,
|
||||
bs.result_msg as resultMsg, bs.remark as remark, bs.status as status, bs.json_result as jsonResult, bs.creator as creator,
|
||||
bs.create_time as createTime
|
||||
FROM
|
||||
bm_storage_log
|
||||
bm_storage_log bs
|
||||
LEFT JOIN ma_type mt ON bs.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
<where>
|
||||
<if test="modelTitle != null and modelTitle != ''">
|
||||
and model_title like concat('%', #{modelTitle}, '%')
|
||||
and bs.model_title like concat('%', #{modelTitle}, '%')
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
and type_name like concat('%', #{typeName}, '%')
|
||||
and mt.type_name like concat('%', #{typeName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
ORDER BY bs.create_time DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertBmStorageLog" parameterType="com.bonus.common.biz.domain.BmStorageLog" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getInputRecordList" resultType="com.bonus.material.basic.domain.InputRecordInfo">
|
||||
SELECT
|
||||
bs.type_name as typeName,
|
||||
bs.type_model_name as typeModelName,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as typeModelName,
|
||||
bs.ma_code as maCode,
|
||||
mt.unit_name as unit,
|
||||
bs.in_num as inputNum,
|
||||
|
|
@ -257,6 +257,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bm_storage_log bs
|
||||
LEFT JOIN ma_type mt ON bs.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN tm_task tt ON bs.task_id = tt.task_id
|
||||
WHERE bs.in_num != 0
|
||||
<if test="inputType != null and inputType != ''">
|
||||
|
|
@ -285,8 +287,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bpl.pro_name AS proName,
|
||||
bui.unit_name AS unitName,
|
||||
bai.agreement_code AS agreementCode,
|
||||
bs.type_name as typeName,
|
||||
bs.type_model_name as typeModelName,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as typeModelName,
|
||||
bs.ma_code as maCode,
|
||||
mt.unit_name as unit,
|
||||
bs.out_num as outNum,
|
||||
|
|
@ -308,6 +310,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||
LEFT JOIN ma_type mt ON bs.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN tm_task tt ON bs.task_id = tt.task_id
|
||||
WHERE bs.out_num != 0
|
||||
<if test="unitId != null">
|
||||
|
|
@ -338,4 +342,182 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getRetainedEquipmentList" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||
SELECT
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
IFNULL(mt.buy_price, 0) AS buyPrice,
|
||||
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)
|
||||
ELSE
|
||||
IFNULL(mt.storage_num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
|
||||
+ IFNULL(subquery4.inputNum, 0)
|
||||
END AS allNum,
|
||||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
'编码'
|
||||
ELSE
|
||||
'数量'
|
||||
END manageType,
|
||||
IFNULL(subquery5.fiveReplacementNum, 0) AS fiveReplacementNum,
|
||||
IFNULL(subquery5.tenReplacementNum, 0) AS tenReplacementNum,
|
||||
IFNULL(subquery5.tenPlusReplacementNum, 0) AS tenPlusReplacementNum
|
||||
FROM ma_type mt
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
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
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
||||
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
subquery1.type_id,
|
||||
subquery1.typeName,
|
||||
subquery1.typeModelName,
|
||||
IFNULL(subquery1.outNum, 0) AS outNum,
|
||||
IFNULL(subquery2.backNum, 0) AS backNum,
|
||||
CASE
|
||||
|
||||
WHEN IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0) > 0 THEN
|
||||
IFNULL(subquery1.outNum, 0) - IFNULL(subquery2.backNum, 0)
|
||||
ELSE 0
|
||||
END AS usNum
|
||||
FROM (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(IFNULL(lod.out_num, 0)) AS outNum
|
||||
FROM lease_out_details lod
|
||||
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_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
GROUP BY mt.type_id) AS subquery1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(IFNULL(bcd.back_num, 0)) backNum
|
||||
FROM back_check_details bcd
|
||||
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_type mt3 ON mt3.type_id = mt2.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
|
||||
GROUP BY mt.type_id) AS subquery2
|
||||
ON subquery1.type_id = subquery2.type_id) AS subquery1
|
||||
ON mt.type_id = subquery1.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(
|
||||
IFNULL(rad.repair_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
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE
|
||||
rad.status = '0'
|
||||
GROUP BY
|
||||
mt.type_id) AS subquery2 ON subquery2.type_id = mt.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(
|
||||
IFNULL(rid.repair_num, 0) - IFNULL(rid.input_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
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE IFNULL(rid.repair_num, 0) - IFNULL(rid.input_num, 0) > 0
|
||||
GROUP BY
|
||||
mt.type_id) AS subquery3 ON subquery3.type_id = mt.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt4.type_name AS constructionType,
|
||||
mt3.type_name AS materialType,
|
||||
mt2.type_name AS typeName,
|
||||
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
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE IFNULL(pcd.check_num, 0) - IFNULL(pcd.input_num, 0) > 0
|
||||
GROUP BY
|
||||
mt.type_id) AS subquery4 ON subquery4.type_id = mt.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id AS typeId,
|
||||
IFNULL(SUM(IF(TIMESTAMPDIFF(YEAR,pcd.create_time,now()) < 5, pcd.input_num,0)),0) AS fiveReplacementNum,
|
||||
IFNULL(SUM(IF(TIMESTAMPDIFF(YEAR,pcd.create_time,now()) >= 5 and TIMESTAMPDIFF(YEAR,pcd.create_time,now()) < 10, pcd.input_num,0)),0) AS tenReplacementNum,
|
||||
IFNULL(SUM(IF(TIMESTAMPDIFF(YEAR,pcd.create_time,now()) >= 10, pcd.input_num,0)),0) AS tenPlusReplacementNum
|
||||
FROM purchase_check_details pcd
|
||||
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
|
||||
GROUP BY mt.type_id
|
||||
) subquery5 ON subquery5.typeId = mt.type_id
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.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
|
||||
WHERE mt.`level` = 4
|
||||
and mt.del_flag = '0'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
mt4.type_name like concat('%',#{keyWord},'%') or
|
||||
mt3.type_name like concat('%',#{keyWord},'%') or
|
||||
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||
mt.type_name like concat('%',#{keyWord},'%')
|
||||
)
|
||||
</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>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue