From 189add7a28d273861f9e54c81fb0330da4327ca0 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期五, 28 十一月 2025 16:48:39 +0800
Subject: [PATCH] 补片管理界面添加导出功能,补片、返工管理相关筛选调整

---
 north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml                        |   12 +-
 north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue            |   60 +++++++++++++++
 north-glass-erp/src/main/java/com/example/erp/dto/pp/exportReplenishDTO.java         |   68 +++++++++++++++++
 north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml                      |   52 +++++++++++-
 north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java          |    5 +
 north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java       |   15 +++
 north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java |   15 +++
 7 files changed, 216 insertions(+), 11 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue b/north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue
index 605f541..f6aee63 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/replenish/SelectReplenish.vue
@@ -190,6 +190,10 @@
         'code':'cancelReview'
       }
     ],
+    slots: {
+      tools: 'toolbar_buttons',
+      buttons:'buttons'
+    },
     /*import: false,
     export: true,
     print: true,*/
@@ -362,8 +366,53 @@
   reserve:true
 }
 
+const exportEvent = () => {
+  const $table = xGrid.value
+  if ($table) {
+    $table.exportData({
+      filename: 'order_export',
+      sheetName: 'Sheet1',
+      type: 'xlsx'
+    })
+  }
+}
 
+function exportExcel(url, fileName,date) {
+  gridOptions.loading = true
+  if(date===null){
+    ElMessage.warning(t('report.pleaseSelectADateFirst'))
+    return
+  }
 
+  const date1 = new Date(date[0]);
+  const date2 = new Date(date[1]);
+  const timeDiff = Math.abs(date2.getTime() - date1.getTime());
+  const daysDiff = timeDiff / (1000 * 3600 * 24);
+  if(Math.floor(daysDiff)>180){
+    ElMessage.warning(t('report.theFilteringTimeForExportCannotExceed180Days'))
+    return
+  }
+  let dataMp = ref({
+    date: date,
+  })
+  request.post(url,date,{responseType :'blob'}).then(res => {
+    const blob = new Blob([res])
+    if ('download' in document.createElement('a')) { // 闈濱E涓嬭浇
+      const elink = document.createElement('a')
+      elink.download = `${fileName}.xlsx`
+      elink.style.display = 'none'
+      elink.href = URL.createObjectURL(blob)
+      document.body.appendChild(elink)
+      elink.click()
+      URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
+      document.body.removeChild(elink)
+      gridOptions.loading = false
+    } else { // IE10+涓嬭浇
+      navigator.msSaveBlob(blob, fileName)
+    }
+
+  })
+}
 </script>
 
 <template>
@@ -444,7 +493,18 @@
           >
           </vxe-pager>
         </template>
+        <template #toolbar_buttons>
+          <vxe-button icon="vxe-icon-download" circle
+                      style="margin-right: 0.5rem"
+                      @click="exportEvent" />
 
+          <vxe-button icon="vxe-icon-cloud-download" style="margin-right: 0.5rem"
+                      circle
+                      @click="exportExcel('/Replenish/exportReplenish',
+                                          t('replenish.patchManagement'),
+                                          selectDate)" />
+
+        </template>
 
       </vxe-grid>
     </div>
diff --git a/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java b/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
index 6b6ff0f..a9a1d17 100644
--- a/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
+++ b/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
@@ -5,18 +5,24 @@
 import com.example.erp.common.Result;
 import com.example.erp.dto.pp.PatchLogAddDTO;
 import com.example.erp.dto.pp.PatchLogDTO;
+import com.example.erp.dto.pp.TeamOutputDTO;
+import com.example.erp.dto.pp.exportReplenishDTO;
 import com.example.erp.entity.pp.FlowCard;
 import com.example.erp.entity.pp.PatchLog;
 import com.example.erp.entity.pp.Rework;
 import com.example.erp.exception.ServiceException;
 import com.example.erp.service.pp.ReplenishService;
 import com.example.erp.service.pp.ReworkService;
+import com.example.erp.tools.DownExcel;
 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.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.sql.Date;
+import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
 
@@ -93,4 +99,13 @@
     public Result updateCancelReview( @RequestBody Map<String,Object> object){
         return Result.success(replenishService.updateCancelReviewSv(object));
     }
