Browse Source

有效期2

zhuhaiwen 3 years ago
parent
commit
7dedc5997a

+ 3 - 2
oa-app/src/main/java/com/css/oa/exam/certificate/controller/CertifiController.java

@ -2,6 +2,7 @@ package com.css.oa.exam.certificate.controller;
2 2
3 3
import com.css.oa.exam.base.BaseController;
4 4
import com.css.oa.exam.certificate.bean.CertiQueryReq;
5
import com.css.oa.exam.certificate.bean.ClientResWrap;
5 6
import com.css.oa.exam.certificate.repository.Certificate;
6 7
import com.css.oa.exam.certificate.service.CertifiService;
7 8
import com.css.oa.utils.Result;
@ -139,8 +140,8 @@ public class CertifiController extends BaseController {
139 140
            if (TextUtils.isEmpty(exam_id)) {
140 141
                return setErr("exam_id 不能为空");
141 142
            }
142
            Certificate obj = mService.myOneCerti(student_id, exam_id);
143
            result = setResult("myOneCerti", obj);
143
            ClientResWrap wrap = mService.myOneCerti(student_id, exam_id);
144
            result = setResult("myOneCerti", wrap);
144 145
        } catch (Exception e) {
145 146
            result = setErr(e.getMessage());
146 147
            e.printStackTrace();

+ 37 - 33
oa-app/src/main/java/com/css/oa/exam/certificate/service/CertifiService.java

@ -21,8 +21,6 @@ import org.springframework.data.jpa.domain.Specification;
21 21
import org.springframework.stereotype.Service;
22 22
23 23
import javax.persistence.criteria.*;
24
import java.text.ParsePosition;
25
import java.text.SimpleDateFormat;
26 24
import java.util.*;
27 25
28 26
@Slf4j
@ -182,48 +180,54 @@ public class CertifiService extends BaseVerifyService implements ICertifiService
182 180
        repository.saveAll(all);
183 181
    }
184 182
183
    private ClientResWrap getOne(Student student, Certificate cer) {
184
        CopyObjTool.copyProperties(student, cer);
185
        ClientResWrap wrap = new ClientResWrap();
186
        String exam_id = cer.getExam_id();
187
        Exam exam = examRepository.findById(exam_id).get();
188
        wrap.setYear("" + exam.getYear() + "年");
189
        wrap.setExam_name(exam.getExam_name());
190
        wrap.setSeries_name(cer.getSeries_name());
191
        wrap.setLevel_name(cer.getLevel_name());
192
        wrap.setSubject_name(exam.getSubject_name());
193
        wrap.setScore("" + cer.getScore());
194
        wrap.setValidity(cer.getValidity());//有效期 截止日期
195
196
        wrap.setPrint_title("水利部" + wrap.getYear() + "年度职称专业理论知识考试");
197
        wrap.setPrint_certi_num(cer.getCerti_num());
198
        wrap.setPrint_name(cer.getName());
199
        wrap.setPrint_card_num(cer.getCard_num());
200
        wrap.setSeries_name(cer.getSeries_name());
201
        wrap.setLevel_name(cer.getLevel_name());
202
        //合格证的生成日期,转换为汉语大写
203
        Date create_time = cer.getCreate_time();
204
        wrap.setPrint_time(ExamTimeUtil.change(create_time));
205
206
        String endYear = ExamTimeUtil.format(cer.getValidity()).substring(0, 4);
207
        wrap.setPrint_validity("(有效期:" + exam.getYear() + "年~" + endYear + "年)");
208
        return wrap;
209
    }
