jsk 根据机具类型查询机具列表接口 根据工程/往来单位/协议号查询机具信息 根据工程查询领用信息
This commit is contained in:
parent
a4c53207ea
commit
0901a311a0
|
|
@ -5,6 +5,8 @@ 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.core.web.page.TableDataInfo;
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||||
|
import com.bonus.material.clz.domain.vo.lease.LeaseTotalInfo;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
import com.bonus.material.push.domain.vo.IwsCostPushExportVo;
|
import com.bonus.material.push.domain.vo.IwsCostPushExportVo;
|
||||||
import com.bonus.material.push.service.IwsCostPushService;
|
import com.bonus.material.push.service.IwsCostPushService;
|
||||||
|
|
@ -216,4 +218,45 @@ public class IwsCostPushController extends BaseController {
|
||||||
return iwsCostPushService.computeTheMonthCost(obj);
|
return iwsCostPushService.computeTheMonthCost(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程查询领用信息
|
||||||
|
* @author jsk
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "根据工程查询领用信息")
|
||||||
|
@GetMapping("/getProLeaseInfo")
|
||||||
|
public AjaxResult getProLeaseInfo(IwsCostPushBean info) {
|
||||||
|
startPage();
|
||||||
|
List<IwsCostPushBean> list = iwsCostPushService.getProLeaseInfo(info);
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机具类型查询机具列表接口
|
||||||
|
* @author jsk
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "根据机具类型查询机具列表接口")
|
||||||
|
@GetMapping("/getDeviceInfoPageByMaType")
|
||||||
|
public AjaxResult getEquipmentListByType(IwsCostPushBean info) {
|
||||||
|
startPage();
|
||||||
|
List<MaterialRetainedEquipmentInfo> list = iwsCostPushService.getEquipmentListByType(info);
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程/往来单位/协议号查询机具信息
|
||||||
|
* @author jsk
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "根据工程/往来单位/协议号查询机具信息")
|
||||||
|
@GetMapping("/getDeviceInfoPageByAgreementProject")
|
||||||
|
public AjaxResult getEquipmentListByAgreementCode(IwsCostPushBean info) {
|
||||||
|
startPage();
|
||||||
|
List<MaterialRetainedEquipmentInfo> list = iwsCostPushService.getEquipmentListByAgreementCode(info);
|
||||||
|
return AjaxResult.success(getDataTable(list));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public class IwsCostPushBean implements Serializable {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
// 协议号
|
// 协议号
|
||||||
@Excel(name = "协议号", sort = 1)
|
@Excel(name = "协议号", sort = 1)
|
||||||
private String agreementCode;
|
private String agreementCode;
|
||||||
|
|
@ -146,4 +147,24 @@ public class IwsCostPushBean implements Serializable {
|
||||||
|
|
||||||
// 是否删除 false未删除 true已删除
|
// 是否删除 false未删除 true已删除
|
||||||
private boolean delFlag = false;
|
private boolean delFlag = false;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "预领料数")
|
||||||
|
private BigDecimal preNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "待出库数量")
|
||||||
|
private BigDecimal pendingNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "出库数量")
|
||||||
|
@Excel(name = "出库数量")
|
||||||
|
private BigDecimal outNum;
|
||||||
|
// 工程id数组
|
||||||
|
private String[] projectIds;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
private String deviceModel;
|
||||||
|
private String deviceStatus;
|
||||||
|
private String maType;
|
||||||
|
|
||||||
|
private String maTypeName;
|
||||||
|
private String maModelName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.bonus.material.push.mapper;
|
package com.bonus.material.push.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||||
|
import com.bonus.material.clz.domain.vo.lease.LeaseTotalInfo;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
|
@ -45,4 +47,30 @@ public interface IwsCostPushMapper {
|
||||||
* @param record 协议信息及条件
|
* @param record 协议信息及条件
|
||||||
*/
|
*/
|
||||||
List<IwsCostPushBean> getPaidSltBaseInfo(IwsCostPushBean record);
|
List<IwsCostPushBean> getPaidSltBaseInfo(IwsCostPushBean record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jsk
|
||||||
|
*根据工程查询领用信息
|
||||||
|
*/
|
||||||
|
List<IwsCostPushBean> getProLeaseInfo(IwsCostPushBean record);
|
||||||
|
/**
|
||||||
|
* 工器具领料记录总数
|
||||||
|
* @param leaseTotalInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IwsCostPushBean getTotalInfo(IwsCostPushBean leaseTotalInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工器具领料记录总数
|
||||||
|
* @param leaseTotalInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaterialRetainedEquipmentInfo> getEquipmentListByType(IwsCostPushBean leaseTotalInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工器具领料记录总数
|
||||||
|
* @param leaseTotalInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaterialRetainedEquipmentInfo> getEquipmentListByAgreementCode(IwsCostPushBean leaseTotalInfo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.material.push.service;
|
package com.bonus.material.push.service;
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -33,4 +34,19 @@ public interface IwsCostPushService {
|
||||||
* 根据协议ID及月份查询当月租赁费用明细
|
* 根据协议ID及月份查询当月租赁费用明细
|
||||||
*/
|
*/
|
||||||
List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record);
|
List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程查询领用信息
|
||||||
|
*/
|
||||||
|
List<IwsCostPushBean> getProLeaseInfo(IwsCostPushBean record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机具类型查询机具列表接口
|
||||||
|
*/
|
||||||
|
List<MaterialRetainedEquipmentInfo> getEquipmentListByType(IwsCostPushBean record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程/往来单位/协议号查询机具信息
|
||||||
|
*/
|
||||||
|
List<MaterialRetainedEquipmentInfo> getEquipmentListByAgreementCode(IwsCostPushBean record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
import com.bonus.common.biz.config.DateTimeHelper;
|
import com.bonus.common.biz.config.DateTimeHelper;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||||
|
import com.bonus.material.clz.domain.vo.lease.LeaseTotalInfo;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
import com.bonus.material.push.mapper.IwsCostPushMapper;
|
import com.bonus.material.push.mapper.IwsCostPushMapper;
|
||||||
import com.bonus.material.push.service.IwsCostPushService;
|
import com.bonus.material.push.service.IwsCostPushService;
|
||||||
|
|
@ -315,4 +317,102 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
||||||
|
|
||||||
return daysBetween;
|
return daysBetween;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jsk
|
||||||
|
*根据工程查询领用信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<IwsCostPushBean> getProLeaseInfo(IwsCostPushBean info) {
|
||||||
|
List<IwsCostPushBean> list=new ArrayList<>();
|
||||||
|
try{
|
||||||
|
BigDecimal preNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal outNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal pendingNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
info.setProjectId(String.join(",", info.getProjectIds()));
|
||||||
|
list=iwsCostPushMapper.getProLeaseInfo(info);
|
||||||
|
if (!org.springframework.util.CollectionUtils.isEmpty(list)) {
|
||||||
|
for (IwsCostPushBean leaseTotalInfo : list) {
|
||||||
|
// 根据typeId和parentId查询领料数量
|
||||||
|
IwsCostPushBean totalInfo = iwsCostPushMapper.getTotalInfo(leaseTotalInfo);
|
||||||
|
if (totalInfo != null) {
|
||||||
|
leaseTotalInfo.setPreNum(totalInfo.getPreNum());
|
||||||
|
leaseTotalInfo.setPendingNum(leaseTotalInfo.getPreNum().subtract(leaseTotalInfo.getOutNum()));
|
||||||
|
}
|
||||||
|
preNum = preNum.add(leaseTotalInfo.getPreNum());
|
||||||
|
outNum = outNum.add(leaseTotalInfo.getOutNum());
|
||||||
|
pendingNum = pendingNum.add(leaseTotalInfo.getPendingNum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机具类型查询机具列表接口
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MaterialRetainedEquipmentInfo> getEquipmentListByType(IwsCostPushBean bean) {
|
||||||
|
BigDecimal totalPrice = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalStoreNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalRepairNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalInputNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalRepairInputNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalAllNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
try{
|
||||||
|
bean.setProjectId(String.join(",", bean.getProjectIds()));
|
||||||
|
}catch (Exception e){}
|
||||||
|
List<MaterialRetainedEquipmentInfo> recordList = iwsCostPushMapper.getEquipmentListByType(bean);
|
||||||
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
||||||
|
for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : recordList) {
|
||||||
|
totalStoreNum = totalStoreNum.add(retainedEquipmentInfo.getStoreNum());
|
||||||
|
totalUsNum = totalUsNum.add(retainedEquipmentInfo.getUsNum());
|
||||||
|
totalAllNum = totalAllNum.add(retainedEquipmentInfo.getAllNum());
|
||||||
|
BigDecimal equipmentPrice = retainedEquipmentInfo.getAllNum()
|
||||||
|
.multiply(retainedEquipmentInfo.getBuyPrice())
|
||||||
|
.divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
||||||
|
totalPrice = totalPrice.add(equipmentPrice);
|
||||||
|
retainedEquipmentInfo.setTotalPrice(equipmentPrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return recordList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工程/往来单位/协议号查询机具信息
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MaterialRetainedEquipmentInfo> getEquipmentListByAgreementCode(IwsCostPushBean bean) {
|
||||||
|
BigDecimal totalPrice = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalStoreNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalRepairNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalInputNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalRepairInputNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal totalAllNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP);
|
||||||
|
try{
|
||||||
|
bean.setProjectId(String.join(",", bean.getProjectIds()));
|
||||||
|
}catch (Exception e){}
|
||||||
|
List<MaterialRetainedEquipmentInfo> recordList = iwsCostPushMapper.getEquipmentListByAgreementCode(bean);
|
||||||
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
||||||
|
for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : recordList) {
|
||||||
|
totalStoreNum = totalStoreNum.add(retainedEquipmentInfo.getStoreNum());
|
||||||
|
totalUsNum = totalUsNum.add(retainedEquipmentInfo.getUsNum());
|
||||||
|
totalAllNum = totalAllNum.add(retainedEquipmentInfo.getAllNum());
|
||||||
|
BigDecimal equipmentPrice = retainedEquipmentInfo.getAllNum()
|
||||||
|
.multiply(retainedEquipmentInfo.getBuyPrice())
|
||||||
|
.divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
||||||
|
totalPrice = totalPrice.add(equipmentPrice);
|
||||||
|
retainedEquipmentInfo.setTotalPrice(equipmentPrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return recordList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,4 +128,271 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<select id="getProLeaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||||
|
SELECT
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name AS unitName,
|
||||||
|
sai.lease_price as leasePrice,
|
||||||
|
bma.agreement_id AS agreementId,sai.type_id as typeId,
|
||||||
|
IFNULL(mt.lease_price ,0) as nowLeasePrice,
|
||||||
|
sai.buy_price as buyPrice,sai.num AS leaseNum,sai.start_time AS leaseDate,sai.end_time AS backDate,
|
||||||
|
IF(sai.`status` = 0,sai.num,0) as returnNum,
|
||||||
|
(datediff(sai.end_time,sai.start_time)+1) * (sai.num) * (sai.lease_price) AS leaseMoney,
|
||||||
|
bma.`agreement_code` AS agreementCode,bma.project_id as projectId,
|
||||||
|
bma.is_slt AS isSettlement,
|
||||||
|
bma.sign_time AS settlementTime,
|
||||||
|
bma.is_push AS isPush
|
||||||
|
FROM bm_agreement_info bma
|
||||||
|
LEFT JOIN slt_agreement_info sai ON bma.agreement_id = sai.agreement_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||||
|
where 1=1
|
||||||
|
<if test="projectId != null and projectId != ''">
|
||||||
|
and bma.project_id in (${projectId})
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTotalInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||||
|
SELECT
|
||||||
|
parent_id as parentId,
|
||||||
|
pre_num AS preNum
|
||||||
|
FROM
|
||||||
|
clz_lease_apply_details
|
||||||
|
WHERE
|
||||||
|
type_id = #{typeId}
|
||||||
|
AND parent_id = #{parentId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getEquipmentListByType" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
IFNULL(mt.lease_price, 0) AS buyPrice,
|
||||||
|
IFNULL(subquery1.usNum, 0) AS storeNum,
|
||||||
|
IFNULL(subquery3.usNum, 0) AS usNum,
|
||||||
|
IFNULL(subquery1.usNum, 0) + IFNULL(subquery3.usNum, 0)
|
||||||
|
AS allNum,
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
'编码'
|
||||||
|
ELSE
|
||||||
|
'数量'
|
||||||
|
END manageType
|
||||||
|
FROM ma_type mt
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
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
|
||||||
|
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 bm_agreement_info bai on sai.agreement_id=bai.agreement_id
|
||||||
|
WHERE
|
||||||
|
sai.`status` = '0'
|
||||||
|
<if test="agreementCode != null and agreementCode != ''">
|
||||||
|
and bai.agreement_code =#{agreementCode}
|
||||||
|
</if>
|
||||||
|
<if test="projectId != null and projectId != ''">
|
||||||
|
and bai.project_id in (${projectId})
|
||||||
|
</if>
|
||||||
|
AND sai.end_time IS NULL
|
||||||
|
AND sai.back_id IS NULL
|
||||||
|
GROUP BY mt.type_id
|
||||||
|
) AS subquery1
|
||||||
|
ON mt.type_id = subquery1.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
subquery3.type_id,
|
||||||
|
subquery3.typeName,
|
||||||
|
subquery3.typeModelName,
|
||||||
|
IFNULL(subquery3.outNum, 0) AS outNum,
|
||||||
|
IFNULL(subquery4.backNum, 0) AS backNum,
|
||||||
|
CASE
|
||||||
|
WHEN IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0) > 0 THEN
|
||||||
|
IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0)
|
||||||
|
ELSE 0
|
||||||
|
END AS usNum
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL(lod.out_num, 0)) AS outNum
|
||||||
|
FROM clz_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
|
||||||
|
WHERE lod.is_finished = '1'
|
||||||
|
GROUP BY mt.type_id) AS subquery3
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL(bcd.back_num, 0)) backNum
|
||||||
|
FROM clz_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
|
||||||
|
WHERE bcd.is_finished = '1'
|
||||||
|
GROUP BY mt.type_id) AS subquery4
|
||||||
|
ON subquery3.type_id = subquery4.type_id) AS subquery3
|
||||||
|
ON mt.type_id = subquery3.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="deviceName != null and deviceName != ''">
|
||||||
|
and mt2.type_name like concat('%',#{deviceName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="deviceModel != null and deviceModel != ''">
|
||||||
|
and mt.type_name like concat('%',#{deviceModel},'%')
|
||||||
|
</if>
|
||||||
|
<if test="maType != null and maType != ''">
|
||||||
|
and mt3.type_name like concat('%',#{maType},'%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getEquipmentListByAgreementCode" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit,
|
||||||
|
IFNULL(mt.lease_price, 0) AS buyPrice,
|
||||||
|
IFNULL(subquery1.usNum, 0) AS storeNum,
|
||||||
|
IFNULL(subquery3.usNum, 0) AS usNum,
|
||||||
|
IFNULL(subquery1.usNum, 0) + IFNULL(subquery3.usNum, 0)
|
||||||
|
AS allNum,
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
'编码'
|
||||||
|
ELSE
|
||||||
|
'数量'
|
||||||
|
END manageType
|
||||||
|
FROM ma_type mt
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
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
|
||||||
|
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
|
||||||
|
sai.`status` = '0'
|
||||||
|
AND sai.end_time IS NULL
|
||||||
|
AND sai.back_id IS NULL
|
||||||
|
GROUP BY mt.type_id
|
||||||
|
) AS subquery1
|
||||||
|
ON mt.type_id = subquery1.type_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
subquery3.type_id,
|
||||||
|
subquery3.typeName,
|
||||||
|
subquery3.typeModelName,
|
||||||
|
IFNULL(subquery3.outNum, 0) AS outNum,
|
||||||
|
IFNULL(subquery4.backNum, 0) AS backNum,
|
||||||
|
CASE
|
||||||
|
|
||||||
|
WHEN IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0) > 0 THEN
|
||||||
|
IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0)
|
||||||
|
ELSE 0
|
||||||
|
END AS usNum
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL(lod.out_num, 0)) AS outNum
|
||||||
|
FROM clz_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
|
||||||
|
WHERE lod.is_finished = '1'
|
||||||
|
GROUP BY mt.type_id) AS subquery3
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt4.type_id AS firstTypeId,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt3.type_id AS secondTypeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt2.type_id AS thirdTypeId,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
SUM(IFNULL(bcd.back_num, 0)) backNum
|
||||||
|
FROM clz_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
|
||||||
|
WHERE bcd.is_finished = '1'
|
||||||
|
GROUP BY mt.type_id) AS subquery4
|
||||||
|
ON subquery3.type_id = subquery4.type_id) AS subquery3
|
||||||
|
ON mt.type_id = subquery3.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="maModelName != null and maModelName != ''">
|
||||||
|
and mt.type_name like concat('%',#{maModelName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="maTypeName != null and maTypeName != ''">
|
||||||
|
and mt2.type_name like concat('%',#{maTypeName},'%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue