zjh
2024-12-07 148a7f11b0ead8539cae824f02dda19a703f4d0b
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
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.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.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 ITjReportTemplateService tjReportTemplateService;
    @Autowired
    private IDictUserInfoService dictUserInfoService;
    @Resource
    private LtkjExamJcbgdService jcbgdService;
    @Resource
    private LtkjExamJcsqdService jcsqdService;
    @Resource
    private LtkjHybgdService ltkjHybgdService;
    @Resource
    private LtkjHysqdService ltkjHysqdService;
    @Autowired
    private ITbTransitionService tbTransitionService;
    @Autowired
    private ISysDeptService deptService;
    @Autowired
    private ITjProjectService projectService;
    @Autowired
    private LtkjJfzhgljyxmzdService ltkjJfzhgljyxmzdService;
    @Autowired
    private LtkjJfxmgljyxmzdService ltkjJfxmgljyxmzdService;
    @Autowired
    private LtkjJyxmzdService jyxmzdService;
    @Autowired
    private LisApiMethod lisApiMethod;
    @Autowired
    private ITjOrderService orderService;
    @Autowired
    private ITjCustomerService customerService;
    @Autowired
    private PacsApiMethodService pacsApiMethodService;
 
    @Test
    public void test01(){
        // 修改体检模板
        LambdaQueryWrapper<TjReportTemplate> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TjReportTemplate::getReportTemId,1763094589125423105L);
        TjReportTemplate template = tjReportTemplateService.getOne(queryWrapper);
        String s = PDFBinaryUtil.getPDFBinary("D:\\Tjreport\\体检模板5 - 去除首.pdf");
        template.setTemplate(s);
        System.out.println(tjReportTemplateService.updateById(template)); //(BLOB) 537.41 KB
    }
 
    @Test
    public void test02(){
        // 修改医师签名
        LambdaQueryWrapper<DictUserInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DictUserInfo::getId,1762046878778523680L);
        DictUserInfo dictUserInfo = dictUserInfoService.getOne(queryWrapper);
        String s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\蔡丽娴.gif");
        dictUserInfo.setQmImg(s);
        dictUserInfoService.updateById(dictUserInfo);
 
//        queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.eq(DictUserInfo::getId,1814237486088957952L);
//        dictUserInfo = dictUserInfoService.getOne(queryWrapper);
//        s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\曹凌艳.gif");
//        dictUserInfo.setQmImg(s);
//        dictUserInfoService.updateById(dictUserInfo);
 
//        queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.eq(DictUserInfo::getId,1814238293836402688L);
//        dictUserInfo = dictUserInfoService.getOne(queryWrapper);
//        s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\曾志云.gif");
//        dictUserInfo.setQmImg(s);
//        dictUserInfoService.updateById(dictUserInfo);
 
//        queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.eq(DictUserInfo::getId,1814238354339196928L);
//        dictUserInfo = dictUserInfoService.getOne(queryWrapper);
//        s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\陈海红.gif");
//        dictUserInfo.setQmImg(s);
//        dictUserInfoService.updateById(dictUserInfo);
    }
 
    @Test
    public void test03(){
        List<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId("610125200008122217","10001241009165139");
        LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>();
        wq.in(TjProject::getProId, detailList.stream().map(TbTransition::getParentProId).collect(Collectors.toList()));
        wq.in(TjProject::getDeptId,deptService.getJyDeptIds());
        List<TjProject> projects = projectService.list(wq);
        List<OutpintestapplyDetailsDto> detailsDtos = new ArrayList<>();
        if (projects != null && !projects.isEmpty()){
            LisSaveSqdxxDto lisSaveSqdxxDto = new LisSaveSqdxxDto();
            ArrayList<LisSaveSqdxxJyxmlistDto> dtos = new ArrayList<>();
            BigDecimal allPrice = new BigDecimal("0");
            int xh = 0;
            for (TjProject project : projects) {
                if (0 == project.getProParentId() && project.getProPrice().compareTo(BigDecimal.ZERO) != 0) {
                    if (null != project.getHisXmbm()) {
                        allPrice.add(project.getProPrice());
                        LambdaQueryWrapper<LtkjJfzhgljyxmzd> wrapper = new LambdaQueryWrapper<>();
                        wrapper.eq(LtkjJfzhgljyxmzd::getZhxmdm, project.getHisXmbm());
                        LtkjJfzhgljyxmzd jfzhgljyxmzd = ltkjJfzhgljyxmzdService.getOne(wrapper);
                        if (jfzhgljyxmzd != null) {
                            LambdaQueryWrapper<LtkjJyxmzd> wrapper1 = new LambdaQueryWrapper<>();
                            wrapper1.eq(LtkjJyxmzd::getJyxmdm,jfzhgljyxmzd.getJyxmdm());
                            LtkjJyxmzd jyxmzd = jyxmzdService.getOne(wrapper1);
                            System.out.println("jyxmzd.getJybbdm() = " + jyxmzd.getJybbdm());
                            LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto();
                            dto.setXh(String.valueOf(xh++));
                            dto.setJyxm(jfzhgljyxmzd.getJyxmdm());
                            dto.setXmmc(jfzhgljyxmzd.getZhxmmc());
                            dtos.add(dto);
 
                            OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto();
                            detailsDto.setMxfyxmbm(project.getHisXmbm());
                            if (project.getSfzhfy().equals("Y")) {
                                detailsDto.setSfzhfy("1");
                            } else {
                                detailsDto.setSfzhfy("0");
                            }
                            detailsDto.setSl(project.getSl());
                            detailsDto.setProjg(project.getProPrice());
                            detailsDtos.add(detailsDto);
                        }else {
                            LambdaQueryWrapper<LtkjJfxmgljyxmzd> wrapper1 = new LambdaQueryWrapper<>();
                            wrapper1.eq(LtkjJfxmgljyxmzd::getXmdm, project.getHisXmbm());
                            LtkjJfxmgljyxmzd jfxmgljyxmzd = ltkjJfxmgljyxmzdService.getOne(wrapper1);
                            if (jfxmgljyxmzd != null) {
                                LambdaQueryWrapper<LtkjJyxmzd> wrapper2 = new LambdaQueryWrapper<>();
                                wrapper2.eq(LtkjJyxmzd::getJyxmdm,jfxmgljyxmzd.getJyxmdm());
                                LtkjJyxmzd jyxmzd = jyxmzdService.getOne(wrapper2);
                                System.out.println("jyxmzd.getJybbdm() = " + jyxmzd.getJybbdm());
                                LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto();
                                dto.setXh(String.valueOf(xh++));
                                dto.setJyxm(jfxmgljyxmzd.getJyxmdm());
                                dto.setXmmc(jfxmgljyxmzd.getXmmc());
                                dtos.add(dto);
 
                                OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto();
                                detailsDto.setMxfyxmbm(project.getHisXmbm());
                                if (project.getSfzhfy().equals("Y")) {
                                    detailsDto.setSfzhfy("1");
                                } else {
                                    detailsDto.setSfzhfy("0");
                                }
                                detailsDto.setSl(project.getSl());
                                detailsDto.setProjg(project.getProPrice());
                                detailsDtos.add(detailsDto);
                            }
                        }
                    }
                }
            }
        }
    }
 
    @Test
    public void test04(){
        String cusId = "610622199805230627";
        String cardId = "10001241010163121";
        // 检验保存
        List<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId(cusId,cardId);
        TjOrder tjOrder = orderService.getOrderByTjNum(detailList.get(0).getTjNum());
        LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TjCustomer::getCusIdcard,cusId);
        TjCustomer customer = customerService.getOne(wrapper);
