大屏接口修改

This commit is contained in:
cwchen 2023-12-23 23:17:12 +08:00
parent 272bce65c7
commit 5ae2f1679f
3 changed files with 78 additions and 158 deletions

View File

@ -11,7 +11,7 @@ public class CommonConstants {
public static final String SGJJ = "施工机具"; public static final String SGJJ = "施工机具";
/** 安全工器具*/ /** 安全工器具*/
public static final String AQGQJ = "安全工器具"; public static final String AQGQJ = "安全工器具";
/** 机具分公司*/ /** 机具设备分公司*/
public static final String JJ = "机具设备分公司"; public static final String JJ = "机具设备分公司";
/** 调试分公司*/ /** 调试分公司*/
public static final String TS = "调试分公司"; public static final String TS = "调试分公司";

View File

@ -30,7 +30,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
@Override @Override
public AjaxResult getMaterialReqData() { public AjaxResult getMaterialReqData() {
HashMap<Object, Object> map = new HashMap<>(2); HashMap<Object, Object> map = new HashMap<>(2);
// 施工安全工器具数量 // 施工安全工器具数量
int num = 0, num2 = 0; int num = 0, num2 = 0;
try { try {
List<MaTypeDo> list = mapper.getMaterialReqData(DateTimeHelper.getNowDate()); List<MaTypeDo> list = mapper.getMaterialReqData(DateTimeHelper.getNowDate());
@ -48,7 +48,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
@Override @Override
public AjaxResult getMaterialReturnData() { public AjaxResult getMaterialReturnData() {
HashMap<Object, Object> map = new HashMap<>(2); HashMap<Object, Object> map = new HashMap<>(2);
// 施工安全工器具数量 // 施工安全工器具数量
int num = 0, num2 = 0; int num = 0, num2 = 0;
try { try {
List<MaTypeDo> list = mapper.getMaterialReturnData(DateTimeHelper.getNowDate()); List<MaTypeDo> list = mapper.getMaterialReturnData(DateTimeHelper.getNowDate());
@ -80,9 +80,9 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
ParamsDto dto = new ParamsDto(); ParamsDto dto = new ParamsDto();
try { try {
// 施工机具 // 施工机具
TotalOwnershipVo vo = countNum("1", CommonConstants.SGJJ); TotalOwnershipVo vo = countNum("1", CommonConstants.JJ);
// 安全工器具 // 安全工器具
TotalOwnershipVo vo2 = countNum("2", CommonConstants.AQGQJ); TotalOwnershipVo vo2 = countNum("2", CommonConstants.TS);
list.add(vo); list.add(vo);
list.add(vo2); list.add(vo2);
} catch (Exception e) { } catch (Exception e) {
@ -146,7 +146,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
HashMap<Object, Object> map = new HashMap<>(3); HashMap<Object, Object> map = new HashMap<>(3);
try { try {
dto.setType("1"); dto.setType("1");
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null); dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.JJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.TS : null);
List<MaterialDataVo> lyList = mapper.getScrapAnalysisByMonth(dto); List<MaterialDataVo> lyList = mapper.getScrapAnalysisByMonth(dto);
dto.setType("2"); dto.setType("2");
List<MaterialDataVo> bfList = mapper.getScrapAnalysisByMonth(dto); List<MaterialDataVo> bfList = mapper.getScrapAnalysisByMonth(dto);
@ -169,7 +169,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
List<String> yearMonthList = DateTimeHelper.getYearMonth(); List<String> yearMonthList = DateTimeHelper.getYearMonth();
List<Integer> valueList = new ArrayList<>(); List<Integer> valueList = new ArrayList<>();
List<Integer> valueList2 = new ArrayList<>(); List<Integer> valueList2 = new ArrayList<>();
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null); dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.JJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.TS : null);
try { try {
for (String date : yearMonthList) { for (String date : yearMonthList) {
String year = date.substring(0, 4); String year = date.substring(0, 4);
@ -208,7 +208,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
int num = 0, num2 = 0; int num = 0, num2 = 0;
String rate = "0%", rate2 = "0%"; String rate = "0%", rate2 = "0%";
try { try {
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null); dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.JJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.TS : null);
dto.setStartDate(monthDayMap.get("beginDate")); dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate")); dto.setEndDate(monthDayMap.get("endDate"));
List<MaTypeDo> list = mapper.getPickingAnalysisByMonth(dto); List<MaTypeDo> list = mapper.getPickingAnalysisByMonth(dto);
@ -235,7 +235,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay(); Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay();
dto.setStartDate(monthDayMap.get("beginDate")); dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate")); dto.setEndDate(monthDayMap.get("endDate"));
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null); dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.JJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.TS : null);
try { try {
List<ScrapAnalysisVo> list = mapper.getMaterialReturnByMonth(dto); List<ScrapAnalysisVo> list = mapper.getMaterialReturnByMonth(dto);
List<Integer> valueList = commonUtil.setMaterialReturnData(list); List<Integer> valueList = commonUtil.setMaterialReturnData(list);
@ -259,7 +259,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay(); Map<String, String> monthDayMap = DateTimeHelper.getNowOneMonthDay();
dto.setStartDate(monthDayMap.get("beginDate")); dto.setStartDate(monthDayMap.get("beginDate"));
dto.setEndDate(monthDayMap.get("endDate")); dto.setEndDate(monthDayMap.get("endDate"));
dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.SGJJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.AQGQJ : null); dto.setMaTypeName(Objects.equals("1", dto.getMaType()) ? CommonConstants.JJ : Objects.equals("2", dto.getMaType()) ? CommonConstants.TS : null);
try { try {
List<ScrapAnalysisVo> list = mapper.getMaintenanceByMonth(dto); List<ScrapAnalysisVo> list = mapper.getMaintenanceByMonth(dto);
List<Integer> valueList = commonUtil.setMaintenanceData(list); List<Integer> valueList = commonUtil.setMaintenanceData(list);

View File

@ -27,23 +27,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--当月领料分析--> <!--当月领料分析-->
<select id="getPickingAnalysisByMonth" resultType="com.bonus.sgzb.largeScreen.domain.MaTypeDo"> <select id="getPickingAnalysisByMonth" resultType="com.bonus.sgzb.largeScreen.domain.MaTypeDo">
SELECT lod.out_num AS num, SELECT lod.out_num AS num,
a.typeName, mt.type_name AS typeName,
a.manage_type AS manageType mt.manage_type AS manageType
FROM lease_out_details lod FROM lease_out_details lod
LEFT JOIN ( LEFT JOIN ma_type mt ON lod.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName,mt.manage_type LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON lod.type_id = a.type_id
WHERE lod.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') WHERE lod.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</select> </select>
<!--设备分布--> <!--设备分布-->
@ -53,44 +47,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
/*验收*/ /*验收*/
<if test="type == 1"> <if test="type == 1">
SELECT pcd.check_num AS num, SELECT pcd.check_num AS num,
a.typeName mt.type_name AS typeName
FROM purchase_check_info pci FROM purchase_check_info pci
LEFT JOIN purchase_check_details pcd ON pci.task_id = pcd.task_id LEFT JOIN purchase_check_details pcd ON pci.task_id = pcd.task_id
LEFT JOIN ( LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON pcd.type_id = a.type_id
WHERE pci.arrival_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') WHERE pci.arrival_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</if> </if>
/*入库*/ /*入库*/
<if test="type == 2"> <if test="type == 2">
SELECT iad.input_num, SELECT iad.input_num,
a.typeName mt.type_name AS typeName
FROM input_apply_details iad FROM input_apply_details iad
LEFT JOIN ( LEFT JOIN ma_type mt ON iad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON iad.type_id = a.type_id
WHERE iad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') AND iad.input_type = '1' WHERE iad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') AND iad.input_type = '1'
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</if> </if>
</select> </select>
@ -101,24 +83,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT SUM(lod.out_num) AS num, SELECT SUM(lod.out_num) AS num,
bui.unit_name AS unitName bui.unit_name AS unitName
FROM lease_out_details lod FROM lease_out_details lod
LEFT JOIN ( LEFT JOIN ma_type mt ON lod.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON lod.type_id = a.type_id
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
<where> <where>
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
a.typeName = #{maTypeName} sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</where> </where>
GROUP BY bai.unit_id GROUP BY bai.unit_id
@ -129,23 +105,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT SUM(scrap_num) AS num, SELECT SUM(scrap_num) AS num,
bui.unit_name AS unitName bui.unit_name AS unitName
FROM scrap_apply_details sad FROM scrap_apply_details sad
LEFT JOIN ( LEFT JOIN ma_type mt ON sad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON sad.type_id = a.type_id
LEFT JOIN tm_task_agreement tta ON sad.task_id = tta.task_id LEFT JOIN tm_task_agreement tta ON sad.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
WHERE sad.status = '1' WHERE sad.status = '1'
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
GROUP BY bai.unit_id GROUP BY bai.unit_id
ORDER BY num DESC ORDER BY num DESC
@ -155,22 +125,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getMaterialReturnByMonth" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo"> <select id="getMaterialReturnByMonth" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo">
SELECT bad.pre_num AS planNum, SELECT bad.pre_num AS planNum,
bad.audit_num AS realityNum, bad.audit_num AS realityNum,
a.typeName mt.type_name AS typeName
FROM back_apply_details bad FROM back_apply_details bad
LEFT JOIN ( LEFT JOIN ma_type mt ON bad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON bad.type_id = a.type_id
WHERE bad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') WHERE bad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</select> </select>
<!--当月维修分析--> <!--当月维修分析-->
@ -178,82 +142,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT rad.repair_num AS repairNum, SELECT rad.repair_num AS repairNum,
rad.repaired_num AS repairedNum, rad.repaired_num AS repairedNum,
rad.scrap_num AS scrapNum, rad.scrap_num AS scrapNum,
a.typeName mt.type_name AS typeName
FROM repair_apply_details rad FROM repair_apply_details rad
LEFT JOIN ( LEFT JOIN ma_type mt ON rad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON rad.type_id = a.type_id
WHERE rad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59') WHERE rad.create_time BETWEEN CONCAT(#{startDate}, ' 00:00:00') AND CONCAT(#{endDate}, ' 23:59:59')
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</select> </select>
<!--施工机具/工器具总保有量--> <!--施工机具/工器具总保有量-->
<select id="getTotalOwnership" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo"> <select id="getTotalOwnership" resultType="com.bonus.sgzb.largeScreen.domain.ScrapAnalysisVo">
/*在库*/ /*在库*/
<if test="type == 1"> <if test="type == 1">
SELECT mt4.type_name AS typeName, SELECT mt.type_name AS typeName,
mt.num AS num mt.num AS num
FROM ma_type mt FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3' LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4' AND mt.del_flag = '0' WHERE mt.`level` = '4' AND mt.del_flag = '0'
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND mt4.type_name = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND mt4.type_name = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</if> </if>
/*待入库 新购/修试*/ /*待入库 新购/修试*/
<if test="type == 2"> <if test="type == 2">
SELECT pcd.purchase_num AS num, SELECT pcd.purchase_num AS num,
pcd.input_num AS num2, pcd.input_num AS num2,
a.typeName AS typeName mt.type_name AS typeName
FROM purchase_check_details pcd FROM purchase_check_details pcd
LEFT JOIN ( LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON pcd.type_id = a.type_id
WHERE pcd.status = '1' WHERE pcd.status = '1'
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
UNION ALL UNION ALL
SELECT rid.repair_num AS num, SELECT rid.repair_num AS num,
rid.input_num AS num2, rid.input_num AS num2,
a.typeName AS typeName mt.type_name AS typeName
FROM repair_input_details rid FROM repair_input_details rid
LEFT JOIN ( LEFT JOIN ma_type mt ON rid.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON rid.type_id = a.type_id
<where> <where>
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
a.typeName = #{maTypeName} sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</where> </where>
</if> </if>
@ -261,43 +205,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type == 3"> <if test="type == 3">
SELECT lod.out_num AS num, SELECT lod.out_num AS num,
'1' AS type, '1' AS type,
a.typeName AS typeName mt.type_name AS typeName
FROM lease_out_details lod FROM lease_out_details lod
LEFT JOIN ( LEFT JOIN ma_type mt ON lod.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON lod.type_id = a.type_id
<where> <where>
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
a.typeName = #{maTypeName} sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</where> </where>
UNION ALL UNION ALL
SELECT bad.audit_num AS num, SELECT bad.audit_num AS num,
'2' AS type, '2' AS type,
a.typeName AS typeName mt.type_name AS typeName
FROM back_apply_details bad FROM back_apply_details bad
LEFT JOIN ( LEFT JOIN ma_type mt ON bad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON bad.type_id = a.type_id
<where> <where>
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
a.typeName = #{maTypeName} sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</where> </where>
</if> </if>
@ -306,44 +238,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT rad.repair_num AS repairNum, SELECT rad.repair_num AS repairNum,
rad.repaired_num AS repairedNum, rad.repaired_num AS repairedNum,
rad.scrap_num AS scrapNum, rad.scrap_num AS scrapNum,
a.typeName AS typeName mt.type_name AS typeName
FROM repair_apply_details rad FROM repair_apply_details rad
LEFT JOIN ( LEFT JOIN ma_type mt ON rad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON rad.type_id = a.type_id
<where> <where>
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
a.typeName = #{maTypeName} sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</where> </where>
</if> </if>
/*报废*/ /*报废*/
<if test="type == 5"> <if test="type == 5">
SELECT sad.scrap_num AS num, SELECT sad.scrap_num AS num,
a.typeName AS typeName mt.type_name AS typeName
FROM scrap_apply_details sad FROM scrap_apply_details sad
LEFT JOIN ( LEFT JOIN ma_type mt ON sad.type_id = mt.type_id AND mt.`level` = '4'
SELECT mt.type_id,mt4.type_name AS typeName LEFT JOIN sys_dept sd ON sd.dept_id = mt.company_id
FROM ma_type mt
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id AND mt2.`level` = '3'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.`level` = '2'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.`level` = '1'
WHERE mt.`level` = '4'
)a ON sad.type_id = a.type_id
WHERE sad.status = '1' WHERE sad.status = '1'
<if test="maType!=null and maType == 1"> <if test="maType!=null and maType == 1">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
<if test="maType!=null and maType == 2"> <if test="maType!=null and maType == 2">
AND a.typeName = #{maTypeName} AND sd.dept_name = #{maTypeName}
</if> </if>
</if> </if>
</select> </select>