张延森 3 jaren geleden
bovenliggende
commit
06e80d75df

+ 1
- 1
pom.xml Bestand weergeven

@@ -80,7 +80,7 @@
80 80
 		<dependency>
81 81
 			<groupId>com.alibaba</groupId>
82 82
 			<artifactId>easyexcel</artifactId>
83
-			<version>2.0.4</version>
83
+			<version>3.0.5</version>
84 84
 		</dependency>
85 85
 		<!--excel end-->
86 86
 

+ 39
- 0
src/main/java/com/njyunzhi/ubpa/common/excelConverter/LocalDateTimeConverter.java Bestand weergeven

@@ -0,0 +1,39 @@
1
+package com.njyunzhi.ubpa.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+import com.njyunzhi.ubpa.common.DateUtils;
9
+
10
+import java.time.LocalDateTime;
11
+
12
+public class LocalDateTimeConverter implements Converter<LocalDateTime> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return LocalDateTime.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 写 Excel
25
+     * @param value
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        if (null == value) return null;
34
+
35
+        String val = DateUtils.toString(value, "yyyy-MM-dd HH:mm:ss");
36
+
37
+        return new WriteCellData(val);
38
+    }
39
+}

+ 49
- 0
src/main/java/com/njyunzhi/ubpa/common/excelConverter/ResultStatusConverter.java Bestand weergeven

@@ -0,0 +1,49 @@
1
+package com.njyunzhi.ubpa.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+public class ResultStatusConverter implements Converter<Integer> {
10
+    @Override
11
+    public Class supportJavaTypeKey() {
12
+        return Integer.class;
13
+    }
14
+
15
+    @Override
16
+    public CellDataTypeEnum supportExcelTypeKey() {
17
+        return CellDataTypeEnum.STRING;
18
+    }
19
+
20
+    /**
21
+     * 写 excel
22
+     * @param value
23
+     * @param contentProperty
24
+     * @param globalConfiguration
25
+     * @return
26
+     * @throws Exception
27
+     */
28
+    @Override
29
+    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
30
+        String result = null;
31
+        if (null == value) return null;
32
+
33
+        final int on = 1;
34
+        final int off = 0;
35
+
36
+        switch (value) {
37
+            case on:
38
+                result = "正常";
39
+                break;
40
+            case off:
41
+                result = "异常";
42
+                break;
43
+            default:
44
+                break;
45
+        }
46
+
47
+        return new WriteCellData(result);
48
+    }
49
+}

+ 1
- 1
src/main/java/com/njyunzhi/ubpa/config/CorsConfig.java Bestand weergeven

