diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java index 7b33211..f771663 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java @@ -17,6 +17,7 @@ public class DeptEquipmentConfig extends BaseEntity { private String equipmentId; private List configs; private String configStatus; + private String jijuType; @Excel(name = "配置值") private String configValue; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/controller/ProjectController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/controller/ProjectController.java index 522d3f9..7e52574 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/controller/ProjectController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/controller/ProjectController.java @@ -1,16 +1,21 @@ package com.bonus.material.project.controller; +import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; import com.bonus.material.project.domain.Project; import com.bonus.material.project.domain.ProjectType; import com.bonus.material.project.service.ProjectService; +import com.bonus.material.supplier.domain.MaSupplier; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -108,5 +113,22 @@ public class ProjectController extends BaseController { return AjaxResult.success(projectTypes); } + /** + * 导出 + * @param response + * @param project + */ + @PostMapping("/export") + @SysLog(title = "项目管理", businessType = OperaType.EXPORT, logType = 0, module = "系统管理->项目管理", details = "导出项目信息") + public void export(HttpServletResponse response, Project project) { + try { + List list = projectService.selectProjectList(project); + ExcelUtil util = new ExcelUtil(Project.class); + util.exportExcel(response,list,"项目数据"); + } catch (Exception e) { + logger.error(e.toString(), e); + } + } + } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java index 5759078..29e35e5 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java @@ -1,5 +1,6 @@ package com.bonus.material.project.domain; +import com.bonus.common.core.annotation.Excel; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.models.auth.In; import lombok.Data; @@ -14,22 +15,32 @@ import java.util.Date; @Data public class Project { + + //用于excel导出的序号一列,不需要业务逻辑处理 + @Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT , sort = 0) + int sequence; + //工程id 主键 private Integer id; //工程编号 + @Excel(name = "项目编号", width = 25, sort = 2) private String pro_code; //工程名称 + @Excel(name = "项目名称", width = 25, sort = 1) private String pro_name; //电压等级 + @Excel(name = "电压等级", width = 25, sort = 4) private String voltage; //规模 + @Excel(name = "规模", width = 25, sort = 5) private String scale; //工程类型 + @Excel(name = "项目类型", width = 25, sort = 3) private String project_type; //工程类型名称 @@ -39,6 +50,7 @@ public class Project { private String org_name; //机械化率 + @Excel(name = "机械化率", width = 25, sort = 9) private String mechanize_rate; //开工时间 @@ -50,12 +62,15 @@ public class Project { private Date put_time; //省 + @Excel(name = "所在省", width = 25, sort = 6) private String province; //市 + @Excel(name = "所在市", width = 25, sort = 7) private String city; //县 + @Excel(name = "所在区/县", width = 25, sort = 8) private String county; //备注 diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml index 425fcc6..b39d269 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml @@ -76,16 +76,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ma_dev_info m2 LEFT JOIN ma_dev_qc m1 ON m1.ma_id = m2.ma_id - LEFT JOIN ma_type m3 ON m2.type_id = m3.type_id + INNER JOIN ma_type m3 ON m2.type_id = m3.type_id LEFT JOIN sys_user su ON su.user_id = m1.create_by LEFT JOIN ( SELECT count(*) as num, ma_id, MAX( qc_time ) AS max_qc_time FROM ma_dev_qc GROUP BY ma_id ) latest_qc ON m1.ma_id = latest_qc.ma_id LEFT JOIN ( SELECT ma_id, min( create_time ) AS create_time FROM ma_dev_qc GROUP BY ma_id ) aa ON m1.ma_id = aa.ma_id - LEFT JOIN jj_sing_project jsp ON m2.on_project = jsp.pro_code LEFT JOIN sys_dept sd ON sd.dept_id = m2.on_company - + LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on + m2.ma_id=mdq.ma_id LEFT JOIN ma_supplier ms ON ms.supplier_id = m2.supplier_id LEFT JOIN sys_cnarea sc ON sc.area_code = m2.province_id diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml index 9e39761..7b5a674 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml @@ -64,6 +64,7 @@ config_value, config_rate, config_description, + jiju_type, remark ) VALUES @@ -75,6 +76,7 @@ #{item.basicConfig}, #{item.configurationRate}, #{item.configurationDescription}, + #{jijuType}, #{remark} ) diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml index 9d8af43..d251963 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml @@ -99,16 +99,44 @@ mt.type_id AS equipmentId, mt2.type_name AS equipmentName, mt.type_name AS equipmenttype, + mt.jiju_type as jijuType, CASE - WHEN MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '' THEN '已配置' - ELSE '未配置' + + WHEN MAX( mdc.config_value ) IS NOT NULL + AND MAX( mdc.config_value ) != '' THEN + '已配置' ELSE '未配置' END AS configStatus - FROM ma_type mt + FROM + ma_type mt LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id - LEFT JOIN ma_dept_config mdc - ON mdc.type_id = mt.type_id + LEFT JOIN ma_dept_config mdc ON mdc.type_id = mt.type_id AND mdc.dept_id = #{deptId} - WHERE mt.level = 3 + WHERE + mt.LEVEL =5 + GROUP BY + mt.type_id, + mt2.type_name, + mt.type_name + UNION + + SELECT + mt.type_id AS equipmentId, + mt2.type_name AS equipmentName, + mt.type_name AS equipmenttype, + mt.jiju_type as jijuType, + CASE + + WHEN MAX( mdc.config_value ) IS NOT NULL + AND MAX( mdc.config_value ) != '' THEN + '已配置' ELSE '未配置' + END AS configStatus + FROM + tool_type mt + LEFT JOIN tool_type mt2 ON mt.parent_id = mt2.type_id + LEFT JOIN ma_dept_config mdc ON mdc.type_id = mt.type_id + AND mdc.dept_id = #{deptId} + WHERE + mt.LEVEL =4 AND mt.type_name LIKE CONCAT('%', #{equipmentName}, '%') @@ -159,6 +187,7 @@ SUM(config_value) AS config_value, SUM(if(config_rate='/',0,config_rate)) AS config_rate FROM ma_dept_config + where jiju_type =1 GROUP BY dept_id, type_id, config_type ) grouped LEFT JOIN sys_dept sd ON sd.dept_id = grouped.dept_id @@ -168,8 +197,8 @@ LEFT JOIN ( SELECT sd.dept_id AS dept_id, - mt2.type_id AS parent_type_id, - COUNT(md.ma_id) AS order_count + mt.type_id AS parent_type_id, + COUNT(md.num) AS order_count FROM ma_order_details md LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id @@ -177,10 +206,56 @@ LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id - GROUP BY sd.dept_id, mt2.type_id + where devType =0 + GROUP BY sd.dept_id, mt.type_id ) order_stat ON order_stat.dept_id = grouped.dept_id AND order_stat.parent_type_id = grouped.type_id + + UNION + + SELECT + my.type_name AS deptName, + my.type_id AS typeId, + sd.dept_name AS companyName, + grouped.dept_id AS companyId, + grouped.config_type AS configType, + grouped.config_value AS configValue, + if(grouped.config_rate='/',0,grouped.config_rate) AS configRate, + IFNULL(order_stat.order_count, 0) AS orderCount + FROM + ( + SELECT + dept_id, + type_id, + config_type, + SUM(config_value) AS config_value, + SUM(if(config_rate='/',0,config_rate)) AS config_rate + FROM ma_dept_config + where jiju_type =2 + GROUP BY dept_id, type_id, config_type + ) grouped + LEFT JOIN sys_dept sd ON sd.dept_id = grouped.dept_id + LEFT JOIN tool_type my ON my.type_id = grouped.type_id + + -- 设备订单数量子查询 + LEFT JOIN ( + SELECT + sd.dept_id AS dept_id, + mt.type_id AS parent_type_id, + COUNT(md.num) AS order_count + FROM + ma_order_details md + LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id + LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id + LEFT JOIN tool_type mt ON mdi.type_id = mt.type_id + LEFT JOIN tool_type mt2 ON mt.parent_id = mt2.type_id + LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id + where devType =1 + GROUP BY sd.dept_id, mt.type_id + ) order_stat + ON order_stat.dept_id = grouped.dept_id + AND order_stat.parent_type_id = grouped.type_id;