zjh
2024-12-25 79f9fbd9f999e26af3f0bca534d825eb687e092c
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ltkj.LtkjApplication;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.DictUserInfo;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.hisDto.OutpintestapplyDetailsDto;
import com.ltkj.hosp.lisDto.LisSaveSqdxxDto;
import com.ltkj.hosp.lisDto.LisSaveSqdxxJyxmlistDto;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.LtkjExamJcbgd;
import com.ltkj.hosp.sqlDomain.LtkjHybgd;
import com.ltkj.hosp.sqlDomain.LtkjHysqd;
import com.ltkj.system.service.ISysDeptService;
import com.ltkj.web.config.pdfutils.PDFBinaryUtil;
import com.ltkj.web.controller.his.HisPDFUtil;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.controller.pacs.PacsApiMethodService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import javax.annotation.Resource;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2024/7/1 15:00
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = LtkjApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Slf4j
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class zwxTest {
    @Autowired
    private ITjOrderService orderService;
    @Autowired
    private ITjCustomerService customerService;
    @Autowired
    private ITjReportTemplateService reportTemplateService;
    @Autowired
    private HisPDFUtil hisPDFUtil;
 
    public static String generateId() {
        String id;
        do {
            // 获取当前时间戳的后几位
            long timestamp = System.currentTimeMillis() % 10000000000L;
            // 随机生成4位数
            int randomNum = new Random().nextInt(9000) + 1000; // 生成1000~9999之间的随机数
            // 拼接时间戳后6位和随机数4位,得到10位数
            id = String.valueOf(timestamp) + randomNum;
        } while (id.startsWith("2"));
        return id;
    }
 
    /**
     * 修改报告
     */
    @Test
    public void uploadPdf(){
        String base64String = PDFBinaryUtil.getPDFBinary("E:\\文档\\报告体检模板new - 首页.pdf");
        System.out.println("base64String = " + base64String);
        TjReportTemplate template = new TjReportTemplate();
        template.setReportTemId(1864937292297244675L);
        template.setTemplate(base64String);
        reportTemplateService.updateById(template);
    }
 
    @Test
    public void uploadzjysqm() throws IOException {
        File file = new File("d:\\Users\\w\\Desktop\\总检医师签名\\ysqm.png");
        FileInputStream fileInputStream = new FileInputStream(file);
        byte[] bytes = new byte[(int) file.length()];
        fileInputStream.read(bytes);
        String string = Base64.getEncoder().encodeToString(bytes);
        LambdaUpdateWrapper<TjReportTemplate> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(TjReportTemplate::getOpen,0);
        wrapper.eq(TjReportTemplate::getFlag,4);
        reportTemplateService.update(wrapper);
        TjReportTemplate template = new TjReportTemplate();
        template.setReportTemId(IdUtil.getSnowflake().nextId());
        template.setTemplate(string);
        template.setCreateTime(new Date());
        template.setCreateBy("超级管理员");
        template.setDeleted(0);
        template.setFlag("4");
        template.setName("总检医师签名");
        template.setRemark("图片必须为PS中画布大小为300*140 PNG透明图");
        template.setOpen("1");
        reportTemplateService.save(template);
    }
 
}