@@ -23,7 +23,7 @@ public class CorsConfig implements WebMvcConfigurer {
23 23
                 //是否发送Cookie
24 24
                 .allowCredentials(true)
25 25
                 //设置放行哪些原始域
26
-                .allowedOrigins("http://localhost:8000")
26
+                .allowedOrigins("http://localhost:8000", "http://localhost:3000")
27 27
                 //放行哪些请求方式
28 28
                 .allowedMethods("GET", "POST", "PUT", "DELETE")
29 29
                 //.allowedMethods("*") //或者放行全部

+ 1
- 1
src/main/java/com/njyunzhi/ubpa/controller/TaOrgController.java Bestand weergeven

@@ -62,7 +62,7 @@ public class TaOrgController extends BaseController {
62 62
         QueryWrapper<TaOrg> queryWrapper = new QueryWrapper<>();
63 63
         queryWrapper.eq("status", Constants.STATUS_NORMAL);
64 64
         queryWrapper.like(!StringUtils.isEmpty(orgName), "org_name", "%" + orgName + "%");
65
-        queryWrapper.orderByDesc("org_name");
65
+        queryWrapper.orderByAsc("org_name");
66 66
         queryWrapper.orderByDesc("create_date");
67 67
 
68 68
         IPage<TaOrg> result = iTaOrgService.page(pg, queryWrapper);

+ 32
- 0
src/main/java/com/njyunzhi/ubpa/controller/TaResumeWorkFormController.java Bestand weergeven

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.njyunzhi.ubpa.common.*;
7
+import com.njyunzhi.ubpa.vo.FormExport;
7 8
 import io.swagger.annotations.Api;
8 9
 import io.swagger.annotations.ApiOperation;
9 10
 import io.swagger.annotations.ApiParam;
@@ -19,7 +20,10 @@ import com.njyunzhi.ubpa.service.ITaResumeWorkFormService;
19 20
 import com.njyunzhi.ubpa.entity.TaResumeWorkForm;
20 21
 import org.springframework.web.bind.annotation.RestController;
21 22
 
23
+import javax.servlet.http.HttpServletResponse;
24
+import java.net.URL;
22 25
 import java.time.LocalDateTime;
26
+import java.util.List;
23 27
 
24 28
 /**
25 29
  * <p>
@@ -72,6 +76,34 @@ public class TaResumeWorkFormController extends BaseController {
72 76
         return ResponseBean.success(result);
73 77
     }
74 78
 
79
+    /**
80
+     * 分页查询列表
81
+     * @return
82
+     */
83
+    @RequestMapping(value="/admin/resume-work-form/export",method= RequestMethod.GET)
84
+    @ApiOperation(value="申请导出", notes = "申请导出", httpMethod = "GET", response = ResponseBean.class)
85
+    public void formExport(@ApiParam("企业ID") @RequestParam(value ="orgId", required = false) String orgId,
86
+                           @ApiParam("申请人") @RequestParam(value ="userName", required = false) String userName,
87
+                           @ApiParam(value = "起始时间", example = "2022-03-01") @RequestParam(value ="start", required = false) String start,
88
+                           @ApiParam(value = "结束时间", example = "2022-03-31") @RequestParam(value ="end", required = false) String end,
89
+                           HttpServletResponse response) throws Exception{
90
+
91
+        LocalDateTime startDate = DateUtils.getDayStart(start);
92
+        LocalDateTime endDate = DateUtils.getDayEnd(end);
93
+
94
+        List<FormExport> list = iTaResumeWorkFormService.formExport(orgId, userName, startDate, endDate, Constants.STATUS_NORMAL);
95
+        for(FormExport item: list) {
96
+            if (!StringUtils.isEmpty(item.getAntigenImage())) {
97
+                item.setAntigenImageURL(new URL(item.getAntigenImage()));
98
+            }
99
+            if (!StringUtils.isEmpty(item.getNucleicImage())) {
100
+                item.setNucleicImageURL(new URL(item.getNucleicImage()));
101
+            }
102
+        }
103
+
104
+        ExcelUtils.flush(response, FormExport.class, list, "测试");
105
+    }
106
+
75 107
     /**
76 108
      * 保存对象
77 109
      * @param taResumeWorkForm 实体对象

+ 10
- 0
src/main/java/com/njyunzhi/ubpa/mapper/TaResumeWorkFormMapper.java Bestand weergeven

@@ -2,7 +2,12 @@ package com.njyunzhi.ubpa.mapper;
2 2
 
3 3
 import com.njyunzhi.ubpa.entity.TaResumeWorkForm;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.njyunzhi.ubpa.vo.FormExport;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.time.LocalDateTime;
10
+import java.util.List;
6 11
 
7 12
 /**
8 13
  * <p>
@@ -15,4 +20,9 @@ import org.apache.ibatis.annotations.Mapper;
15 20
 @Mapper
16 21
 public interface TaResumeWorkFormMapper extends BaseMapper<TaResumeWorkForm> {
17 22
 
23
+    List<FormExport> formExport(@Param("orgId") String orgId,
24
+                                @Param("userName") String userName,
25
+                                @Param("startDate") LocalDateTime startDate,
26
+                                @Param("endDate") LocalDateTime endDate,
27
+                                @Param("status") int status);
18 28
 }

+ 5
- 0
src/main/java/com/njyunzhi/ubpa/service/ITaResumeWorkFormService.java Bestand weergeven

@@ -2,6 +2,10 @@ package com.njyunzhi.ubpa.service;
2 2
 
3 3
 import com.njyunzhi.ubpa.entity.TaResumeWorkForm;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.njyunzhi.ubpa.vo.FormExport;
6
+
7
+import java.time.LocalDateTime;
8
+import java.util.List;
5 9
 
6 10
 /**
7 11
  * <p>
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 17
  */
14 18
 public interface ITaResumeWorkFormService extends IService<TaResumeWorkForm> {
15 19
 
20
+    List<FormExport> formExport(String orgId, String userName, LocalDateTime startDate, LocalDateTime endDate, int status);
16 21
 }

+ 8
- 0
src/main/java/com/njyunzhi/ubpa/service/impl/TaResumeWorkFormServiceImpl.java Bestand weergeven

@@ -4,8 +4,12 @@ import com.njyunzhi.ubpa.entity.TaResumeWorkForm;
4 4
 import com.njyunzhi.ubpa.mapper.TaResumeWorkFormMapper;
5 5
 import com.njyunzhi.ubpa.service.ITaResumeWorkFormService;
6 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.njyunzhi.ubpa.vo.FormExport;
7 8
 import org.springframework.stereotype.Service;
8 9
 
10
+import java.time.LocalDateTime;
11
+import java.util.List;
12
+
9 13
 /**
10 14
  * <p>
11 15
  * 复工申请 服务实现类
@@ -17,4 +21,8 @@ import org.springframework.stereotype.Service;
17 21
 @Service
18 22
 public class TaResumeWorkFormServiceImpl extends ServiceImpl<TaResumeWorkFormMapper, TaResumeWorkForm> implements ITaResumeWorkFormService {
19 23
 
24
+    @Override
25
+    public List<FormExport> formExport(String orgId, String userName, LocalDateTime startDate, LocalDateTime endDate, int status) {
26
+        return baseMapper.formExport(orgId, userName, startDate, endDate, status);
27
+    }
20 28
 }

+ 2
- 2
src/main/java/com/njyunzhi/ubpa/shiro/ShiroConfig.java Bestand weergeven

@@ -79,8 +79,8 @@ public class ShiroConfig {
79 79
         // 修改多 Realm 的处理逻辑
80 80
         ModularRealmAuthenticator realmAuthenticator = (ModularRealmAuthenticator) manager.getAuthenticator();
81 81
         // 主要有一个 Realm 成功, 就立即返回
82
-//        realmAuthenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
83
-        realmAuthenticator.setAuthenticationStrategy(new FirstExceptionStrategy());
82
+        realmAuthenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
83
+//        realmAuthenticator.setAuthenticationStrategy(new FirstExceptionStrategy());
84 84
 
85 85
         //  Use your own realm
86 86
         List<Realm> realmList = new ArrayList<Realm>() {{

+ 62
- 0
src/main/java/com/njyunzhi/ubpa/vo/FormExport.java Bestand weergeven

@@ -0,0 +1,62 @@
1
+package com.njyunzhi.ubpa.vo;
2
+
3
+
4
+import com.alibaba.excel.annotation.ExcelIgnore;
5
+import com.alibaba.excel.annotation.ExcelProperty;
6
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
7
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
8
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
9
+import com.alibaba.excel.converters.url.UrlImageConverter;
10
+import com.njyunzhi.ubpa.common.excelConverter.ResultStatusConverter;
11
+import io.swagger.annotations.ApiModel;
12
+import io.swagger.annotations.ApiModelProperty;
13
+import lombok.Data;
14
+import lombok.EqualsAndHashCode;
15
+import lombok.experimental.Accessors;
16
+
17
+import java.net.URL;
18
+import java.time.LocalDateTime;
19
+
20
+@Data
21
+@ContentRowHeight(15)
22
+@HeadRowHeight(25)
23
+@ColumnWidth(25)
24
+@EqualsAndHashCode(callSuper = false)
25
+@Accessors(chain = true)
26
+@ApiModel(value="复工申请导出", description="复工申请导出")
27
+public class FormExport {
28
+
29
+    @ExcelProperty(value = "企业名称", index = 1)
30
+    @ApiModelProperty(value = "所属企业")
31
+    private String orgName;
32
+
33
+    @ExcelProperty(value = "申请人名称", index = 2)
34
+    @ApiModelProperty(value = "申请人姓名")
35
+    private String userName;
36
+
37
+    @ExcelIgnore
38
+    private String antigenImage;
39
+
40
+    @ExcelProperty(value = "抗原截图", index = 3, converter = UrlImageConverter.class)
41
+    @ApiModelProperty(value = "抗原截图")
42
+    private URL antigenImageURL;
43
+
44
+    @ExcelProperty(value = "抗原是否正常", index = 4, converter = ResultStatusConverter.class)
45
+    @ApiModelProperty(value = "抗原是否正常")
46
+    private Integer antigenIsNormal;
47
+
48
+    @ExcelIgnore
49
+    private String nucleicImage;
50
+
51
+    @ExcelProperty(value = "核酸截图", index = 5, converter = UrlImageConverter.class)
52
+    @ApiModelProperty(value = "核酸截图")
53
+    private URL nucleicImageURL;
54
+
55
+    @ExcelProperty(value = "核酸是否正常", index = 6, converter = ResultStatusConverter.class)
56
+    @ApiModelProperty(value = "核酸是否正常")
57
+    private Integer nucleicIsNormal;
58
+
59
+    @ExcelProperty(value = "申请时间", index = 7)
60
+    @ApiModelProperty(value = "创建时间")
61
+    private LocalDateTime createDate;
62
+}

+ 29
- 0
src/main/resources/mapper/TaResumeWorkFormMapper.xml Bestand weergeven

@@ -2,4 +2,33 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.njyunzhi.ubpa.mapper.TaResumeWorkFormMapper">
4 4
 
5
+    <select id="formExport" resultType="com.njyunzhi.ubpa.vo.FormExport">
6
+        SELECT
7
+            s.org_name,
8
+            t.user_name,
9
+            t.antigen_image,
10
+            t.antigen_is_normal,
11
+            t.nucleic_image,
12
+            t.nucleic_is_normal,
13
+            t.create_date
14
+        FROM
15
+            ta_resume_work_form t
16
+            INNER JOIN ta_org s ON t.org_id = s.org_id
17
+        WHERE
18
+            t.`status` = #{status}
19
+          <if test="orgId != null and orgId != ''">
20
+              AND t.org_id = #{orgId}
21
+          </if>
22
+          <if test="userName != null and userName != ''">
23
+              AND t.user_name LIKE CONCAT( '%', #{userName}, '%' )
24
+          </if>
25
+          <if test="startDate != null">
26
+              AND t.startDate &gt;= #{startDate}
27
+          </if>
28
+          <if test="endDate != null">
29
+            AND t.endDate &lt;= #{endDate}
30
+          </if>
31
+        ORDER BY
32
+        s.org_name ASC
33
+    </select>
5 34
 </mapper>