210
185 211
    public Map myCerti(String student_id) {
186 212
        Student student = studentRepository.findById(student_id).get();
187
        List<Certificate> certificates = repository.myCerti(student_id);
213
        List<Certificate> cers = repository.myCerti(student_id);
188 214
        List<ClientResWrap> list = new ArrayList<>();
189
        for (Certificate cer : certificates) {
190
            CopyObjTool.copyProperties(student, cer);
191
            ClientResWrap wrap = new ClientResWrap();
192
            String exam_id = cer.getExam_id();
193
            Exam exam = examRepository.findById(exam_id).get();
194
            wrap.setYear("" + exam.getYear() + "年");
195
            wrap.setExam_name(exam.getExam_name());
196
            wrap.setSeries_name(cer.getSeries_name());
197
            wrap.setLevel_name(cer.getLevel_name());
198
            wrap.setSubject_name(exam.getSubject_name());
199
            wrap.setScore("" + cer.getScore());
200
            wrap.setValidity(cer.getValidity());//有效期 截止日期
201
202
            wrap.setPrint_title("水利部" + wrap.getYear() + "年度职称专业理论知识考试");
203
            wrap.setPrint_certi_num(cer.getCerti_num());
204
            wrap.setPrint_name(cer.getName());
205
            wrap.setPrint_card_num(cer.getCard_num());
206
            wrap.setSeries_name(cer.getSeries_name());
207
            wrap.setLevel_name(cer.getLevel_name());
208
            //合格证的生成日期,转换为汉语大写
209
            Date create_time = cer.getCreate_time();
210
            wrap.setPrint_time(ExamTimeUtil.change(create_time));
211
            
212
            wrap.setPrint_validity("(有效期:2020年~2022年)");
213
            list.add(wrap);
215
        for (Certificate cer : cers) {
216
            list.add(getOne(student, cer));
214 217
        }
215 218
        Map map = new LinkedHashMap();
216
        map.put("total", certificates.size());
217
        map.put("list", certificates);
219
        map.put("total", list.size());
220
        map.put("list", list);
218 221
        return map;
219 222
    }
220 223
221
    public Certificate myOneCerti(String student_id, String exam_id) {
224
    public ClientResWrap myOneCerti(String student_id, String exam_id) {
225
        Student student = studentRepository.findById(student_id).get();
222 226
        List<Certificate> cers = repository.myOneCerti(student_id, exam_id);
223 227
        if (cers.size() > 0) {
224
            return cers.get(0);
228
            return getOne(student, cers.get(0));
225 229
        }
226
        return new Certificate();
230
        return new ClientResWrap();
227 231
    }
228 232
229 233
}

+ 41 - 5
oa-app/src/main/java/com/css/oa/exam/util/ExamTimeUtil.java

@ -6,6 +6,12 @@ import java.util.Locale;
6 6
7 7
public class ExamTimeUtil {
8 8
9
    public static String format(Date date) {
10
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
11
        String dateString = formatter.format(date);
12
        return dateString;
13
    }
14
9 15
    public static String change(Date date) {
10 16
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
11 17
        String dateString = formatter.format(date);
@ -20,11 +26,9 @@ public class ExamTimeUtil {
20 26
            buffer.append(numToHans(c));
21 27
        }
22 28
        buffer.append("年");
23
        String monthStr = split[1];//"2021"
24
        for (int i = 0; i < monthStr.length(); i++) {
25
            char c = monthStr.charAt(i);
26
            buffer.append(numToHans(c));
27
        }
29
        String monthStr = split[1];//"04"
30
        String s = numToMonth(monthStr);
31
        buffer.append(s);
28 32
        buffer.append("月");
29 33
        return buffer.toString();
30 34
    }
@ -41,4 +45,36 @@ public class ExamTimeUtil {
41 45
        return "";
42 46
    }
43 47
48
    //"04" -> "四"
49
    private static String numToMonth(String monthStr) {
50
        switch (monthStr) {
51
            case "01":
52
                return "一";
53
            case "02":
54
                return "二";
55
            case "03":
56
                return "三";
57
            case "04":
58
                return "四";
59
            case "05":
60
                return "五";
61
            case "06":
62
                return "六";
63
            case "07":
64
                return "七";
65
            case "08":
66
                return "八";
67
            case "09":
68
                return "九";
69
            case "10":
70
                return "十";
71
            case "11":
72
                return "十一";
73
            case "12":
74
                return "十二";
75
            default:
76
                return "零";
77
        }
78
    }
79
44 80
}