成套机具和退料申请当前在用量代码提交
This commit is contained in:
parent
3edb63e8b8
commit
bf0992137d
|
|
@ -29,7 +29,7 @@ public class CompositeQueryController extends BaseController {
|
|||
* @param
|
||||
* @return 抱杆台账查询
|
||||
*/
|
||||
@Log(title = "抱杆台账查询", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "抱杆台账查询")
|
||||
@GetMapping("/getHoldingLedger")
|
||||
public AjaxResult getHoldingLedger(StorageStatus storageStatus) {
|
||||
startPage();
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ public class TmTaskController extends BaseController {
|
|||
if (StringUtils.isNull(task)) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
if (StringUtils.isNotNull(task.getLeaseApplyInfo().getPhone())) {
|
||||
if (StringUtils.isNotBlank(task.getLeaseApplyInfo().getPhone())) {
|
||||
String phone = task.getLeaseApplyInfo().getPhone();
|
||||
if (!PhoneUtil.isMobile(phone)){
|
||||
logger.error("手机号格式错误 :{}", phone);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.sgzb.app.domain;
|
||||
|
||||
import com.bonus.sgzb.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -13,6 +15,21 @@ public class MachinePart {
|
|||
private String typeName;
|
||||
private String modelId;
|
||||
private Integer parentId;
|
||||
private Integer partNum;
|
||||
private Integer num;
|
||||
private Double partNum;
|
||||
private Double num;
|
||||
private Integer typeId;
|
||||
/** 名称 */
|
||||
@ApiModelProperty(value = "厂家名称")
|
||||
private String supplier;
|
||||
|
||||
/**
|
||||
* 在用数量
|
||||
*/
|
||||
@ApiModelProperty(value = "在用数量")
|
||||
private Double usNum;
|
||||
/**
|
||||
* 总保有量
|
||||
*/
|
||||
@ApiModelProperty(value = "总保有量")
|
||||
private Double allNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class TmTask implements Serializable {
|
|||
* 库存
|
||||
*/
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer num;
|
||||
private Double num;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
|
|
@ -258,7 +258,7 @@ public class TmTask implements Serializable {
|
|||
private String maId;
|
||||
private String maStatus;
|
||||
private String typeId;
|
||||
private Integer partNum;
|
||||
private Double partNum;
|
||||
@ApiModelProperty(value = "预计领料时间(重庆)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.sgzb.app.mapper;
|
|||
import com.bonus.sgzb.app.domain.MachinePart;
|
||||
import com.bonus.sgzb.app.domain.StorageStatus;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
import com.bonus.sgzb.base.domain.MaSupplierInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -16,4 +17,8 @@ public interface HoldingLedgerMapper {
|
|||
List<StorageStatus> getHoldingLedger(StorageStatus storageStatus);
|
||||
|
||||
List<MachinePart> getWholeSetDetails(StorageStatus storageStatus);
|
||||
|
||||
StorageStatus getHoldingLedgerUserNum(MachinePart wholeSetDetail);
|
||||
|
||||
String getMaSupplier(MachinePart wholeSetDetail);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
MachinePart machinePart = tmTaskMapper.getMachineParts(typeId);
|
||||
machinePart.setParentId(record.getId());
|
||||
int countMachineByPidAndTid = tmTaskMapper.getCountMachineByPidAndTid(machinePart);
|
||||
int machinePartNum = typeId.getPartNum() * (int) Double.parseDouble(backApplyInfo.getPreNum());
|
||||
Double machinePartNum = typeId.getPartNum() * Double.parseDouble(backApplyInfo.getPreNum());
|
||||
count1 += machinePartNum;
|
||||
count2 += countMachineByPidAndTid;
|
||||
machinePart.setPartNum(machinePartNum - countMachineByPidAndTid);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package com.bonus.sgzb.app.service.impl;
|
|||
|
||||
import com.bonus.sgzb.app.domain.MachinePart;
|
||||
import com.bonus.sgzb.app.domain.StorageStatus;
|
||||
import com.bonus.sgzb.app.domain.TmTask;
|
||||
import com.bonus.sgzb.app.mapper.HoldingLedgerMapper;
|
||||
import com.bonus.sgzb.app.service.HoldingLedgerService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -27,6 +27,21 @@ public class HoldingLedgerImpl implements HoldingLedgerService {
|
|||
if (holdingLedger.size() > 0) {
|
||||
for (StorageStatus bean : holdingLedger) {
|
||||
List<MachinePart> wholeSetDetails = holdingLedgerMapper.getWholeSetDetails(bean);
|
||||
for (MachinePart wholeSetDetail : wholeSetDetails) {
|
||||
//获取生产厂家
|
||||
String maSupplierInfo = holdingLedgerMapper.getMaSupplier(wholeSetDetail);
|
||||
if (StringUtils.isBlank(maSupplierInfo)) {
|
||||
wholeSetDetail.setSupplier(null);
|
||||
} else {
|
||||
wholeSetDetail.setSupplier(maSupplierInfo);
|
||||
}
|
||||
|
||||
//获取总保有量、在库数、在用数
|
||||
StorageStatus status = holdingLedgerMapper.getHoldingLedgerUserNum(wholeSetDetail);
|
||||
wholeSetDetail.setNum(status.getNum());
|
||||
wholeSetDetail.setUsNum(status.getUsNum());
|
||||
wholeSetDetail.setAllNum(status.getAllNum());
|
||||
}
|
||||
bean.setWholeSetDetails(wholeSetDetails);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,10 +214,8 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
typeIds.removeIf(item -> item == null);
|
||||
for (TmTask typeId : typeIds) {
|
||||
MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId);
|
||||
machinePart.setPartNum((int) (typeId.getPartNum() * record.getOutNum()));
|
||||
machinePart.setPartNum((typeId.getPartNum() * record.getOutNum()));
|
||||
typeId.setNum(machinePart.getNum() - machinePart.getPartNum());
|
||||
|
||||
|
||||
res = leaseOutDetailsMapper.updateMaTypeStockNumCt(typeId);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -291,7 +289,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
|
|||
typeIds.removeIf(item -> item == null);
|
||||
for (TmTask typeId : typeIds) {
|
||||
MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId);
|
||||
machinePart.setPartNum((int) (typeId.getPartNum() * record.getOutNum()));
|
||||
machinePart.setPartNum((typeId.getPartNum() * record.getOutNum()));
|
||||
if (machinePart.getNum() < machinePart.getPartNum()) {
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
typeIds.removeIf(item -> item == null);
|
||||
for (TmTask typeId : typeIds) {
|
||||
MachinePart machinePart = tmTaskMapper.getMachineParts(typeId);
|
||||
machinePart.setPartNum((int) (typeId.getPartNum() * leaseApplyDetail.getPreNum()));
|
||||
machinePart.setPartNum((typeId.getPartNum() * leaseApplyDetail.getPreNum()));
|
||||
machineParts.add(machinePart);
|
||||
}
|
||||
leaseApplyDetail.setMaTypeDetails(machineParts);
|
||||
|
|
@ -578,7 +578,7 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
|
||||
@Override
|
||||
public String selectTaskNumByMonths(Date nowDate, Integer taskType) {
|
||||
return tmTaskMapper.selectTaskNumByMonths(nowDate,taskType);
|
||||
return tmTaskMapper.selectTaskNumByMonths(nowDate, taskType);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,122 +5,121 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.bonus.sgzb.app.mapper.HoldingLedgerMapper">
|
||||
<select id="getHoldingLedger" resultType="com.bonus.sgzb.app.domain.StorageStatus">
|
||||
SELECT
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
mt.type_id AS typeId,
|
||||
IFNULL( mt.num, 0 ) AS num,
|
||||
IFNULL( subquery1.usNum, 0 ) AS usNum,
|
||||
IFNULL( subquery2.repairNum, 0 ) AS repairNum,
|
||||
IFNULL( subquery3.repairInputNum, 0 ) AS repairInputNum,
|
||||
IFNULL( subquery4.inputNum, 0 ) AS inputNum,
|
||||
IFNULL( mt.num, 0 ) + IFNULL( subquery1.usNum, 0 ) + IFNULL( subquery2.repairNum, 0 ) + IFNULL( subquery3.repairInputNum, 0 ) AS allNum,
|
||||
CASE
|
||||
mt.manage_type
|
||||
WHEN 0 THEN
|
||||
'否' ELSE '是'
|
||||
END manageType
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
mt.type_id AS typeId,
|
||||
IFNULL( mt.num, 0 ) AS num,
|
||||
IFNULL( subquery1.usNum, 0 ) AS usNum,
|
||||
IFNULL( subquery2.repairNum, 0 ) AS repairNum,
|
||||
IFNULL( subquery3.repairInputNum, 0 ) AS repairInputNum,
|
||||
IFNULL( subquery4.inputNum, 0 ) AS inputNum,
|
||||
IFNULL( mt.num, 0 ) + IFNULL( subquery1.usNum, 0 ) + IFNULL( subquery2.repairNum, 0 ) + IFNULL( subquery3.repairInputNum, 0 ) AS allNum,
|
||||
CASE
|
||||
mt.manage_type
|
||||
WHEN 0 THEN
|
||||
'否' ELSE '是'
|
||||
END manageType
|
||||
FROM
|
||||
ma_type mt
|
||||
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,
|
||||
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
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
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_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,
|
||||
mt2.type_name AS typeName,
|
||||
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
|
||||
IFNULL( rad.repair_num, 0 ) - IFNULL( rad.repaired_num, 0 ) - IFNULL( rad.scrap_num, 0 ) > 0
|
||||
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,
|
||||
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
|
||||
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,
|
||||
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
|
||||
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 ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
ma_type mt
|
||||
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,
|
||||
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
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
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_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,
|
||||
mt2.type_name AS typeName,
|
||||
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
|
||||
mt.`level` = 4
|
||||
AND mt.del_flag = '0'
|
||||
AND mt.manage_type = 2
|
||||
<if test="typeId != null and typeId != ''">
|
||||
and mt.type_id = #{typeId}
|
||||
</if>
|
||||
IFNULL( rad.repair_num, 0 ) - IFNULL( rad.repaired_num, 0 ) - IFNULL( rad.scrap_num, 0 ) > 0
|
||||
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,
|
||||
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
|
||||
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,
|
||||
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
|
||||
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 ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
WHERE
|
||||
mt.`level` = 4
|
||||
AND mt.del_flag = '0'
|
||||
AND mt.manage_type = 2
|
||||
<if test="typeId != null and typeId != ''">
|
||||
and mt.type_id = #{typeId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getWholeSetDetails" resultType="com.bonus.sgzb.app.domain.MachinePart">
|
||||
SELECT
|
||||
|
|
@ -143,4 +142,132 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt.type_id = #{typeId}
|
||||
) aa ON aa.type_id = mt2.type_id
|
||||
</select>
|
||||
<select id="getHoldingLedgerUserNum" resultType="com.bonus.sgzb.app.domain.StorageStatus">
|
||||
SELECT
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
mt.type_id AS typeId,
|
||||
IFNULL( mt.num, 0 ) AS num,
|
||||
IFNULL( subquery1.usNum, 0 ) AS usNum,
|
||||
IFNULL( subquery2.repairNum, 0 ) AS repairNum,
|
||||
IFNULL( subquery3.repairInputNum, 0 ) AS repairInputNum,
|
||||
IFNULL( subquery4.inputNum, 0 ) AS inputNum,
|
||||
IFNULL( mt.num, 0 ) + IFNULL( subquery1.usNum, 0 ) + IFNULL( subquery2.repairNum, 0 ) + IFNULL( subquery3.repairInputNum, 0 ) AS allNum,
|
||||
CASE
|
||||
mt.manage_type
|
||||
WHEN 0 THEN
|
||||
'否' ELSE '是'
|
||||
END manageType
|
||||
FROM
|
||||
ma_type mt
|
||||
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,
|
||||
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
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt.type_id,
|
||||
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_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,
|
||||
mt2.type_name AS typeName,
|
||||
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
|
||||
IFNULL( rad.repair_num, 0 ) - IFNULL( rad.repaired_num, 0 ) - IFNULL( rad.scrap_num, 0 ) > 0
|
||||
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,
|
||||
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
|
||||
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,
|
||||
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
|
||||
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 ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
WHERE
|
||||
mt.`level` = 4
|
||||
AND mt.del_flag = '0'
|
||||
AND mt.type_id = #{typeId}
|
||||
</select>
|
||||
<select id="getMaSupplier" resultType="java.lang.String">
|
||||
SELECT
|
||||
msi.supplier as supplier
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN purchase_check_details pcd ON mt.type_id = pcd.type_id
|
||||
LEFT JOIN ma_supplier_info msi ON pcd.supplier_id = msi.supplier_id
|
||||
WHERE
|
||||
mt.type_id = #{typeId}
|
||||
ORDER BY pcd.input_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -572,35 +572,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
<select id="getUseTypeTree" resultType="com.bonus.sgzb.material.domain.TypeTreeNode">
|
||||
WITH RECURSIVE type_hierarchy AS (-- 基础情况:从第四级开始
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt.type_name,
|
||||
mt.parent_id,
|
||||
mt.unit_name,
|
||||
mt.company_id,
|
||||
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num,
|
||||
mt.LEVEL
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
WHERE
|
||||
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.STATUS = '0' )
|
||||
GROUP BY
|
||||
mt.type_id UNION ALL-- 递归情况:向上查找父级
|
||||
SELECT
|
||||
mt.type_id,
|
||||
mt.type_name,
|
||||
mt.parent_id,
|
||||
mt.unit_name,
|
||||
mt.company_id,
|
||||
0 AS num,-- 父级没有直接关联的 num,可以设为0或NULL
|
||||
mt.LEVEL
|
||||
FROM
|
||||
ma_type mt
|
||||
INNER JOIN type_hierarchy th ON mt.type_id = th.parent_id
|
||||
) -- 查询结果,包括从第四级到第一级的所有元素
|
||||
SELECT
|
||||
mt.type_id AS typeId,
|
||||
mt.type_name AS typeName,
|
||||
mt.parent_id AS parentId,
|
||||
mt.unit_name AS unitNames,
|
||||
mt.company_id AS companyId,
|
||||
IFNULL(aa.num,0) as num,
|
||||
mt.`level`
|
||||
*
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN ( SELECT SUM(sai.num)as num,sai.type_id FROM slt_agreement_info sai WHERE sai.`status`='0'
|
||||
<if test="agreementId!=null and agreementId!=''">
|
||||
and sai.agreement_id =#{agreementId}
|
||||
</if>
|
||||
|
||||
GROUP BY sai.type_id) aa on aa.type_id=mt.type_id
|
||||
WHERE
|
||||
mt.del_flag = '0'
|
||||
<if test="level!=null and level!=''">
|
||||
<if test="level == 2">
|
||||
AND level IN ('1','2')
|
||||
</if>
|
||||
<if test="level == 3">
|
||||
AND level IN ('1','2','3')
|
||||
</if>
|
||||
<if test="level == 4">
|
||||
AND level IN ('1','2','3','4')
|
||||
</if>
|
||||
</if>
|
||||
type_hierarchy
|
||||
GROUP BY
|
||||
type_id
|
||||
ORDER BY
|
||||
LEVEL ASC;
|
||||
</select>
|
||||
|
||||
<select id="exportList" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
|
||||
|
|
|
|||
Loading…
Reference in New Issue