瀏覽代碼

fan zha 0802

sunyize 2 年之前
父節點
當前提交
36d41ce0b3

+ 39 - 14
tnc-sms/src/main/java/org/jeecg/modules/smscheck/controller/BusinessReminderCardController.java

@@ -13,7 +13,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.poi.ss.formula.functions.T;
 import org.apache.shiro.SecurityUtils;
@@ -36,7 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
-
+import org.springframework.beans.BeanUtils;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.text.DateFormat;
@@ -58,7 +57,7 @@ import java.util.stream.Stream;
 @Slf4j
 public class BusinessReminderCardController  extends JeecgController<BusinessReminderCard, BusinessReminderCardService> {
     @Value("${jeecg.path.upload}")
-    private String upLoadPath;
+    private static String upLoadPath;
     @Autowired
     private BusinessReminderCardService businessReminderCardService;
     @Autowired
@@ -320,35 +319,61 @@ public class BusinessReminderCardController  extends JeecgController<BusinessRem
 
         List<String> numberResults = request.getParameterMap().get("numberResults[]")==null?new ArrayList<>():  new ArrayList<>(Arrays.asList(request.getParameterMap().get("numberResults[]")));
 
-        if (numberResults!=null && numberResults.size()==1 && (numberResults.get(0).equals("3"))|| numberResults.get(0).equals("1")){
+        if (numberResults!=null && numberResults.size()==1){
             if (numberResults.get(0).equals("3")){
-                BeanUtils.copyProperties(exportList, excels);
+                copyList(exportList,excels,NameListExcel.class);
                 for (NameListExcel excel : excels) {
                     excel.setApplicationDate(format);
                 }
-                getModelAndView(excels,"骚扰电话\\诈骗电话管控申请表");
+                return getModelAndView(excels,"骚扰电话\\诈骗电话管控申请表",NameListExcel.class);
             }
             //关停  shutDown
-            if (numberResults.get(0).equals("1")){
-                BeanUtils.copyProperties(exportList, excelList);
+            if (numberResults.get(0).equals("2")){
+                copyList(exportList,excelList,ShowDownExcel.class);
+                int i =1;
                 for (ShowDownExcel showDownExcel : excelList) {
-                    showDownExcel.setIsNow("否");
-                    showDownExcel.setLabel("安防停机-不可复开");
+                    showDownExcel.setIndex(i);
+                    i++;
+                    if (showDownExcel.getStatus().equals("0")){
+                        showDownExcel.setIsNow("否");
+                        showDownExcel.setLabel("安防停机-不可复开");
+                    }
+                    if (showDownExcel.getStatus().equals("1")){
+                        showDownExcel.setIsNow("是");
+                        showDownExcel.setLabel("安防停机-不可复开");
+                    }
                 }
-                getModelAndView(excelList,"上报关停号码列表");
+                return getModelAndView(excelList,"上报关停号码列表",ShowDownExcel.class);
             }
         }
 
-         return getModelAndView(exportList,"入网信息业务");
+         return getModelAndView(exportList,"入网信息业务",BusinessReminderCard.class);
     }
 
-    private ModelAndView getModelAndView(Object data,String title){
+
+    public static <S,T> void copyList(Collection<S> sCollection,Collection<T> tCollection,Class<T> tClass) {
+        if (sCollection == null || tCollection == null || sCollection.size() == 0) {
+            return;
+        }
+        try {
+            for (S s : sCollection) {
+                T t = tClass.newInstance();
+                BeanUtils.copyProperties(s, t);
+                tCollection.add(t);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private static <S,T>   ModelAndView getModelAndView(Object data,String title,Class<T> tClass){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         // Step.3 AutoPoi 导出Excel
         ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
         //此处设置的filename无效 ,前端会重更新设置一下
         mv.addObject(NormalExcelConstants.FILE_NAME, "入网信息业务");
-        mv.addObject(NormalExcelConstants.CLASS, BusinessReminderCard.class);
+        mv.addObject(NormalExcelConstants.CLASS, tClass);
         //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
         ExportParams  exportParams=new ExportParams(  title, "导出人:" + sysUser.getRealname(), "入网信息业务");
         exportParams.setImageBasePath(upLoadPath);

+ 5 - 1
tnc-sms/src/main/java/org/jeecg/modules/smscheck/entity/excel/NameListExcel.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.smscheck.entity.excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -14,6 +16,8 @@ import java.util.Date;
  * @Date: 2023-08-24  19:53
  */
 @Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
 public class NameListExcel {
     /** 姓名 */
     @Excel(name = "姓名", width = 15)
@@ -36,7 +40,7 @@ public class NameListExcel {
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "入网时间")
     @Excel(name = "入网时间", width = 15)
-    private Date staffNo;
+    private String staffNo;
 
 
     @ApiModelProperty(value = "申请日期")

+ 6 - 0
tnc-sms/src/main/java/org/jeecg/modules/smscheck/entity/excel/ShowDownExcel.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.smscheck.entity.excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -14,6 +16,8 @@ import java.util.Date;
  * @Date: 2023-08-24  20:02
  */
 @Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
 public class ShowDownExcel {
 
 
@@ -37,4 +41,6 @@ public class ShowDownExcel {
     @ApiModelProperty(value = "现是否为关停状态")
     @Excel(name = "现是否为关停状态", width = 15)
     private String isNow;
+
+    private String status;
 }