src/main/java/org/springblade/modules/apply/entity/ExamPayment.java
@@ -45,7 +45,7 @@ /** * 缴费类型 1:公司缴费 2:个人缴费 */ private Long type; private Integer type; /** @@ -81,4 +81,12 @@ */ @TableField("apply_code") private String applyCode; /** * 缴费凭证 url */ @TableField("certificate_url") private String certificateUrl; } src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml
@@ -2,28 +2,39 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.springblade.modules.apply.mapper.ExamPaymentMapper"> <!--考试报名分页信息--> <!--缴费分页信息--> <select id="selectExamPaymentPage" resultType="org.springblade.modules.apply.vo.ExamPaymentVO"> SELECT se.*, bd.dept_name deptName se.*, bu.real_name realName,bu.cardid idCardNo,bu.sex,bu.phone, bd.dept_name deptName FROM sys_exam_payment se sys_exam_payment se left join blade_dept bd blade_user bu on bd.id = se.worker_id bu.id = se.worker_id left join blade_dept bd on bd.id = bu.dept_id WHERE type = 1 type = 1 <if test="examPayment.workerId!=null and examPayment.workerId!=''"> and se.worker_id like concat('%', #{examPayment.workerId},'%') </if> <if test="examPayment.deptName!=null and examPayment.deptName!=''"> and bd.dept_name like concat('%', #{examPayment.deptName},'%') </if> <if test="examPayment.realName!=null and examPayment.realName!=''"> and bu.real_name like concat('%', #{examPayment.realName},'%') </if> <if test="examPayment.idCardNo!=null and examPayment.idCardNo!=''"> and bu.cardid like concat('%', #{examPayment.idCardNo},'%') </if> </select> <!--考试报名详情信息--> <!--缴费详情信息--> <select id="selectExamPaymentInfo" resultType="org.springblade.modules.apply.vo.ExamPaymentVO"> SELECT * src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java
@@ -44,5 +44,25 @@ */ private Integer num; /** * 保安员姓名 */ private String realName; /** * 身份证号 */ private String idCardNo; /** * 性别 1男 2女 */ private Integer sex; /** * 联系电话 */ private String phone; } src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherMapper.xml
@@ -26,6 +26,10 @@ blade_user bu on bu.id = sd.user_ids left join sys_information si on si.departmentid = bu.dept_id where 1=1 <if test="dispatcher.dispatcherUnitId!=null"> and sd.dispatcher_unit_id = #{dispatcher.dispatcherUnitId} @@ -40,6 +44,9 @@ <if test="dispatcher.userIds!=null and dispatcher.userIds!=''"> and sd.user_ids like concat('%', #{dispatcher.userIds},'%') </if> <if test="dispatcher.jurisdiction!=null and dispatcher.jurisdiction!='' and dispatcher.jurisdiction!='1372091709474910209' "> and si.jurisdiction = #{dispatcher.jurisdiction} </if> <if test="dispatcher.name!=null and dispatcher.name!=''"> and sd.name like concat('%', #{dispatcher.name},'%') </if> src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; import org.springblade.modules.apply.entity.Apply; import org.springblade.modules.exam.entity.ExamPaper; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.vo.ExamPaperSubjectVO; @@ -102,4 +103,11 @@ * @return */ Integer getTrainNumber(@Param("examPaper")ExamPaperVO examPaperVO1); /** * 根据用户id查询报名信息 * @param userId 用户id * @return */ List<Apply> getApplyDetail(@Param("userId")String userId); } src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -249,4 +249,37 @@ and cancel = 1 </select> <!--根据用户id查询报名信息--> <select id="getApplyDetail" resultType="org.springblade.modules.apply.entity.Apply"> (select sa.id as id from sys_apply sa left join blade_user bu on bu.id = sa.user_id where sa.user_id = #{userId} and is_apply = 1 and is_exam = 1 and sa.apply_status = 2 ) union all (select str.id as id from sys_training_registration str left join blade_user bu on bu.id = str.user_id where str.user_id = #{userId} and bu.is_train = 1 and is_exam = 1 and str.cancel = 1 ) </select> </mapper> src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.apply.entity.Apply; import org.springblade.modules.exam.entity.ExamPaper; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.vo.ExamPaperSubjectVO; @@ -96,4 +97,11 @@ * @return */ ExamPaper getExamInfoByExamName(String examName); /** * 根据用户id查询报名信息 * @param userId 用户id * @return */ List<Apply> getApplyDetail(String userId); } src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.modules.apply.entity.Apply; import org.springblade.modules.exam.entity.ExamPaper; import org.springblade.modules.exam.entity.ExamSubjectChoices; import org.springblade.modules.exam.mapper.ExamPaperMapper; @@ -142,4 +143,14 @@ public ExamPaper getExamInfoByExamName(String examName) { return baseMapper.getExamInfoByExamName(examName); } /** * 根据用户id查询报名信息 * @param userId 用户id * @return */ @Override public List<Apply> getApplyDetail(String userId) { return baseMapper.getApplyDetail(userId); } } src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -34,6 +34,10 @@ import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.Func; import org.springblade.modules.FTP.FtpUtil; import org.springblade.modules.apply.entity.Apply; import org.springblade.modules.apply.entity.ExamPayment; import org.springblade.modules.apply.service.ExamPaymentService; import org.springblade.modules.exam.service.ExamPaperService; import org.springblade.modules.resource.builder.oss.OssBuilder; import org.springblade.modules.resource.entity.Attach; import org.springblade.modules.resource.service.IAttachService; @@ -77,6 +81,10 @@ private final IUserService userService; private final ExamPaperService examPaperService; private final ExamPaymentService examPaymentService; /** * 创建存储桶 @@ -373,6 +381,122 @@ /** * 文件上传,zip , 缴费凭证 * * @param file 图片对象 */ @PostMapping("put-file-exam-payment-zip") public R putFileExamPaymentZip(@RequestParam MultipartFile file) throws Exception { Map<String, Object> map = new HashMap<>(1); //填写你文件上传的地址以及相应信息 String url = "http://223.82.109.183:2081"; String access = "zhbaadmin"; String secret = "zhbapassword"; String bucket = "zhba"; MinioClient minioClient = MinioClient.builder() .endpoint(url) .credentials(access, secret) .build(); // 检查存储桶是否已经存在 boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build()); if (!isExist) { // 创建一个名为zip的存储桶,用于zip文件。 minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build()); minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).build()); } String fileName = file.getOriginalFilename(); String namePath = fileName.substring(0,fileName.lastIndexOf(".")); String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.US); //判断文件是不是zip类型 if(!fileType.equals("zip")){ map.put("data","上传文件类型不符!"); return R.data(map); } //FileConfig.localtion是配置文件和config类生产的,测试demo可以直接把FileConfig.localtion替换成D:/test String uuid = UUID.randomUUID().toString(); String desPath = FileConfig.localtion + File.separator + uuid.replaceAll("-", ""); //遗漏了这个代码,在本地测试环境不会出问题,在服务器上一定会报没有找到文件的错误 String savePath = FileConfig.localtion + File.separator; FileUtil fileUtil = new FileUtil(); //解压zip文件 FileUtil.unZip(file, desPath,savePath); List<MultipartFile> fileList = new ArrayList<>(); //获取图片文件 fileList = fileUtil.getSubFiles(desPath+File.separator+namePath,fileList); for (MultipartFile multipartFile : fileList){ if(multipartFile.getName().toLowerCase().endsWith(".png") || multipartFile.getName().toLowerCase().endsWith(".jpg")) { String newName = "upload/picture/" + UUID.randomUUID().toString().replaceAll("-", "") + multipartFile.getName().substring(multipartFile.getName().lastIndexOf(".")); InputStream in = multipartFile.getInputStream(); String[] split = newName.split("/"); //创建头部信息 Map<String, String> headers = new HashMap<>(1 << 2); //添加自定义内容类型 headers.put("Content-Type", "application/octet-stream"); //上传 minioClient.putObject( PutObjectArgs.builder().bucket(bucket).object(newName).stream( in, in.available(), -1) .headers(headers) .build()); String urls = "http://223.82.109.183:2081/zhba/" + newName; //内网 String inUrl = ip + newName; //取出身份证号,查询用户信息,更新用户信息 String pictrueName = multipartFile.getName().substring(0, multipartFile.getName().lastIndexOf(".")); // String regex ="([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})"; String regex ="[\u4e00-\u9fa5]"; Pattern compile = Pattern.compile(regex); String idCardNo = compile.matcher(pictrueName).replaceAll(""); User user = userService.getUserInfoByIdCardNo(idCardNo); //设置用户头像url if (null!=user){ ExamPayment examPayment = new ExamPayment(); examPayment.setWorkerId(user.getId().toString()); examPayment.setCertificateUrl(urls); examPayment.setType(1); examPayment.setPaymentTime(new Date()); //查询当前人员的报名信息 List<Apply> applyList = examPaperService.getApplyDetail(user.getId().toString()); //有且只有一条信息 if (applyList.size()==1){ examPayment.setApplyCode(applyList.get(0).getId().toString()); } //新增 examPaymentService.save(examPayment); //数据推送 String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(examPayment.getPaymentTime()); String s = "insert into sys_apply(id,type,payment_time,worker_id,apply_code,certificate_url) " + "values(" + "'" + examPayment.getId() + "'" + "," + "'" + examPayment.getType() + "'" + "," + "'" + formatStr + "'" + "," + "'" + examPayment.getWorkerId() + "'" + "," + "'" + examPayment.getApplyCode() + "'" + "," +"'" + examPayment.getCertificateUrl() + "'" + ")"; FtpUtil.sqlFileUpload(s); //文件推送 InputStream inputStream = multipartFile.getInputStream(); FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream); in.close(); } } } //最后要删除文件 FileUtil.clearFiles(FileConfig.localtion + File.separator + file.getOriginalFilename()); FileUtil.clearFiles(desPath); //数据封装 map.put("data", "上传成功!"); //返回 return R.data(map); } /** * 文件上传,自定义上传 * * @param file 图片对象