zjh
2024-12-31 9b6f602df09c5e39481f03e22d99fffe825b9393
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.ltkj.web.controller.readIdCard;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.service.ITjCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zjh
 * @Date: 2023/2/16 10:20
 */
@Api(tags = "读取身份证信息")
@RestController
@RequestMapping("/read")
@Slf4j
public class readIdCardController {
    @Resource
    private ITjCustomerService customerService;
 
    /**
     * 查询小程序主页轮播图列表
     */
    @GetMapping
    @ApiOperation(value = "读取身份证信息接口")
    public AjaxResult getIdCard() {
        byte sid[] = new byte[37];
        byte name[] = new byte[31];
        byte sex[] = new byte[3];
        byte folk[] = new byte[10];
        byte birth[] = new byte[9];
        byte code[] = new byte[19];
        byte add[] = new byte[71];
        byte agency[] = new byte[31];
        byte expirestart[] = new byte[9];
        byte expireend[] = new byte[9];
        int ret = 0;
 
        if (CLibrary.sdtapi.InitComm(1001) == 1) {
            log.info("connect OK! 连接成功!!!!!");
            ret = CLibrary.sdtapi.GetSAMIDToStr(sid);
            if (ret != 1) {
                log.info("GetSAMIDToStr=" + ret);
                return null;
            }
            while (true) {
                ret = CLibrary.sdtapi.Authenticate();
                if (ret == 1) {
                    log.info("======================================");
                    ret = CLibrary.sdtapi.ReadBaseInfosPhoto(name, sex, folk, birth, code, add, agency, expirestart, expireend, null);
                    if (ret != 1) {
                        return AjaxResult.success(null);
                    }
//                    CLibrary.sdtapi.HID_BeepLED(true,true,50);
//                    CLibrary.sdtapi.HID_BeepLED(false,false,50);
//                    CLibrary.sdtapi.HID_BeepLED(true,true,50);
                    String s = new String(name);
                    log.info(s.substring(0, s.length() - 1).trim());
                    String s1 = new String(sex);
                    log.info(s1.substring(0, s1.length() - 1).trim());
                    String s2 = new String(folk);
                    log.info(s2.substring(0, s2.length() - 1).trim());
                    String s3 = new String(birth);
                    log.info(s3.substring(0, s3.length() - 1).trim());
                    String s4 = new String(code);
                    log.info(s4.substring(0, s4.length() - 1).trim());
                    String s5 = new String(add);
                    log.info(s5.substring(0, s5.length() - 1).trim());
                    String s6 = new String(agency);
                    log.info(s6.substring(0, s6.length() - 1).trim());
                    String s7 = new String(expirestart);
                    log.info(s7.substring(0, s7.length() - 1).trim());
                    String s8 = new String(expireend);
                    log.info(s8.substring(0, s8.length() - 1).trim());
                    LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
                    wq.eq(TjCustomer::getCusIdcard, code);
                    TjCustomer one = customerService.getOne(wq);
                    if (null == one) {
                        log.info("数据库没有" + s.substring(0, s.length() - 1).trim() + "的信息");
                    }
                    return AjaxResult.success(s.substring(0, s.length() - 1).trim(), one);
                }
            }
        } else {
            return AjaxResult.error();
        }
    }
 
}