+
+    @ApiOperation("琛ョ墖淇℃伅瀵煎嚭")
+    @PostMapping("/exportReplenish")
+    public void exportReplenish(HttpServletResponse response,
+                                 @RequestBody List<LocalDate> dates
+    ) throws IOException, IllegalAccessException, InstantiationException {
+        //鍙傛暟锛氱浉搴旂殑鏁版嵁锛屽疄浣撶被淇℃伅锛岀浉搴旂殑鏂规硶锛堟暟鎹幏鍙栵級锛岀敓鎴愮殑excel鍚嶅瓧
+        DownExcel.download(response, exportReplenishDTO.class, replenishService.exportReplenishSv(dates), "PatchLogAddDTO");
+    }
 }
diff --git a/north-glass-erp/src/main/java/com/example/erp/dto/pp/exportReplenishDTO.java b/north-glass-erp/src/main/java/com/example/erp/dto/pp/exportReplenishDTO.java
new file mode 100644
index 0000000..145d0c3
--- /dev/null
+++ b/north-glass-erp/src/main/java/com/example/erp/dto/pp/exportReplenishDTO.java
@@ -0,0 +1,68 @@
+package com.example.erp.dto.pp;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class exportReplenishDTO {
+    @ExcelProperty("閿�鍞崟鍙�")
+    private String orderId;
+    @ExcelProperty("琛ョ墖鍗曞彿")
+    private String patchId;
+    @ExcelProperty("鎶ュ伐缂栧彿")
+    private String reportingWorkId;
+    @ExcelProperty("娴佺▼鍗″彿")
+    private String processId;
+    @ExcelProperty("椤圭洰鍚嶇О")
+    private String project;
+    @ExcelProperty("鎵规")
+    private String batch;
+    @ExcelProperty("瀹℃牳浜�")
+    private String reviewer;
+    @ExcelProperty("缂栧彿")
+    private String glassNumber;
+    @ExcelProperty("璁㈠崟搴忓彿")
+    private Integer orderSort;
+    @ExcelProperty("浜у搧鍚嶇О")
+    private String productName;
+    @ExcelProperty("灞傚彿")
+    private Integer technologyNumber;
+    @ExcelProperty("鐗囨爣璁�")
+    private String glassAddress;
+    @ExcelProperty("鍗曠墖鍚嶇О")
+    private String glassChild;
+    @ExcelProperty("鏁伴噺")
+    private Integer patchNum;
+    @ExcelProperty("瀹�")
+    private Double width;
+    @ExcelProperty("楂�")
+    private Double height;
+    @ExcelProperty("褰㈢姸")
+    private String shape;
+    @ExcelProperty("鎶ュ伐宸ュ簭")
+    private String patchProcesses;
+    @ExcelProperty("琛ョ墖鍘熷洜")
+    private String patchReason;
+    @ExcelProperty("琛ョ墖绫诲瀷")
+    private String patchType;
+    @ExcelProperty("璐d换淇℃伅")
+    private String responsiblePersonnel;
+    @ExcelProperty("璐d换璁惧")
+    private String responsibleEquipment;
+    @ExcelProperty("璐d换鐝粍")
+    private String responsibleTeam;
+    @ExcelProperty("闈㈢Н")
+    private String patchArea;
+    @ExcelProperty("鍒跺崟鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime createTime;
+    @ExcelProperty("瀹℃牳鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime updateTime;
+
+
+}
diff --git a/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java b/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
index e6cae01..8eb6174 100644
--- a/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
+++ b/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
@@ -2,12 +2,15 @@
 
 import com.example.erp.dto.pp.PatchLogAddDTO;
 import com.example.erp.dto.pp.PatchLogDTO;
+import com.example.erp.dto.pp.exportReplenishDTO;
+import com.example.erp.dto.sd.OrderDTO;
 import com.example.erp.entity.pp.PatchLog;
 import com.example.erp.entity.pp.ReportingWork;
 import com.github.yulichang.base.MPJBaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
 
@@ -50,5 +53,7 @@
     Boolean updateReplenishCancel(@Param("patchLog") PatchLog patchLog);
 
     Integer selectProjectCount(String processId, String patchId, Integer technologyNumber);
+
+    List<exportReplenishDTO> exportReplenishMp(List<LocalDate> dates);
 }
 
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
index a0099f2..9025211 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
@@ -7,6 +7,8 @@
 import com.example.erp.common.AsyncQueryExecutor;
 import com.example.erp.dto.pp.PatchLogAddDTO;
 import com.example.erp.dto.pp.PatchLogDTO;
+import com.example.erp.dto.pp.exportReplenishDTO;
+import com.example.erp.dto.sd.OrderDTO;
 import com.example.erp.entity.pp.FlowCard;
 import com.example.erp.entity.pp.PatchLog;
 import com.example.erp.entity.pp.ReportingWork;
@@ -340,6 +342,13 @@
                         reportingWorkMapper.updateRWDPatchNum(patchLog1.getReportingWorkId(),patchLog1.getOrderSort(),patchLog1.getTechnologyNumber(),patchLog1.getPatchNum());
                         //鏇存柊鎶ュ伐娴佺▼琛ㄦ暟鎹�
                         reportingWorkMapper.updateReplenishWorkProcess(patchLog1.getProcessId(),patchLog1.getOrderSort(),patchLog1.getTechnologyNumber(),patchLog1.getPatchNum(),patchLog1.getPatchProcesses());
+
+                        Log log = new Log();
+                        log.setContent(object.toString());
+                        log.setFunction("deleteReplenishSv琛ョ墖鍒犻櫎");
+                        log.setOperatorId((String) object.get("userId"));
+                        log.setOperator((String) object.get("userName"));
+                        logService.saveLog(log);
                     }
                     else{
                         saveState = false;
@@ -417,5 +426,11 @@
 
         return saveState;
     }