//        lisApiMethod.save(tjOrder,customer,detailList);
        // 检验作废
//        lisApiMethod.cancel("",tjOrder.getCardId(),customer.getCusName());
        // 检查保存
        pacsApiMethodService.save(tjOrder,customer,detailList);
        // 检查作废
        pacsApiMethodService.updatePacsApply("","",customer.getCusName());
    }
 
    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;
    }
 
    public static void main01(String[] args) {
//        LtkjExamJcbgd jcbgd = new LtkjExamJcbgd();
//        jcbgd.setJcbw("1");
//        jcbgd.setBgImg("1");
//        jcbgd.setBgNr("1");
//        jcbgd.setBgUrl("1");
//        jcbgd.setShysdm("1");
//        jcbgd.setShysxm("1");
//        jcbgd.setSqsj("1");
//        jcbgd.setTjh("1");
//        Map<String, Object> map = BeanUtil.beanToMap(jcbgd, true, true);
//        System.out.println("map = " + map);
//        System.out.println(IdUtil.getSnowflake().nextIdStr());
//        String format = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
//        System.out.println("format = " + format);
//        String s = String.valueOf(RandomUtil.randomInt(1000, 9999));
//        System.out.println("s = " + s);
//        format+=s;
//        System.out.println("format = " + format);
//        System.out.println(format.length());
//        String str = "3";
//
//        List<String> list = Arrays.asList(str.split(","));
//        if (list.contains("3")){
//            System.out.println("1");
//        }else {
//            System.out.println("0");
//        }
//        String millis = String.valueOf(System.currentTimeMillis());
//        System.out.println("millis = " + millis);
//        System.out.println(RandomUtil.randomString(millis, 3));
//        String yyyyMMdd = new SimpleDateFormat("yyyyMMdd").format(new Date());
//        String sqdh = "3"+yyyyMMdd.substring(2)+ RandomUtil.randomString(String.valueOf(System.currentTimeMillis()), 3);
//        System.out.println("sqdh = " + sqdh);
        String yyyyMMdd = new SimpleDateFormat("yyMMdd").format(new Date());
        Random random = new Random();
        int firstDigit = random.nextInt(9) + 1;
        while (firstDigit == 2) {
            firstDigit = random.nextInt(9) + 1;
        }
        int randomLastTwo = random.nextInt(100);
        String sqdh = String.format("%d%s%02d", firstDigit, yyyyMMdd, randomLastTwo);
        System.out.println("sqdh = " + sqdh);
    }
 
    public static void main(String[] args) {
        String list = "<List>";
        for (int i = 0; i < 2; i++) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("index",RandomUtil.randomInt(1,10));
            list+=XmlUtil.mapToXmlStr(map).replace("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>","")
                    .replace("<xml>","").replace("</xml>","");
        }
        list+="</List>";
        HashMap<String, Object> map = new HashMap<>();
        map.put("Root",list);
        System.out.println(XmlUtil.mapToXmlStr(map).replaceAll("&lt;","<").replaceAll("&gt;",">"));
    }
}