智慧保安后台管理-外网
Administrator
2022-06-30 a9943ed22bd7568924bf98c462139269d873cd8a
新增保安员证编号批量导入,保安员新增,从业记录同步sql 修改
4 files modified
2 files added
129 ■■■■■ changed files
src/main/java/org/springblade/modules/securitypaper/controller/SecurityPaperController.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/securitypaper/excel/PaperExcel.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/securitypaper/excel/PaperImporter.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/securitypaper/service/SecurityPaperService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/securitypaper/controller/SecurityPaperController.java
@@ -13,6 +13,8 @@
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.excel.PaperExcel;
import org.springblade.modules.securitypaper.excel.PaperImporter;
import org.springblade.modules.securitypaper.excel.SecurityPaperExcel;
import org.springblade.modules.securitypaper.excel.SecurityPaperImporter;
import org.springblade.modules.securitypaper.service.SecurityPaperService;
@@ -102,7 +104,7 @@
    /**
     * 导入保安员证数据
     * 导入保安员证数据(需用户编号,无效保安员身份证号码)
     */
    @PostMapping("import-security-paper")
    public R importSecurityPaper(MultipartFile file, Integer isCovered, String deptId) {
@@ -112,6 +114,16 @@
    }
    /**
     * 导入保安员证数据(需身份证号码,无需用户编号)
     */
    @PostMapping("import-paper")
    public R importPaper(MultipartFile file, Integer isCovered) {
        PaperImporter paperImporter = new PaperImporter(securityPaperService, false);
        ExcelUtil.save(file, paperImporter, PaperExcel.class);
        return R.success("操作成功");
    }
    /**
     * 导出模板
     */
    @GetMapping("export-template-security-paper")
src/main/java/org/springblade/modules/securitypaper/excel/PaperExcel.java
New file
@@ -0,0 +1,38 @@
package org.springblade.modules.securitypaper.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serializable;
/**
 * UserExcel
 *
 * @author Chill
 */
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class PaperExcel implements Serializable {
    private static final long serialVersionUID = 1L;
    @ColumnWidth(10)
    @ExcelProperty("姓名*")
    private String realName;
    @ExcelProperty("身份证号*")
    @ColumnWidth(20)
    private String cardid;
    @ExcelProperty("保安员证编号*")
    @ColumnWidth(15)
    private String number;
}
src/main/java/org/springblade/modules/securitypaper/excel/PaperImporter.java
New file
@@ -0,0 +1,40 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.securitypaper.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.modules.securitypaper.service.SecurityPaperService;
import java.util.List;
/**
 * 保安员证数据数据导入类
 *
 * @author zhongrj
 */
@RequiredArgsConstructor
public class PaperImporter implements ExcelImporter<PaperExcel> {
    private final SecurityPaperService service;
    private final Boolean isCovered;
    @Override
    public void save(List<PaperExcel> data) {
        service.importPaper(data, isCovered);
    }
}
src/main/java/org/springblade/modules/securitypaper/service/SecurityPaperService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.excel.PaperExcel;
import org.springblade.modules.securitypaper.excel.SecurityPaperExcel;
import java.util.List;
@@ -19,4 +20,11 @@
     * @param deptId
     */
    void importSecurityPaper(List<SecurityPaperExcel> data, Boolean isCovered, String deptId);
    /**
     * 批量导入证件数据
     * @param data
     * @param isCovered
     */
    void importPaper(List<PaperExcel> data, Boolean isCovered);
}
src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java
@@ -12,6 +12,7 @@
import org.springblade.modules.FTP.Result;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.excel.PaperExcel;
import org.springblade.modules.securitypaper.excel.SecurityPaperExcel;
import org.springblade.modules.securitypaper.mapper.SecurityPaperMapper;
import org.springblade.modules.securitypaper.service.SecurityPaperService;
@@ -176,4 +177,26 @@
            }
        }
    }
    /**
     * 批量导入证件数据
     * @param data
     * @param isCovered
     */
    @Override
    public void importPaper(List<PaperExcel> data, Boolean isCovered) {
        if (data.size()>0){
            for (PaperExcel paperExcel : data) {
                //设置信息
                String sql = "insert into sys_security_paper(number,create_time,people_name,id_card_no,source) " +
                    "values(" + "'" + paperExcel.getNumber() + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'" + "," +
                    "'" + paperExcel.getRealName() + "'" + "," +
                    "'" + paperExcel.getCardid() + "'" + ",3)";
                System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "保安员证编号导入sql = " + sql);
                //数据推送
                myAsyncService.FTP(sql);
            }
        }
    }
}
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -1653,7 +1653,7 @@
                "values(" + "'" + experience.getId() + "'" + "," +
                "'" + experience.getName() + "'" + "," +
                "'" + experience.getPost() + "'" + "," +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
                "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
                "," + "'" + experience.getCardid() + "'" +
                "," + "'" + experience.getCompanyname() + "'" +
                "," + "'" + experience.getSecurityid() + "'"
@@ -1944,8 +1944,8 @@
            //内网同步
            String s = "insert into sys_experience(id,name,entryTime,departureTime,leaving,cardId,companyname,securityId) " +
                "values(" + "'" + experience.getId() + "'" + "," +
                "'" + experience.getName() + "'" + "," +
                "values(" + "'" + experience.getId() + "'" +
                "," + "'" + experience.getName() + "'" +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'" +
                "," + "'" + experience.getLeaving() + "'" +