+
+//    public List exportReplenishSv(Map<String, Object> dates) {
+//    }
+    public List<exportReplenishDTO> exportReplenishSv(List<LocalDate> dates) {
+        return patchMapper.exportReplenishMp(dates);
+    }
 }
 
diff --git a/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml b/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
index 1f09882..b554941 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
@@ -100,7 +100,7 @@
                 and ogd.glass_child regexp #{patchLog.glassChild}
             </if>
             <if test="patchLog.responsibleTeam != null and patchLog.responsibleTeam != ''">
-                and r.responsible_team regexp #{patchLog.responsibleTeam}
+                and r.responsible_team like concat('%', #{patchLog.responsibleTeam}, '%')
             </if>
             <if test="patchLog.responsibleEquipment != null and patchLog.responsibleEquipment != ''">
                 and r.responsible_equipment regexp #{patchLog.responsibleEquipment}
@@ -124,7 +124,7 @@
                 and r.patch_processes regexp #{patchLog.patchProcesses}
             </if>
             <if test="patchLog.reviewer != null and patchLog.reviewer != ''">
-                and r.reviewer regexp #{patchLog.reviewer}
+                and r.reviewer like concat('%', #{patchLog.reviewer}, '%')
             </if>
         </where>
          order by r.review_status,r.id desc
@@ -193,7 +193,7 @@
                 and ogd.glass_child regexp #{patchLog.glassChild}
             </if>
             <if test="patchLog.responsibleTeam != null and patchLog.responsibleTeam != ''">
-                and r.responsible_team regexp #{patchLog.responsibleTeam}
+                and r.responsible_team like concat('%', #{patchLog.responsibleTeam}, '%')
             </if>
             <if test="patchLog.responsibleEquipment != null and patchLog.responsibleEquipment != ''">
                 and r.responsible_equipment regexp #{patchLog.responsibleEquipment}
@@ -217,7 +217,7 @@
                 and r.patch_processes regexp #{patchLog.patchProcesses}
             </if>
             <if test="patchLog.reviewer != null and patchLog.reviewer != ''">
-                and r.reviewer regexp #{patchLog.reviewer}
+                and r.reviewer like concat('%', #{patchLog.reviewer}, '%')
             </if>
         </where>
         ) as zu
@@ -368,7 +368,7 @@
                 and ogd.glass_child regexp #{patchLogAddDTO.glassChild}
             </if>
             <if test="patchLogAddDTO.responsibleTeam != null and patchLogAddDTO.responsibleTeam != ''">
-                and dd.responsible_team regexp #{patchLogAddDTO.responsibleTeam}
+                and dd.responsible_team like concat('%', #{patchLogAddDTO.responsibleTeam}, '%')
             </if>
             <if test="patchLogAddDTO.responsibleEquipment != null and patchLogAddDTO.responsibleEquipment != ''">
                 and dd.responsible_equipment regexp #{patchLogAddDTO.responsibleEquipment}
@@ -432,4 +432,46 @@
           and project_no IS not NULL;
     </select>
 
+    <select id="exportReplenishMp">
+        select
+        r.id,
+        r.review_status,
+        r.reporting_work_id,
+        r.patch_id,
+        r.process_id,
+        r.order_id,
+        r.order_sort,
+        o.project,
+        o.batch,
+        od.building_number,
+        od.product_name,
+        r.technology_number,
+        ogd.glass_address,
+        ogd.glass_child,
+        r.patch_num,
+        ogd.child_width as width,
+        ogd.child_height as height,
+        od.shape,
+        r.patch_type,
+        r.patch_reason,
+        r.responsible_team,
+        r.responsible_personnel,
+        r.responsible_equipment,
+        r.patch_area,
+        r.quality_inspector,
+        r.patch_processes,
+        r.reviewer,
+        r.create_time as create_time,
+        date(r.update_time) as update_time,
+        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS glassNumber
+        from pp.patch_log r left join sd.order_detail od on r.order_id=od.order_id and r.order_sort=od.order_number
+        left join sd.`order` o on r.order_id = o.order_id
+        left join (select * from sd.order_glass_detail group by order_id,order_number,technology_number) as ogd
+        on r.order_id = ogd.order_id and r.order_sort = ogd.order_number and r.technology_number=ogd.technology_number
+        <where>
+            date(r.create_time)>=#{dates[0]} and date(r.create_time) &lt;= #{dates[1]}
+            and o.create_order>0
+        </where>
+        order by r.review_status,r.id desc
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml b/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
index 97a9760..996eb69 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
@@ -51,7 +51,7 @@
                 and r.rework_id regexp #{rework.reworkId}
             </if>
             <if test="rework.reworkTeam != null and rework.reworkTeam != ''">
-                and r.rework_team regexp #{rework.reworkTeam}
+                and r.rework_team like concat('%', #{rework.reworkTeam}, '%')
             </if>
             <if test="rework.orderId != null and rework.orderId != ''">
                 and r.order_id regexp #{rework.orderId}
@@ -99,7 +99,7 @@
                 and ogd.glass_address regexp #{rework.glassAddress}
             </if>
             <if test="rework.responsibleTeam != null and rework.responsibleTeam != ''">
-                and r.responsible_team regexp #{rework.responsibleTeam}
+                and r.responsible_team like concat('%', #{rework.responsibleTeam}, '%')
             </if>
             <if test="rework.responsibleEquipment != null and rework.responsibleEquipment != ''">
                 and r.responsible_equipment regexp #{rework.responsibleEquipment}
@@ -123,7 +123,7 @@
                 and r.rework_processes regexp #{rework.reworkProcesses}
             </if>
             <if test="rework.reviewer != null and rework.reviewer != ''">
-                and r.reviewer regexp #{rework.reviewer}
+                and r.reviewer like concat('%', #{rework.reviewer}, '%')
             </if>
         </where>
          order by r.review_status,r.id desc limit #{offset},#{pageSize};
@@ -145,7 +145,7 @@
                 and r.rework_id regexp #{rework.reworkId}
             </if>
             <if test="rework.reworkTeam != null and rework.reworkTeam != ''">
-                and r.rework_team regexp #{rework.reworkTeam}
+                and r.rework_team like concat('%', #{rework.reworkTeam}, '%')
             </if>
             <if test="rework.orderId != null and rework.orderId != ''">
                 and r.order_id regexp #{rework.orderId}
@@ -193,7 +193,7 @@
                 and ogd.glass_address regexp #{rework.glassAddress}
             </if>
             <if test="rework.responsibleTeam != null and rework.responsibleTeam != ''">
-                and r.responsible_team regexp #{rework.responsibleTeam}
+                and r.responsible_team like concat('%', #{rework.responsibleTeam}, '%')
             </if>
             <if test="rework.responsibleEquipment != null and rework.responsibleEquipment != ''">
                 and r.responsible_equipment regexp #{rework.responsibleEquipment}
@@ -217,7 +217,7 @@
                 and r.rework_processes regexp #{rework.reworkProcesses}
             </if>
             <if test="rework.reviewer != null and rework.reviewer != ''">
-                and r.reviewer regexp #{rework.reviewer}
+                and r.reviewer like concat('%', #{rework.reviewer}, '%')
             </if>
         </where>
         ) as zu;

--
Gitblit v1.8.0