From 90f563ff5d3b0462e8013f4621148fffabec2d9f Mon Sep 17 00:00:00 2001
From: lius <Lius2225@163.com>
Date: 星期二, 18 七月 2023 14:30:17 +0800
Subject: [PATCH] 合格率

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java                  |  107 ++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java |  196 +++++++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java              |    1 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java         |   55 +++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml         |   27 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java    |  166 ++++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java            |   26 ++
 7 files changed, 578 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java
new file mode 100644
index 0000000..06775cc
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java
@@ -0,0 +1,166 @@
+package org.jeecg.modules.mdc.controller;
+
+import java.util.Arrays;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.entity.MdcPassRate;
+import org.jeecg.modules.mdc.service.IMdcPassRateService;
+
+
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * @Description: 鍚堟牸鐜�
+ * @Author: lius
+ * @Date: 2023-07-18
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags = "鍚堟牸鐜�")
+@RestController
+@RequestMapping("/mdc/mdcPassRate")
+public class MdcPassRateController extends JeecgController<MdcPassRate, IMdcPassRateService> {
+
+    @Resource
+    private IMdcPassRateService mdcPassRateService;
+
+    /**
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     *
+     * @param mdcPassRate
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-鍒嗛〉鍒楄〃鏌ヨ")
+    @ApiOperation(value = "鍚堟牸鐜�-鍒嗛〉鍒楄〃鏌ヨ", notes = "鍚堟牸鐜�-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/list")
+    public Result<?> queryPageList(MdcPassRate mdcPassRate,
+                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                   HttpServletRequest req) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
+        Page<MdcPassRate> page = new Page<MdcPassRate>(pageNo, pageSize);
+        IPage<MdcPassRate> pageList = mdcPassRateService.pageList(userId, page, mdcPassRate, req);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 娣诲姞
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-娣诲姞")
+    @ApiOperation(value = "鍚堟牸鐜�-娣诲姞", notes = "鍚堟牸鐜�-娣诲姞")
+    @PostMapping(value = "/add")
+    public Result<?> add(@RequestBody MdcPassRate mdcPassRate) {
+        if (StringUtils.isBlank(mdcPassRate.getEquipmentIds())) {
+            return Result.error("鏈�夋嫨璁惧锛岃鎺掓煡锛�");
+        }
+        boolean result = mdcPassRateService.addPassRate(mdcPassRate);
+        return result ? Result.ok("娣诲姞鎴愬姛!") : Result.error("娣诲姞澶辫触!");
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-缂栬緫")
+    @ApiOperation(value = "鍚堟牸鐜�-缂栬緫", notes = "鍚堟牸鐜�-缂栬緫")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<?> edit(@RequestBody MdcPassRate mdcPassRate) {
+        boolean result = mdcPassRateService.updatePassRate(mdcPassRate);
+        return result ? Result.ok("缂栬緫鎴愬姛!") : Result.error("缂栬緫澶辫触!");
+    }
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-閫氳繃id鍒犻櫎")
+    @ApiOperation(value = "鍚堟牸鐜�-閫氳繃id鍒犻櫎", notes = "鍚堟牸鐜�-閫氳繃id鍒犻櫎")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        mdcPassRateService.removeById(id);
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-鎵归噺鍒犻櫎")
+    @ApiOperation(value = "鍚堟牸鐜�-鎵归噺鍒犻櫎", notes = "鍚堟牸鐜�-鎵归噺鍒犻櫎")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.mdcPassRateService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�");
+    }
+
+    /**
+     * 閫氳繃id鏌ヨ
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "鍚堟牸鐜�-閫氳繃id鏌ヨ")
+    @ApiOperation(value = "鍚堟牸鐜�-閫氳繃id鏌ヨ", notes = "鍚堟牸鐜�-閫氳繃id鏌ヨ")
+    @GetMapping(value = "/queryById")
+    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
+        MdcPassRate mdcPassRate = mdcPassRateService.getById(id);
+        return Result.OK(mdcPassRate);
+    }
+
+    /**
+     * 瀵煎嚭excel
+     *
+     * @param request
+     * @param mdcPassRate
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, MdcPassRate mdcPassRate) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
+        return mdcPassRateService.exportXls(userId, mdcPassRate);
+    }
+
+    /**
+     * 閫氳繃excel瀵煎叆鏁版嵁
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, MdcPassRate.class);
+    }
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java
new file mode 100644
index 0000000..3fff2ff
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java
@@ -0,0 +1,107 @@
+package org.jeecg.modules.mdc.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.jeecg.common.system.base.entity.JeecgEntity;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * @Description: 鍚堟牸鐜囪〃
+ * @Author: lius
+ * @Date: 2023-07-18
+ * @Version: V1.0
+ */
+@Data
+@TableName("mdc_pass_rate")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "mdc_pass_rate瀵硅薄", description = "鍚堟牸鐜囪〃")
+public class MdcPassRate extends JeecgEntity implements Serializable {
+
+    private static final long serialVersionUID = 1863479534937744521L;
+
+    /**
+     * 璁惧缂栧彿
+     */
+    @Excel(name = "璁惧缂栧彿", width = 15)
+    @ApiModelProperty(value = "璁惧缂栧彿")
+    private String equipmentId;
+    /**
+     * 璁惧鍚嶇О
+     */
+    @Excel(name = "璁惧鍚嶇О", width = 15)
+    @ApiModelProperty(value = "璁惧鍚嶇О")
+    private String equipmentName;
+    /**
+     * 鏃ユ湡
+     */
+    @Excel(name = "鏃ユ湡", width = 20, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "鏃ユ湡")
+    private Date efficientDate;
+    /**
+     * 鍔犲伐鏁伴噺
+     */
+    @Excel(name = "鍔犲伐鏁伴噺", width = 15)
+    @ApiModelProperty(value = "鍔犲伐鏁伴噺")
+    private Integer processQuantity;
+    /**
+     * 涓嶅悎鏍兼暟閲�
+     */
+    @Excel(name = "涓嶅悎鏍兼暟閲�", width = 15)
+    @ApiModelProperty(value = "涓嶅悎鏍兼暟閲�")
+    private Integer unqualifiedQuantity;
+    /**
+     * 鍚堟牸鐜�
+     */
+    @Excel(name = "鍚堟牸鐜�", width = 15)
+    @ApiModelProperty(value = "鍚堟牸鐜�")
+    private BigDecimal passRate;
+    /**
+     * 澶囨敞
+     */
+    @Excel(name = "澶囨敞", width = 15)
+    @ApiModelProperty(value = "澶囨敞")
+    private String remark;
+
+    /**
+     * 鍓嶅彴浼犲叆 鍒ゆ柇姣忎釜id
+     */
+    @TableField(exist = false)
+    private String parentId;
+
+    /**
+     * 鍓嶅彴浼犲叆 杞﹂棿灞傜骇:1 閮ㄩ棬灞傜骇:2
+     */
+    @TableField(exist = false)
+    private String typeTree;
+
+    /**
+     * 閮ㄩ棬parentId 鍏宠仈瀛愰泦id
+     */
+    @TableField(exist = false)
+    private List<String> mdcSectionIds;
+
+    @TableField(exist = false)
+    private String equipmentIds;
+
+    @TableField(exist = false)
+    private String startTime;
+
+    @TableField(exist = false)
+    private String endTime;
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java
index 1346b7a..bdea1c6 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java
@@ -29,6 +29,7 @@
 @TableName("mdc_torque_config")
 @ApiModel(value = "mdc_torque_config瀵硅薄", description = "鎵煩閰嶇疆绠$悊")
 public class MdcTorqueConfig implements Serializable {
+
     private static final long serialVersionUID = -8646261637017242975L;
 
     /**
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java
new file mode 100644
index 0000000..0db11a4
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java
@@ -0,0 +1,26 @@
+package org.jeecg.modules.mdc.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.mdc.entity.MdcPassRate;
+
+/**
+ * @Description: 鍚堟牸鐜囪〃
+ * @Author: lius
+ * @Date: 2023-07-18
+ * @Version: V1.0
+ */
+public interface MdcPassRateMapper extends BaseMapper<MdcPassRate> {
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     *
+     * @param page
+     * @param mdcPassRate
+     * @return
+     */
+    IPage<MdcPassRate> pageList(Page<MdcPassRate> page, @Param("mdcPassRate") MdcPassRate mdcPassRate);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml
new file mode 100644
index 0000000..3480f62
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.mdc.mapper.MdcPassRateMapper">
+
+    <!--鍒嗛〉鏌ヨ-->
+    <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcPassRate">
+        SELECT * FROM mdc_pass_date
+        <where>
+            <if test="mdcPassRate.equipmentName != null and mdcPassRate.equipmentName != '' ">
+                AND equipment_name LIKE CONCAT(CONCAT('%',#{mdcPassRate.equipmentName}),'%')
+            </if>
+            <if test="mdcPassRate.equipmentId != null and mdcPassRate.equipmentId != '' ">
+                AND equipment_id LIKE CONCAT(CONCAT('%',#{mdcPassRate.equipmentId}),'%')
+            </if>
+            <if test="mdcPassRate.startTime != null and mdcPassRate.endTime != null">
+                AND efficient_date BETWEEN #{ mdcPassRate.startTime } AND #{ mdcPassRate.endTime }
+            </if>
+            <if test="mdcPassRate.mdcSectionIds != null and mdcPassRate.mdcSectionIds.size() > 0 ">
+                AND equipment_id IN
+                <foreach collection="mdcPassRate.mdcSectionIds" item="id" index="index" open="(" close=")" separator=",">
+                    #{ id }
+                </foreach>
+            </if>
+        </where>
+        ORDER BY equipment_name ASC, efficient_date DESC
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java
new file mode 100644
index 0000000..334a27b
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java
@@ -0,0 +1,55 @@
+package org.jeecg.modules.mdc.service;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.mdc.entity.MdcPassRate;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @Description: 鍚堟牸鐜囪〃
+ * @Author: lius
+ * @Date: 2023-07-18
+ * @Version: V1.0
+ */
+public interface IMdcPassRateService extends IService<MdcPassRate> {
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     *
+     * @param userId
+     * @param page
+     * @param mdcPassRate
+     * @param req
+     * @return
+     */
+    IPage<MdcPassRate> pageList(String userId, Page<MdcPassRate> page, MdcPassRate mdcPassRate, HttpServletRequest req);
+
+    /**
+     * 娣诲姞鏁版嵁
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    boolean addPassRate(MdcPassRate mdcPassRate);
+
+    /**
+     * 缂栬緫鏁版嵁
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    boolean updatePassRate(MdcPassRate mdcPassRate);
+
+    /**
+     * 瀵煎嚭
+     *
+     * @param userId
+     * @param mdcPassRate
+     * @return
+     */
+    ModelAndView exportXls(String userId, MdcPassRate mdcPassRate);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java
new file mode 100644
index 0000000..5e34d15
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java
@@ -0,0 +1,196 @@
+package org.jeecg.modules.mdc.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.entity.MdcEquipment;
+import org.jeecg.modules.mdc.entity.MdcPassRate;
+import org.jeecg.modules.mdc.entity.MdcStandardProcessDuration;
+import org.jeecg.modules.mdc.mapper.MdcPassRateMapper;
+import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcPassRateService;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * @Description: 鍚堟牸鐜囪〃
+ * @Author: lius
+ * @Date: 2023-07-18
+ * @Version: V1.0
+ */
+@Service
+public class MdcPassRateServiceImpl extends ServiceImpl<MdcPassRateMapper, MdcPassRate> implements IMdcPassRateService {
+
+    @Resource
+    private IMdcEquipmentService mdcEquipmentService;
+
+    @Override
+    public IPage<MdcPassRate> pageList(String userId, Page<MdcPassRate> page, MdcPassRate mdcPassRate, HttpServletRequest req) {
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(mdcPassRate.getParentId()) && StringUtils.isEmpty(mdcPassRate.getEquipmentId())) {
+            if ("2".equals(mdcPassRate.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPassRate.getParentId());
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPassRate.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) {
+            //鍗曞彴璁惧淇℃伅
+            mdcPassRate.setMdcSectionIds(Collections.singletonList(mdcPassRate.getEquipmentId()));
+        } else {
+            //鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(mdcPassRate.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+
+        if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) {
+            mdcPassRate.setMdcSectionIds(equipmentIds);
+        }
+
+        if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) {
+            return null;
+        }
+
+        return this.baseMapper.pageList(page, mdcPassRate);
+    }
+
+    /**
+     * 娣诲姞鏁版嵁
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    @Override
+    public boolean addPassRate(MdcPassRate mdcPassRate) {
+        boolean result = false;
+        String[] equipmentIds = mdcPassRate.getEquipmentIds().split(",");
+        for (String equipmentId : equipmentIds) {
+            MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId);
+            MdcPassRate passRate = new MdcPassRate();
+            BeanUtils.copyProperties(mdcPassRate, passRate);
+            passRate.setEquipmentId(mdcEquipment.getEquipmentId());
+            passRate.setEquipmentName(mdcEquipment.getEquipmentName());
+            if (passRate.getProcessQuantity() == null || passRate.getProcessQuantity() == 0) {
+                passRate.setPassRate(new BigDecimal("0"));
+            } else {
+                if (passRate.getUnqualifiedQuantity() == null || passRate.getUnqualifiedQuantity() == 0) {
+                    passRate.setPassRate(new BigDecimal("1"));
+                } else {
+                    passRate.setPassRate(new BigDecimal(passRate.getUnqualifiedQuantity()).divide(new BigDecimal(passRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP));
+                }
+            }
+            boolean b = super.save(passRate);
+            if (b) {
+                result = true;
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 缂栬緫鏁版嵁
+     *
+     * @param mdcPassRate
+     * @return
+     */
+    @Override
+    public boolean updatePassRate(MdcPassRate mdcPassRate) {
+        if (mdcPassRate.getProcessQuantity() == null || mdcPassRate.getProcessQuantity() == 0) {
+            mdcPassRate.setPassRate(new BigDecimal("0"));
+        } else {
+            if (mdcPassRate.getUnqualifiedQuantity() == null || mdcPassRate.getUnqualifiedQuantity() == 0) {
+                mdcPassRate.setPassRate(new BigDecimal("1"));
+            } else {
+                mdcPassRate.setPassRate(new BigDecimal(mdcPassRate.getUnqualifiedQuantity()).divide(new BigDecimal(mdcPassRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP));
+            }
+        }
+        return super.updateById(mdcPassRate);
+    }
+
+    /**
+     * 瀵煎嚭
+     *
+     * @param userId
+     * @param mdcPassRate
+     * @return
+     */
+    @Override
+    public ModelAndView exportXls(String userId, MdcPassRate mdcPassRate) {
+        LambdaQueryWrapper<MdcPassRate> queryWrapper = new LambdaQueryWrapper<>();
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(mdcPassRate.getParentId()) && StringUtils.isEmpty(mdcPassRate.getEquipmentId())) {
+            if ("2".equals(mdcPassRate.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPassRate.getParentId());
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPassRate.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) {
+            //鍗曞彴璁惧淇℃伅
+            mdcPassRate.setMdcSectionIds(Collections.singletonList(mdcPassRate.getEquipmentId()));
+        } else {
+            //鏌ヨ鐢ㄦ埛鎵�鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(mdcPassRate.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+        if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) {
+            mdcPassRate.setMdcSectionIds(equipmentIds);
+        }
+        if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) {
+            return null;
+        } else {
+            queryWrapper.in(MdcPassRate::getEquipmentId, mdcPassRate.getMdcSectionIds());
+        }
+        if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) {
+            queryWrapper.like(MdcPassRate::getEquipmentId, mdcPassRate.getEquipmentId());
+        }
+        if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentName())) {
+            queryWrapper.like(MdcPassRate::getEquipmentName, mdcPassRate.getEquipmentName());
+        }
+        if (StringUtils.isNotEmpty(mdcPassRate.getStartTime()) && StringUtils.isNotEmpty(mdcPassRate.getEndTime())) {
+            queryWrapper.between(MdcPassRate::getEfficientDate, mdcPassRate.getStartTime(), mdcPassRate.getEndTime());
+        }
+        queryWrapper.orderByAsc(MdcPassRate::getEquipmentName).orderByDesc(MdcPassRate::getEfficientDate);
+        // Step.2 AutoPoi 瀵煎嚭Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<MdcPassRate> mdcPassRates = this.baseMapper.selectList(queryWrapper);
+        // 瀵煎嚭鏂囦欢鍚嶇О
+        mv.addObject(NormalExcelConstants.FILE_NAME, "鍚堟牸鐜囧垪琛�");
+        mv.addObject(NormalExcelConstants.CLASS, MdcPassRate.class);
+        //鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
+        //update-begin---author:wangshuai ---date:20211227  for锛歔JTC-116]瀵煎嚭浜哄啓姝讳簡------------
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("鍚堟牸鐜囧垪琛ㄦ暟鎹�", "瀵煎嚭浜�:" + user.getRealname(), "瀵煎嚭淇℃伅"));
+        //update-end---author:wangshuai ---date:20211227  for锛歔JTC-116]瀵煎嚭浜哄啓姝讳簡------------
+        mv.addObject(NormalExcelConstants.DATA_LIST, mdcPassRates);
+        return mv;
+    }
+}

--
Gitblit v1.9.3