后台-退料申请与审核
This commit is contained in:
parent
2a4b8420f6
commit
5275483a0e
|
|
@ -38,6 +38,12 @@ public class BackApplyController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "在用设备类型树")
|
||||||
|
@PostMapping("/getUseTypeTree")
|
||||||
|
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean){
|
||||||
|
return backApplyService.getUseTypeTree(bean);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取在用物料列表
|
* 获取在用物料列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -161,4 +161,7 @@ public class BackApplyInfo extends BaseEntity {
|
||||||
@ApiModelProperty(value = "结束时间")
|
@ApiModelProperty(value = "结束时间")
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "等级")
|
||||||
|
private String level;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.sgzb.material.mapper;
|
||||||
|
|
||||||
import com.bonus.sgzb.material.domain.AgreementInfo;
|
import com.bonus.sgzb.material.domain.AgreementInfo;
|
||||||
import com.bonus.sgzb.material.domain.BackApplyInfo;
|
import com.bonus.sgzb.material.domain.BackApplyInfo;
|
||||||
|
import com.bonus.sgzb.material.domain.TypeTreeNode;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
@ -41,4 +42,6 @@ public interface BackApplyMapper {
|
||||||
int del(BackApplyInfo bean);
|
int del(BackApplyInfo bean);
|
||||||
|
|
||||||
int audit(BackApplyInfo bean);
|
int audit(BackApplyInfo bean);
|
||||||
|
|
||||||
|
List<TypeTreeNode> getUseTypeTree(BackApplyInfo bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,6 @@ public interface BackApplyService {
|
||||||
AjaxResult del(BackApplyInfo bean);
|
AjaxResult del(BackApplyInfo bean);
|
||||||
|
|
||||||
AjaxResult audit(BackApplyInfo record);
|
AjaxResult audit(BackApplyInfo record);
|
||||||
|
|
||||||
|
AjaxResult getUseTypeTree(BackApplyInfo bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@ import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.material.domain.BackApplyInfo;
|
import com.bonus.sgzb.material.domain.BackApplyInfo;
|
||||||
|
import com.bonus.sgzb.material.domain.TypeTreeNode;
|
||||||
import com.bonus.sgzb.material.mapper.BackApplyMapper;
|
import com.bonus.sgzb.material.mapper.BackApplyMapper;
|
||||||
import com.bonus.sgzb.material.service.BackApplyService;
|
import com.bonus.sgzb.material.service.BackApplyService;
|
||||||
|
import com.bonus.sgzb.material.vo.TypeTreeBuild;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -122,4 +126,22 @@ public class BackApplyServiceImpl implements BackApplyService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult getUseTypeTree(BackApplyInfo bean) {
|
||||||
|
List<TypeTreeNode> groupList = new ArrayList<>();
|
||||||
|
List<TypeTreeNode> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
list = backApplyMapper.getUseTypeTree(bean);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
// 创建树形结构(数据集合作为参数)
|
||||||
|
TypeTreeBuild treeBuild = new TypeTreeBuild(list);
|
||||||
|
// 原查询结果转换树形结构
|
||||||
|
groupList = treeBuild.buildTree();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
AjaxResult.error("类型树-查询失败", e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(groupList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -485,5 +485,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||||
) AS result2 ON result1.typeId = result2.typeId
|
) AS result2 ON result1.typeId = result2.typeId
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getUseTypeTree" resultType="com.bonus.sgzb.material.domain.TypeTreeNode">
|
||||||
|
WITH RECURSIVE cte AS (
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt.parent_id,
|
||||||
|
mt.type_name,
|
||||||
|
mt.`level`,
|
||||||
|
mt4.num
|
||||||
|
FROM
|
||||||
|
ma_type mt
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
subquery1.type_id AS typeId,
|
||||||
|
subquery1.parent_id ,
|
||||||
|
subquery1.typeName typeCode,
|
||||||
|
subquery1.out_num - COALESCE ( subquery2.audit_num, 0 ) AS num
|
||||||
|
FROM
|
||||||
|
(-- 第一个查询作为子查询
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt.parent_id,
|
||||||
|
mt.type_name AS typeName,
|
||||||
|
SUM( lod.out_num ) AS out_num
|
||||||
|
FROM
|
||||||
|
lease_apply_info lai
|
||||||
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
||||||
|
LEFT JOIN lease_out_details lod ON lod.parent_id = lai.id
|
||||||
|
LEFT JOIN tm_task tt ON tt.task_id = tta.task_id
|
||||||
|
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
|
||||||
|
WHERE
|
||||||
|
tta.agreement_id = #{agreementId}
|
||||||
|
AND tt.task_type = '29'
|
||||||
|
AND mt.`level` = '4'
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id
|
||||||
|
) AS subquery1
|
||||||
|
LEFT JOIN (-- 第二个查询作为子查询
|
||||||
|
SELECT
|
||||||
|
mt.type_id,
|
||||||
|
mt.parent_id,
|
||||||
|
mt.type_name,
|
||||||
|
SUM( bad.audit_num ) AS audit_num
|
||||||
|
FROM
|
||||||
|
back_apply_info bai
|
||||||
|
LEFT JOIN tm_task tt ON tt.task_id = bai.task_id
|
||||||
|
LEFT JOIN back_apply_details bad ON bad.parent_id = bai.id
|
||||||
|
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = bad.type_id
|
||||||
|
WHERE
|
||||||
|
tta.agreement_id = #{agreementId}
|
||||||
|
AND tt.task_type = '36'
|
||||||
|
AND mt.`level` = '4'
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id
|
||||||
|
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||||
|
WHERE
|
||||||
|
subquery1.out_num - COALESCE ( subquery2.audit_num, 0 )> 0) mt4 on mt4.typeId = mt.type_id
|
||||||
|
HAVING num> 0
|
||||||
|
UNION ALL
|
||||||
|
SELECT ma_type.type_id, ma_type.parent_id,ma_type.type_name as typeCode, ma_type.`level`,0 as num
|
||||||
|
FROM ma_type
|
||||||
|
JOIN cte ON ma_type.type_id = cte.parent_id
|
||||||
|
)
|
||||||
|
SELECT type_id as typeId, parent_id as parentId,type_name as typeName,num,`level`
|
||||||
|
FROM cte
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
<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>
|
||||||
|
GROUP BY type_id
|
||||||
|
ORDER BY type_id;
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue