package com.docus.server;


import cn.hutool.extra.spring.SpringUtil;
import com.docus.server.archive.entity.TBasic;
import com.docus.server.archive.mapper.TBasicMapper;
import com.docus.server.archive.utils.PingYinUtil;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

import java.util.Arrays;
import java.util.Date;
import java.util.Properties;


/**
 * @author wyb
 */
@Slf4j
@SpringBootApplication(scanBasePackages ={"com.docus"})
@MapperScan("com.docus.server.**.mapper")
@EnableFeignClients(basePackages = {"com.docus"})
public class AppRunBootstrap {
    public static void main(String[] args) {
        Properties props = System.getProperties();
        props.setProperty("org.apache.cxf.stax.allowInsecureParser", "1");
        props.setProperty("UseSunHttpHandler", "true");
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");

        SpringApplication.run(AppRunBootstrap.class, args);
    }

    static void testMysql(){
        TBasicMapper mapper = SpringUtil.getBean(TBasicMapper.class);
        long currentTimeMillis = System.currentTimeMillis();
        TBasic tBasic1 = new TBasic();
        tBasic1.setPatientId("FS-TEST-1");
        tBasic1.setJzh("jzh"+ currentTimeMillis);
        tBasic1.setInpatientNo(currentTimeMillis +"");
        tBasic1.setAdmissTimes(1);
        tBasic1.setName("佛山测试1");
        tBasic1.setNameSpell(PingYinUtil.getFirstSpell("佛山测试1"));
        tBasic1.setSex("1");
        tBasic1.setSexName("男");
        tBasic1.setAdmissDate(new Date());
        tBasic1.setAdmissDept("221");
        tBasic1.setAdmissDeptName("神经内科");
        tBasic1.setBedNo("神经内科1-1");
        tBasic1.setAttending("wyb");
        tBasic1.setAttendingName("文永斌");
        tBasic1.setAge(50);
        tBasic1.setAgeMonth(12);
        tBasic1.setAgeDay(3);
        tBasic1.setIdCard("xxxxxx");
        tBasic1.setTelphone("666");
        tBasic1.setDisDate(new Date());
        tBasic1.setDisDept("221");
        tBasic1.setDisDeptName("神经内科");
        tBasic1.setTotalCost("28.8");
        tBasic1.setIsDead(0);
        tBasic1.setJzCardNo("kh1998");
        tBasic1.setFileSource(1);
        tBasic1.setCreateTime(new Date());
        tBasic1.setUpdateTime(new Date());
        TBasic tBasic2 = new TBasic();
        BeanUtils.copyProperties(tBasic1,tBasic2);
        tBasic2.setPatientId("FS-TEST-2");
        tBasic2.setAdmissTimes(2);
        tBasic2.setJzh("jzh"+(currentTimeMillis+555));
        mapper.insertBatch(Arrays.asList(tBasic1,tBasic2));
        System.out.println("插入后："+mapper.getByJzh(Arrays.asList(tBasic1.getJzh(),tBasic2.getJzh())));
        tBasic1.setIdCard("modify-1");
        tBasic2.setIdCard("modify-2");
        mapper.updateBatch(Arrays.asList(tBasic1,tBasic2));

        System.out.println("修改后："+mapper.getByJzh(Arrays.asList(tBasic1.getJzh(),tBasic2.getJzh())));

    }
}
