package com.ruoyi.web.work.api;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.work.domain.DeptInfo;
import com.ruoyi.web.work.domain.EmployeeInfo;
import com.ruoyi.web.work.domain.WardInfo;
import com.ruoyi.web.work.service.IDeptInfoService;
import com.ruoyi.web.work.service.IEmployeeInfoService;
import com.ruoyi.web.work.service.IWardInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 回访模板管理
 *
 * @author lsw
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/public")
public class Api_MdmController {

    @Autowired
    private IWardInfoService wardInfoService;

    @Autowired
    private IEmployeeInfoService employeeInfoService;

    @Autowired
    private IDeptInfoService deptInfoService;

    @Autowired
    private ISysDeptService deptService;

    @Autowired
    private ISysUserService userService;

    @Anonymous
    @Log(title = "变更通知接收服务", businessType = BusinessType.INSERT)
    @PostMapping("/acceptNotice")
    public AjaxResult acceptNotice(@RequestHeader  Map<String,String> headMap,
                                   @RequestBody  String requestBody,HttpServletResponse response) {
        AjaxResult ajax = new AjaxResult();
        String ackCode="300.1";
        String ackMessage="接收失败";
        boolean issuccess=false;
        System.out.println("head: " + headMap.toString());
        System.out.println("Request Body: " + requestBody);
        //处理body数据
        requestBody = replaceNullInRequestBody(requestBody);
        JSONObject jsonBodyObject = new JSONObject(requestBody);
        JSONObject jsonRequest = new JSONObject(jsonBodyObject.get("Request"));
        //处理Head数据
        JSONObject jsonHead =new JSONObject(jsonRequest.get("Head"));
        String version=jsonHead.get("Version").toString();
        String orgId=jsonHead.get("OrgId").toString();
        String appId=jsonHead.get("AppId").toString();
        String recOrgId=jsonHead.get("RecOrgId").toString();
        String recAppId=jsonHead.get("RecAppId").toString();
        String messageId=jsonHead.get("MessageId").toString();
        String trancode=jsonHead.get("TranCode").toString();
        //处理Body数据
        JSONObject jsonBody = new JSONObject(jsonRequest.get("Body"));
        JSONObject jsonObject = new JSONObject(jsonBody.get("DataItem"));

        if (trancode.equals("WardInfo")){
            QueryWrapper<WardInfo> queryWrapper = new QueryWrapper<>();
            String wardCode=jsonObject.get("wardCode").toString();
            queryWrapper.eq("ward_code", wardCode);
            int totalWardInfo =wardInfoService.count(queryWrapper);
            issuccess=setWardInfo(totalWardInfo,jsonObject);
        }else if(trancode.equals("EmployeeInfo")){
            /*QueryWrapper<EmployeeInfo> queryWrapper = new QueryWrapper<>();
            String employeeId=jsonObject.get("employeeId").toString();
            queryWrapper.eq("employee_id", employeeId);
            int totalWardInfo =employeeInfoService.count(queryWrapper);
            issuccess=setEmployeeInfo(totalWardInfo,jsonObject);*/
            QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
            String employeeId=jsonObject.get("employeeId").toString();
            queryWrapper.eq("employee_id", employeeId);
            int totalWardInfo =userService.count(queryWrapper);
            issuccess=setEmployeeInfo1(totalWardInfo,jsonObject);
        }else if(trancode.equals("DeptInfo")){
            /*QueryWrapper<DeptInfo> queryWrapper = new QueryWrapper<>();
            String deptCode=jsonObject.get("deptCode").toString();
            queryWrapper.eq("dept_code", deptCode);
            int totalWardInfo =deptInfoService.count(queryWrapper);
            issuccess=setDeptInfo(totalWardInfo,jsonObject);*/
            QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
            String deptCode=jsonObject.get("deptCode").toString();
            queryWrapper.eq("dept_code", deptCode);
            int totalWardInfo =deptService.count(queryWrapper);
            issuccess=setDeptInfo1(totalWardInfo,jsonObject);
        }else{
            ackCode="100.5";
            ackMessage="参数错误";
        }
        if(issuccess){
            ackCode="100.1";
            ackMessage="接收成功";
        }
        //返回响应结果
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        String timestamp=dateFormat.format(new Date());
        HashMap<String, Object> requestData=new HashMap<>();
        HashMap<String, Object> headData=new HashMap<>();
        headData.put("Version",version);
        headData.put("AckCode",ackCode);
        headData.put("AckMessage",ackMessage);
        headData.put("ContentType","text/json");
        headData.put("OrgId",orgId);
        headData.put("AppId",appId);
        headData.put("RecOrgId",recOrgId);
        headData.put("RecAppId",recAppId);
        headData.put("MessageId",messageId);
        headData.put("Timestamp",timestamp);
        requestData.put("Head",headData);
        ajax.put("Response",requestData);
        return ajax;
    }

    /*
    * 添加或修改病区信息
    * */
    private boolean setWardInfo(int count,JSONObject jsonObject){
        WardInfo wardInfo=new WardInfo();
        wardInfo.setOrgCode(jsonObject.get("orgCode").toString());
        wardInfo.setWardCode(jsonObject.get("wardCode").toString());
        wardInfo.setWardName(jsonObject.get("wardName").toString());
        wardInfo.setPy(jsonObject.get("py").toString());
        wardInfo.setWb(jsonObject.get("wb").toString());
        wardInfo.setInputCode(jsonObject.get("inputCode").toString());
        String bedNumber=jsonObject.get("bedNumber").toString();
        if(bedNumber!=null&&bedNumber!=""&&!bedNumber.equals("null")&&!bedNumber.isEmpty()){
            wardInfo.setBedNumber(Long.valueOf(bedNumber));
        }
        wardInfo.setWardTypeCode(jsonObject.get("wardTypeCode").toString());
        wardInfo.setHomeBedSign(jsonObject.get("homeBedSign").toString());
        wardInfo.setSpecialWardSign(jsonObject.get("specialWardSign").toString());
        wardInfo.setMemo(jsonObject.get("memo").toString());
        wardInfo.setValidStartDTime(jsonObject.get("validStartDTime").toString());
        wardInfo.setValidEndDTime(jsonObject.get("validEndDTime").toString());
        wardInfo.setActiveSign(jsonObject.get("activeSign").toString());
        wardInfo.setVerNo(jsonObject.get("verNo").toString());
        wardInfo.setOrderno(jsonObject.get("ORDERNO").toString());
        boolean issuccess=false;
        if(count>0){
            //修改
            wardInfo.setUpdateBy("admin");
            wardInfo.setUpdateTime(new Date());
            QueryWrapper<WardInfo> whereWrapper = new QueryWrapper<>();
            whereWrapper.eq("ward_code", wardInfo.getWardCode());
            boolean result = wardInfoService.update(wardInfo, whereWrapper);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }else{
            //添加
            wardInfo.setCreateBy("admin");
            wardInfo.setCreateTime(new Date());
            boolean result = wardInfoService.save(wardInfo);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }
        return issuccess;
    }

    /*
     * 添加或修改职工信息
     * */
    private boolean setEmployeeInfo(int count,JSONObject jsonObject){
        EmployeeInfo employeeInfo=new EmployeeInfo();
        employeeInfo.setOrgCode(jsonObject.get("orgCode").toString());
        employeeInfo.setEmployeeId(jsonObject.get("employeeId").toString());
        employeeInfo.setEmployeeName(jsonObject.get("employeeName").toString());
        employeeInfo.setPy(jsonObject.get("py").toString());
        employeeInfo.setWb(jsonObject.get("wb").toString());
        employeeInfo.setInputCode(jsonObject.get("inputCode").toString());
        if(jsonObject.get("genderCode") instanceof Number){
            employeeInfo.setGenderCode(((Number) jsonObject.get("genderCode")).intValue());
        }else {
            employeeInfo.setGenderCode(0);
        }
        employeeInfo.setGenderName(jsonObject.get("genderName").toString());
        employeeInfo.setBirthDate(jsonObject.get("birthDate").toString());
        if(jsonObject.get("maritalStatusCode") instanceof Number){
            employeeInfo.setMaritalStatusCode(((Number) jsonObject.get("maritalStatusCode")).intValue());
        }else {
            employeeInfo.setMaritalStatusCode(0);
        }
        if(jsonObject.get("IDTypeCode") instanceof Number){
            employeeInfo.setIdTypeCode(((Number) jsonObject.get("IDTypeCode")).intValue());
        }else {
            employeeInfo.setIdTypeCode(0);
        }
        employeeInfo.setIdNo(jsonObject.get("IDNo").toString());
        employeeInfo.setDeptCode(jsonObject.get("deptCode").toString());
        employeeInfo.setDeptName(jsonObject.get("deptName").toString());
        employeeInfo.setAdminDeptCode(jsonObject.get("adminDeptCode").toString());
        employeeInfo.setAdminDeptName(jsonObject.get("adminDeptName").toString());
        employeeInfo.setWardCode(jsonObject.get("wardCode").toString());
        employeeInfo.setWardName(jsonObject.get("wardName").toString());
        if(jsonObject.get("employeeTypeCode") instanceof Number){
            employeeInfo.setEmployeeTypeCode(((Number) jsonObject.get("employeeTypeCode")).intValue());
        }else {
            employeeInfo.setEmployeeTypeCode(0);
        }
        if(jsonObject.get("techPositionCode") instanceof Number){
            employeeInfo.setTechPositionCode(((Number) jsonObject.get("techPositionCode")).intValue());
        }else {
            employeeInfo.setTechPositionCode(0);
        }
        employeeInfo.setTechPositionName(jsonObject.get("techPositionName").toString());
        employeeInfo.setTelephone(jsonObject.get("telephone").toString());
        employeeInfo.setSupDoctorCode(jsonObject.get("supDoctorCode").toString());
        employeeInfo.setSupDoctorName(jsonObject.get("supDoctorName").toString());
        employeeInfo.setMedDocCode(jsonObject.get("medDocCode").toString());
        employeeInfo.setDirDocSign(jsonObject.get("dirDocSign").toString());
        employeeInfo.setPresRightSign(jsonObject.get("presRightSign").toString());
        employeeInfo.setAnesPresRightSign(jsonObject.get("anesPresRightSign").toString());
        employeeInfo.setSpecRegFee(jsonObject.get("specRegFee").toString());
        if(jsonObject.get("limitNumber") instanceof Number){
            employeeInfo.setLimitNumber(((Number) jsonObject.get("limitNumber")).intValue());
        }else {
            employeeInfo.setLimitNumber(0);
        }
        employeeInfo.setPresChapterNo(jsonObject.get("presChapterNo").toString());
        employeeInfo.setMemo(jsonObject.get("memo").toString());
        if(jsonObject.get("amLimitNo") instanceof Number){
            employeeInfo.setAmLimitNo(((Number) jsonObject.get("amLimitNo")).intValue());
        }else {
            employeeInfo.setAmLimitNo(0);
        }
        if(jsonObject.get("pmLimitNo") instanceof Number){
            employeeInfo.setPmLimitNo(((Number) jsonObject.get("pmLimitNo")).intValue());
        }else {
            employeeInfo.setPmLimitNo(0);
        }
        employeeInfo.setModifiedPresSign(jsonObject.get("modifiedPresSign").toString());
        employeeInfo.setElecPresRight(jsonObject.get("elecPresRight").toString());
        employeeInfo.setNoonLimitNo(jsonObject.get("noonLimitNo").toString());
        employeeInfo.setEmergencyRegFee(jsonObject.get("emergencyRegFee").toString());
        employeeInfo.setEmergencyMedFee(jsonObject.get("emergencyMedFee").toString());
        employeeInfo.setEmergencyTreatFee(jsonObject.get("emergencyTreatFee").toString());
        String degreeCode=jsonObject.get("degreeCode").toString();
        if(degreeCode!=null&&degreeCode!=""&&!degreeCode.equals("null")&&!degreeCode.isEmpty()){
            employeeInfo.setDegreeCode(Long.valueOf(degreeCode));
        }
        employeeInfo.setPhotoUrl(jsonObject.get("photoUrl").toString());
        employeeInfo.setSignatureGraph(jsonObject.get("signatureGraph").toString());
        employeeInfo.setValidStartDTime(jsonObject.get("validStartDTime").toString());
        employeeInfo.setValidEndDTime(jsonObject.get("validEndDTime").toString());
        employeeInfo.setActiveSign(jsonObject.get("activeSign").toString());
        employeeInfo.setVerNo(jsonObject.get("verNo").toString());
        employeeInfo.setEmployeePassword(jsonObject.get("employeePassword").toString());
        employeeInfo.setBmjb(jsonObject.get("bmjb").toString());
        employeeInfo.setGwdm(jsonObject.get("gwdm").toString());
        employeeInfo.setGwmc(jsonObject.get("gwmc").toString());
        employeeInfo.setGhf(jsonObject.get("ghf").toString());
        employeeInfo.setZlf(jsonObject.get("zlf").toString());
        employeeInfo.setWzzxbz(jsonObject.get("wzzxbz").toString());
        employeeInfo.setYsjb(jsonObject.get("ysjb").toString());
        employeeInfo.setIsmsg(jsonObject.get("ismsg").toString());
        employeeInfo.setSszcId(jsonObject.get("sszc_id").toString());
        employeeInfo.setSszcMc(jsonObject.get("sszc_mc").toString());
        employeeInfo.setCzry(jsonObject.get("czry").toString());
        employeeInfo.setZxysdm(jsonObject.get("zxysdm").toString());
        employeeInfo.setMzTfbz(jsonObject.get("mz_tfbz").toString());
        employeeInfo.setSsfl(jsonObject.get("ssfl").toString());
        employeeInfo.setZxksdm(jsonObject.get("zxksdm").toString());
        employeeInfo.setIpaddress(jsonObject.get("ipaddress").toString());
        employeeInfo.setSfyy(jsonObject.get("sfyy").toString());
        employeeInfo.setYxj(jsonObject.get("yxj").toString());
        employeeInfo.setIszkhs(jsonObject.get("iszkhs").toString());
        employeeInfo.setZzghbz(jsonObject.get("zzghbz").toString());
        employeeInfo.setSfxh(jsonObject.get("sfxh").toString());
        employeeInfo.setTxbz(jsonObject.get("txbz").toString());
        employeeInfo.setKsscfq(jsonObject.get("ksscfq").toString());
        employeeInfo.setZyzz(jsonObject.get("zyzz").toString());
        employeeInfo.setSjdpbbz(jsonObject.get("sjdpbbz").toString());
        employeeInfo.setMxpbbz(jsonObject.get("mxpbbz").toString());
        employeeInfo.setFzhxqz(jsonObject.get("fzhxqz").toString());
        employeeInfo.setLsgbz(jsonObject.get("lsgbz").toString());
        employeeInfo.setKzlywcfq(jsonObject.get("kzlywcfq").toString());
        employeeInfo.setCwyyywcfq(jsonObject.get("cwyyywcfq").toString());
        employeeInfo.setSqxtypbz(jsonObject.get("sqxtypbz").toString());
        employeeInfo.setZkxtypbz(jsonObject.get("zkxtypbz").toString());
        employeeInfo.setSsyzqx(jsonObject.get("ssyzqx").toString());
        employeeInfo.setZgkh(jsonObject.get("zgkh").toString());
        employeeInfo.setIsdbrqx(jsonObject.get("isdbrqx").toString());
        employeeInfo.setJsry1(jsonObject.get("jsry1").toString());
        employeeInfo.setZgjj(jsonObject.get("zgjj").toString());
        employeeInfo.setJylcfq(jsonObject.get("jylcfq").toString());
        employeeInfo.setJelcfq(jsonObject.get("jelcfq").toString());
        employeeInfo.setJdlcfq(jsonObject.get("jdlcfq").toString());
        employeeInfo.setBmcfzxysdm(jsonObject.get("bmcfzxysdm").toString());
        employeeInfo.setJsypcfq(jsonObject.get("jsypcfq").toString());
        employeeInfo.setXcfsyq(jsonObject.get("xcfsyq").toString());
        employeeInfo.setFzyyspq(jsonObject.get("fzyyspq").toString());
        employeeInfo.setSzyzq(jsonObject.get("szyzq").toString());
        employeeInfo.setQkysq(jsonObject.get("qkysq").toString());
        employeeInfo.setXgbjxhtyxq(jsonObject.get("xgbjxhtyxq").toString());
        employeeInfo.setYzfsq(jsonObject.get("yzfsq").toString());
        employeeInfo.setYzfscxq(jsonObject.get("yzfscxq").toString());
        employeeInfo.setBlbjq(jsonObject.get("blbjq").toString());
        employeeInfo.setHzq(jsonObject.get("hzq").toString());
        employeeInfo.setGbys(jsonObject.get("gbys").toString());
        employeeInfo.setZycfq(jsonObject.get("zycfq").toString());
        employeeInfo.setMzcfq(jsonObject.get("mzcfq").toString());
        employeeInfo.setFsypcfq(jsonObject.get("fsypcfq").toString());
        employeeInfo.setJhsyypcfq(jsonObject.get("jhsyypcfq").toString());
        employeeInfo.setCkfsgbqx(jsonObject.get("ckfsgbqx").toString());
        employeeInfo.setPxyxj(jsonObject.get("pxyxj").toString());
        employeeInfo.setGbysbz(jsonObject.get("gbysbz").toString());
        employeeInfo.setMfhs(jsonObject.get("mfhs").toString());
        employeeInfo.setXlMc(jsonObject.get("xl_mc").toString());
        employeeInfo.setXwId(jsonObject.get("xw_id").toString());
        employeeInfo.setXwMc(jsonObject.get("xw_mc").toString());
        employeeInfo.setSfzzyy(jsonObject.get("sfzzyy").toString());
        employeeInfo.setWjztxbz(jsonObject.get("wjztxbz").toString());
        employeeInfo.setYbysbz(jsonObject.get("ybysbz").toString());
        employeeInfo.setGjycfq(jsonObject.get("gjycfq").toString());
        employeeInfo.setIsscpt(jsonObject.get("isscpt").toString());
        employeeInfo.setDbcfq(jsonObject.get("dbcfq").toString());
        employeeInfo.setRzrq(jsonObject.get("rzrq").toString());
        employeeInfo.setLzrq(jsonObject.get("lzrq").toString());
        employeeInfo.setKxgypzd(jsonObject.get("kxgypzd").toString());
        if(jsonObject.get("bkxgypzd") instanceof Number){
            employeeInfo.setBkxgypzd(((Number) jsonObject.get("bkxgypzd")).intValue());
        }else {
            employeeInfo.setBkxgypzd(0);
        }
        employeeInfo.setYszgzbm(jsonObject.get("yszgzbm").toString());
        employeeInfo.setYszyzbm(jsonObject.get("yszyzbm").toString());
        employeeInfo.setZwId(jsonObject.get("zw_id").toString());
        employeeInfo.setZwMc(jsonObject.get("zw_mc").toString());
        employeeInfo.setMdmphoto(jsonObject.get("mdmphoto").toString());
        employeeInfo.setDlhsbz(jsonObject.get("dlhsbz").toString());
        employeeInfo.setYszcbh(jsonObject.get("yszcbh").toString());
        employeeInfo.setYszyfw(jsonObject.get("yszyfw").toString());
        employeeInfo.setHszybh(jsonObject.get("hszybh").toString());
        employeeInfo.setZgsc(jsonObject.get("zgsc").toString());
        employeeInfo.setZglx(jsonObject.get("zglx").toString());
        employeeInfo.setCfqz(jsonObject.get("cfqz").toString());
        employeeInfo.setMzlycfqz(jsonObject.get("mzlycfqz").toString());
        employeeInfo.setXycflrqz(jsonObject.get("xycflrqz").toString());
        employeeInfo.setZycflrqz(jsonObject.get("zycflrqz").toString());
        employeeInfo.setCycflrqz(jsonObject.get("cycflrqz").toString());
        employeeInfo.setJslycfqz(jsonObject.get("jslycfqz").toString());
        employeeInfo.setJdlycfqz(jsonObject.get("jdlycfqz").toString());
        employeeInfo.setFzyyspqz(jsonObject.get("fzyyspqz").toString());
        employeeInfo.setXcfsyqxz(jsonObject.get("xcfsyqxz").toString());
        employeeInfo.setSzyzqxz(jsonObject.get("szyzqxz").toString());
        employeeInfo.setQkysqxz(jsonObject.get("qkysqxz").toString());
        employeeInfo.setXgbjxhtyxqxz(jsonObject.get("xgbjxhtyxqxz").toString());
        employeeInfo.setYssfyyzfsqxz(jsonObject.get("yssfyyzfsqxz").toString());
        employeeInfo.setXghqxzdbrsbqz(jsonObject.get("xghqxzdbrsbqz").toString());
        employeeInfo.setFyxxdydcqz(jsonObject.get("fyxxdydcqz").toString());
        employeeInfo.setDbybcfqz(jsonObject.get("dbybcfqz").toString());
        employeeInfo.setJylyfqz(jsonObject.get("jylyfqz").toString());
        employeeInfo.setGjycfqz(jsonObject.get("gjycfqz").toString());
        employeeInfo.setZzrsyycfqz(jsonObject.get("zzrsyycfqz").toString());
        employeeInfo.setCplyycfqz(jsonObject.get("cplyycfqz").toString());
        employeeInfo.setTpsjsyycfqz(jsonObject.get("tpsjsyycfqz").toString());
        employeeInfo.setXyzjyycfqz(jsonObject.get("xyzjyycfqz").toString());
        employeeInfo.setYyjsyycfqz(jsonObject.get("yyjsyycfqz").toString());
        employeeInfo.setMyzqyycfqz(jsonObject.get("myzqyycfqz").toString());
        employeeInfo.setKzlywcfqz(jsonObject.get("kzlywcfqz").toString());
        employeeInfo.setYlqtcfqz(jsonObject.get("ylqtcfqz").toString());
        employeeInfo.setYzfscxqz(jsonObject.get("yzfscxqz").toString());
        employeeInfo.setBlbjqz(jsonObject.get("blbjqz").toString());
        employeeInfo.setHzqz(jsonObject.get("hzqz").toString());
        employeeInfo.setBlzhcxdydcqz(jsonObject.get("blzhcxdydcqz").toString());
        employeeInfo.setEmrblcxqz(jsonObject.get("emrblcxqz").toString());
        employeeInfo.setBltjqz(jsonObject.get("bltjqz").toString());
        employeeInfo.setCsqz(jsonObject.get("csqz").toString());
        employeeInfo.setKsscfqz(jsonObject.get("ksscfqz").toString());
        employeeInfo.setDbrqxz(jsonObject.get("dbrqxz").toString());
        employeeInfo.setCwyyycfqz(jsonObject.get("cwyyycfqz").toString());
        employeeInfo.setJelycfqz(jsonObject.get("jelycfqz").toString());
        employeeInfo.setMzcfqz(jsonObject.get("mzcfqz").toString());
        employeeInfo.setZycfqz(jsonObject.get("zycfqz").toString());
        employeeInfo.setFsypcfqz(jsonObject.get("fsypcfqz").toString());
        employeeInfo.setCkfsgbqz(jsonObject.get("ckfsgbqz").toString());
        employeeInfo.setSfnkssyzz(jsonObject.get("sfnkssyzz").toString());
        employeeInfo.setJhsyypcfqz(jsonObject.get("jhsyypcfqz").toString());
        employeeInfo.setZlxmcfqz(jsonObject.get("zlxmcfqz").toString());
        employeeInfo.setTbcfq(jsonObject.get("tbcfq").toString());
        employeeInfo.setYjkscxq(jsonObject.get("yjkscxq").toString());
        employeeInfo.setEjkscxq(jsonObject.get("ejkscxq").toString());
        employeeInfo.setYwsyq(jsonObject.get("ywsyq").toString());
        employeeInfo.setYbcfq(jsonObject.get("ybcfq").toString());
        employeeInfo.setYydxyqcfq(jsonObject.get("yydxyqcfq").toString());
        employeeInfo.setYlqtlcfq(jsonObject.get("ylqtlcfq").toString());
        employeeInfo.setHzyqq(jsonObject.get("hzyqq").toString());
        employeeInfo.setHzchq(jsonObject.get("hzchq").toString());
        employeeInfo.setSqyxqx(jsonObject.get("sqyxqx").toString());
        employeeInfo.setKsxdfwhqx(jsonObject.get("ksxdfwhqx").toString());
        employeeInfo.setQyxdfwhqx(jsonObject.get("qyxdfwhqx").toString());
        employeeInfo.setQygmxxzfqx(jsonObject.get("qygmxxzfqx").toString());
        employeeInfo.setBkysdmjsjdxgqx(jsonObject.get("bkysdmjsjdxgqx").toString());
        employeeInfo.setQyysdmjsjdxgqx(jsonObject.get("qyysdmjsjdxgqx").toString());
        employeeInfo.setBmfglqx(jsonObject.get("bmfglqx").toString());
        employeeInfo.setKszpglwhqx(jsonObject.get("kszpglwhqx").toString());
        employeeInfo.setQyzpglwhqx(jsonObject.get("qyzpglwhqx").toString());
        employeeInfo.setQydzblmbbjq(jsonObject.get("qydzblmbbjq").toString());
        employeeInfo.setDzysbz(jsonObject.get("dzysbz").toString());
        employeeInfo.setKzrshqx(jsonObject.get("kzrshqx").toString());
        employeeInfo.setKfcfq(jsonObject.get("kfcfq").toString());
        boolean issuccess=false;
        if(count>0){
            //修改
            employeeInfo.setUpdateBy("admin");
            employeeInfo.setUpdateTime(new Date());
            QueryWrapper<EmployeeInfo> whereWrapper = new QueryWrapper<>();
            whereWrapper.eq("employee_id", employeeInfo.getEmployeeId());
            boolean result = employeeInfoService.update(employeeInfo, whereWrapper);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }else{
            //添加
            employeeInfo.setCreateBy("admin");
            employeeInfo.setCreateTime(new Date());
            boolean result = employeeInfoService.save(employeeInfo);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }
        return issuccess;
    }

    /*
     * 添加或修改职工信息sysuser
     * */
    private boolean setEmployeeInfo1(int count,JSONObject jsonObject){
        //查找所属部门
        QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
        String deptCode=jsonObject.get("deptCode").toString();
        queryWrapper.eq("dept_code", deptCode);
        SysDept sysDept1 =deptService.getOne(queryWrapper);
        Long deptId=0L;
        if(sysDept1!=null){
            deptId=sysDept1.getDeptId();
        }
        //组装职工数据dept_id
        SysUser employeeInfo=new SysUser();
        employeeInfo.setDeptId(deptId);
        employeeInfo.setPhonenumber(jsonObject.get("telephone").toString());
        employeeInfo.setOrgCode(jsonObject.get("orgCode").toString());
        employeeInfo.setEmployeeId(jsonObject.get("employeeId").toString());
        employeeInfo.setEmployeeName(jsonObject.get("employeeName").toString());
        employeeInfo.setPy(jsonObject.get("py").toString());
        employeeInfo.setWb(jsonObject.get("wb").toString());
        employeeInfo.setInputCode(jsonObject.get("inputCode").toString());
        if(jsonObject.get("genderCode") instanceof Number){
            employeeInfo.setGenderCode(((Number) jsonObject.get("genderCode")).intValue());
        }else {
            employeeInfo.setGenderCode(0);
        }
        employeeInfo.setGenderName(jsonObject.get("genderName").toString());
        employeeInfo.setBirthDate(jsonObject.get("birthDate").toString());
        if(jsonObject.get("maritalStatusCode") instanceof Number){
            employeeInfo.setMaritalStatusCode(((Number) jsonObject.get("maritalStatusCode")).intValue());
        }else {
            employeeInfo.setMaritalStatusCode(0);
        }
        if(jsonObject.get("idTypeCode") instanceof Number){
            employeeInfo.setIdTypeCode(((Number) jsonObject.get("idTypeCode")).intValue());
        }else {
            employeeInfo.setIdTypeCode(0);
        }
        employeeInfo.setIdNo(jsonObject.get("IDNo").toString());
        employeeInfo.setDeptCode(jsonObject.get("deptCode").toString());
        employeeInfo.setDeptName(jsonObject.get("deptName").toString());
        employeeInfo.setAdminDeptCode(jsonObject.get("adminDeptCode").toString());
        employeeInfo.setAdminDeptName(jsonObject.get("adminDeptName").toString());
        employeeInfo.setWardCode(jsonObject.get("wardCode").toString());
        employeeInfo.setWardName(jsonObject.get("wardName").toString());
        if(jsonObject.get("employeeTypeCode") instanceof Number){
            employeeInfo.setEmployeeTypeCode(((Number) jsonObject.get("employeeTypeCode")).intValue());
        }else {
            employeeInfo.setEmployeeTypeCode(0);
        }
        if(jsonObject.get("techPositionCode") instanceof Number){
            employeeInfo.setTechPositionCode(((Number) jsonObject.get("techPositionCode")).intValue());
        }else {
            employeeInfo.setTechPositionCode(0);
        }
        employeeInfo.setTechPositionName(jsonObject.get("techPositionName").toString());
        employeeInfo.setTelephone(jsonObject.get("telephone").toString());
        employeeInfo.setSupDoctorCode(jsonObject.get("supDoctorCode").toString());
        employeeInfo.setSupDoctorName(jsonObject.get("supDoctorName").toString());
        employeeInfo.setMedDocCode(jsonObject.get("medDocCode").toString());
        employeeInfo.setDirDocSign(jsonObject.get("dirDocSign").toString());
        employeeInfo.setPresRightSign(jsonObject.get("presRightSign").toString());
        employeeInfo.setAnesPresRightSign(jsonObject.get("anesPresRightSign").toString());
        employeeInfo.setSpecRegFee(jsonObject.get("specRegFee").toString());
        if(jsonObject.get("limitNumber") instanceof Number){
            employeeInfo.setLimitNumber(((Number) jsonObject.get("limitNumber")).intValue());
        }else {
            employeeInfo.setLimitNumber(0);
        }
        employeeInfo.setPresChapterNo(jsonObject.get("presChapterNo").toString());
        employeeInfo.setMemo(jsonObject.get("memo").toString());
        if(jsonObject.get("amLimitNo") instanceof Number){
            employeeInfo.setAmLimitNo(((Number) jsonObject.get("amLimitNo")).intValue());
        }else {
            employeeInfo.setAmLimitNo(0);
        }
        if(jsonObject.get("pmLimitNo") instanceof Number){
            employeeInfo.setPmLimitNo(((Number) jsonObject.get("pmLimitNo")).intValue());
        }else {
            employeeInfo.setPmLimitNo(0);
        }
        employeeInfo.setModifiedPresSign(jsonObject.get("modifiedPresSign").toString());
        employeeInfo.setElecPresRight(jsonObject.get("elecPresRight").toString());
        employeeInfo.setNoonLimitNo(jsonObject.get("noonLimitNo").toString());
        employeeInfo.setEmergencyRegFee(jsonObject.get("emergencyRegFee").toString());
        employeeInfo.setEmergencyMedFee(jsonObject.get("emergencyMedFee").toString());
        employeeInfo.setEmergencyTreatFee(jsonObject.get("emergencyTreatFee").toString());
        String degreeCode=jsonObject.get("degreeCode").toString();
        if(degreeCode!=null&&degreeCode!=""&&!degreeCode.isEmpty()&&!degreeCode.equals("null")){
            employeeInfo.setDegreeCode(Long.valueOf(degreeCode));
        }
        employeeInfo.setPhotoUrl(jsonObject.get("photoUrl").toString());
        employeeInfo.setSignatureGraph(jsonObject.get("signatureGraph").toString());
        employeeInfo.setValidStartDTime(jsonObject.get("validStartDTime").toString());
        employeeInfo.setValidEndDTime(jsonObject.get("validEndDTime").toString());
        employeeInfo.setActiveSign(jsonObject.get("activeSign").toString());
        employeeInfo.setVerNo(jsonObject.get("verNo").toString());
        employeeInfo.setEmployeePassword(jsonObject.get("employeePassword").toString());
        employeeInfo.setBmjb(jsonObject.get("bmjb").toString());
        employeeInfo.setGwdm(jsonObject.get("gwdm").toString());
        employeeInfo.setGwmc(jsonObject.get("gwmc").toString());
        employeeInfo.setGhf(jsonObject.get("ghf").toString());
        employeeInfo.setZlf(jsonObject.get("zlf").toString());
        employeeInfo.setWzzxbz(jsonObject.get("wzzxbz").toString());
        employeeInfo.setYsjb(jsonObject.get("ysjb").toString());
        employeeInfo.setIsmsg(jsonObject.get("ismsg").toString());
        employeeInfo.setSszcId(jsonObject.get("sszc_id").toString());
        employeeInfo.setSszcMc(jsonObject.get("sszc_mc").toString());
        employeeInfo.setCzry(jsonObject.get("czry").toString());
        employeeInfo.setZxysdm(jsonObject.get("zxysdm").toString());
        employeeInfo.setMzTfbz(jsonObject.get("mz_tfbz").toString());
        employeeInfo.setSsfl(jsonObject.get("ssfl").toString());
        employeeInfo.setZxksdm(jsonObject.get("zxksdm").toString());
        employeeInfo.setIpaddress(jsonObject.get("ipaddress").toString());
        employeeInfo.setSfyy(jsonObject.get("sfyy").toString());
        employeeInfo.setYxj(jsonObject.get("yxj").toString());
        employeeInfo.setIszkhs(jsonObject.get("iszkhs").toString());
        employeeInfo.setZzghbz(jsonObject.get("zzghbz").toString());
        employeeInfo.setSfxh(jsonObject.get("sfxh").toString());
        employeeInfo.setTxbz(jsonObject.get("txbz").toString());
        employeeInfo.setKsscfq(jsonObject.get("ksscfq").toString());
        employeeInfo.setZyzz(jsonObject.get("zyzz").toString());
        employeeInfo.setSjdpbbz(jsonObject.get("sjdpbbz").toString());
        employeeInfo.setMxpbbz(jsonObject.get("mxpbbz").toString());
        employeeInfo.setFzhxqz(jsonObject.get("fzhxqz").toString());
        employeeInfo.setLsgbz(jsonObject.get("lsgbz").toString());
        employeeInfo.setKzlywcfq(jsonObject.get("kzlywcfq").toString());
        employeeInfo.setCwyyywcfq(jsonObject.get("cwyyywcfq").toString());
        employeeInfo.setSqxtypbz(jsonObject.get("sqxtypbz").toString());
        employeeInfo.setZkxtypbz(jsonObject.get("zkxtypbz").toString());
        employeeInfo.setSsyzqx(jsonObject.get("ssyzqx").toString());
        employeeInfo.setZgkh(jsonObject.get("zgkh").toString());
        employeeInfo.setIsdbrqx(jsonObject.get("isdbrqx").toString());
        employeeInfo.setJsry1(jsonObject.get("jsry1").toString());
        employeeInfo.setZgjj(jsonObject.get("zgjj").toString());
        employeeInfo.setJylcfq(jsonObject.get("jylcfq").toString());
        employeeInfo.setJelcfq(jsonObject.get("jelcfq").toString());
        employeeInfo.setJdlcfq(jsonObject.get("jdlcfq").toString());
        employeeInfo.setBmcfzxysdm(jsonObject.get("bmcfzxysdm").toString());
        employeeInfo.setJsypcfq(jsonObject.get("jsypcfq").toString());
        employeeInfo.setXcfsyq(jsonObject.get("xcfsyq").toString());
        employeeInfo.setFzyyspq(jsonObject.get("fzyyspq").toString());
        employeeInfo.setSzyzq(jsonObject.get("szyzq").toString());
        employeeInfo.setQkysq(jsonObject.get("qkysq").toString());
        employeeInfo.setXgbjxhtyxq(jsonObject.get("xgbjxhtyxq").toString());
        employeeInfo.setYzfsq(jsonObject.get("yzfsq").toString());
        employeeInfo.setYzfscxq(jsonObject.get("yzfscxq").toString());
        employeeInfo.setBlbjq(jsonObject.get("blbjq").toString());
        employeeInfo.setHzq(jsonObject.get("hzq").toString());
        employeeInfo.setGbys(jsonObject.get("gbys").toString());
        employeeInfo.setZycfq(jsonObject.get("zycfq").toString());
        employeeInfo.setMzcfq(jsonObject.get("mzcfq").toString());
        employeeInfo.setFsypcfq(jsonObject.get("fsypcfq").toString());
        employeeInfo.setJhsyypcfq(jsonObject.get("jhsyypcfq").toString());
        employeeInfo.setCkfsgbqx(jsonObject.get("ckfsgbqx").toString());
        employeeInfo.setPxyxj(jsonObject.get("pxyxj").toString());
        employeeInfo.setGbysbz(jsonObject.get("gbysbz").toString());
        employeeInfo.setMfhs(jsonObject.get("mfhs").toString());
        employeeInfo.setXlMc(jsonObject.get("xl_mc").toString());
        employeeInfo.setXwId(jsonObject.get("xw_id").toString());
        employeeInfo.setXwMc(jsonObject.get("xw_mc").toString());
        employeeInfo.setSfzzyy(jsonObject.get("sfzzyy").toString());
        employeeInfo.setWjztxbz(jsonObject.get("wjztxbz").toString());
        employeeInfo.setYbysbz(jsonObject.get("ybysbz").toString());
        employeeInfo.setGjycfq(jsonObject.get("gjycfq").toString());
        employeeInfo.setIsscpt(jsonObject.get("isscpt").toString());
        employeeInfo.setDbcfq(jsonObject.get("dbcfq").toString());
        employeeInfo.setRzrq(jsonObject.get("rzrq").toString());
        employeeInfo.setLzrq(jsonObject.get("lzrq").toString());
        employeeInfo.setKxgypzd(jsonObject.get("kxgypzd").toString());
        if(jsonObject.get("bkxgypzd") instanceof Number){
            employeeInfo.setBkxgypzd(((Number) jsonObject.get("bkxgypzd")).intValue());
        }else {
            employeeInfo.setBkxgypzd(0);
        }
        employeeInfo.setYszgzbm(jsonObject.get("yszgzbm").toString());
        employeeInfo.setYszyzbm(jsonObject.get("yszyzbm").toString());
        employeeInfo.setZwId(jsonObject.get("zw_id").toString());
        employeeInfo.setZwMc(jsonObject.get("zw_mc").toString());
        employeeInfo.setMdmphoto(jsonObject.get("mdmphoto").toString());
        employeeInfo.setDlhsbz(jsonObject.get("dlhsbz").toString());
        employeeInfo.setYszcbh(jsonObject.get("yszcbh").toString());
        employeeInfo.setYszyfw(jsonObject.get("yszyfw").toString());
        employeeInfo.setHszybh(jsonObject.get("hszybh").toString());
        employeeInfo.setZgsc(jsonObject.get("zgsc").toString());
        employeeInfo.setZglx(jsonObject.get("zglx").toString());
        employeeInfo.setCfqz(jsonObject.get("cfqz").toString());
        employeeInfo.setMzlycfqz(jsonObject.get("mzlycfqz").toString());
        employeeInfo.setXycflrqz(jsonObject.get("xycflrqz").toString());
        employeeInfo.setZycflrqz(jsonObject.get("zycflrqz").toString());
        employeeInfo.setCycflrqz(jsonObject.get("cycflrqz").toString());
        employeeInfo.setJslycfqz(jsonObject.get("jslycfqz").toString());
        employeeInfo.setJdlycfqz(jsonObject.get("jdlycfqz").toString());
        employeeInfo.setFzyyspqz(jsonObject.get("fzyyspqz").toString());
        employeeInfo.setXcfsyqxz(jsonObject.get("xcfsyqxz").toString());
        employeeInfo.setSzyzqxz(jsonObject.get("szyzqxz").toString());
        employeeInfo.setQkysqxz(jsonObject.get("qkysqxz").toString());
        employeeInfo.setXgbjxhtyxqxz(jsonObject.get("xgbjxhtyxqxz").toString());
        employeeInfo.setYssfyyzfsqxz(jsonObject.get("yssfyyzfsqxz").toString());
        employeeInfo.setXghqxzdbrsbqz(jsonObject.get("xghqxzdbrsbqz").toString());
        employeeInfo.setFyxxdydcqz(jsonObject.get("fyxxdydcqz").toString());
        employeeInfo.setDbybcfqz(jsonObject.get("dbybcfqz").toString());
        employeeInfo.setJylyfqz(jsonObject.get("jylyfqz").toString());
        employeeInfo.setGjycfqz(jsonObject.get("gjycfqz").toString());
        employeeInfo.setZzrsyycfqz(jsonObject.get("zzrsyycfqz").toString());
        employeeInfo.setCplyycfqz(jsonObject.get("cplyycfqz").toString());
        employeeInfo.setTpsjsyycfqz(jsonObject.get("tpsjsyycfqz").toString());
        employeeInfo.setXyzjyycfqz(jsonObject.get("xyzjyycfqz").toString());
        employeeInfo.setYyjsyycfqz(jsonObject.get("yyjsyycfqz").toString());
        employeeInfo.setMyzqyycfqz(jsonObject.get("myzqyycfqz").toString());
        employeeInfo.setKzlywcfqz(jsonObject.get("kzlywcfqz").toString());
        employeeInfo.setYlqtcfqz(jsonObject.get("ylqtcfqz").toString());
        employeeInfo.setYzfscxqz(jsonObject.get("yzfscxqz").toString());
        employeeInfo.setBlbjqz(jsonObject.get("blbjqz").toString());
        employeeInfo.setHzqz(jsonObject.get("hzqz").toString());
        employeeInfo.setBlzhcxdydcqz(jsonObject.get("blzhcxdydcqz").toString());
        employeeInfo.setEmrblcxqz(jsonObject.get("emrblcxqz").toString());
        employeeInfo.setBltjqz(jsonObject.get("bltjqz").toString());
        employeeInfo.setCsqz(jsonObject.get("csqz").toString());
        employeeInfo.setKsscfqz(jsonObject.get("ksscfqz").toString());
        employeeInfo.setDbrqxz(jsonObject.get("dbrqxz").toString());
        employeeInfo.setCwyyycfqz(jsonObject.get("cwyyycfqz").toString());
        employeeInfo.setJelycfqz(jsonObject.get("jelycfqz").toString());
        employeeInfo.setMzcfqz(jsonObject.get("mzcfqz").toString());
        employeeInfo.setZycfqz(jsonObject.get("zycfqz").toString());
        employeeInfo.setFsypcfqz(jsonObject.get("fsypcfqz").toString());
        employeeInfo.setCkfsgbqz(jsonObject.get("ckfsgbqz").toString());
        employeeInfo.setSfnkssyzz(jsonObject.get("sfnkssyzz").toString());
        employeeInfo.setJhsyypcfqz(jsonObject.get("jhsyypcfqz").toString());
        employeeInfo.setZlxmcfqz(jsonObject.get("zlxmcfqz").toString());
        employeeInfo.setTbcfq(jsonObject.get("tbcfq").toString());
        employeeInfo.setYjkscxq(jsonObject.get("yjkscxq").toString());
        employeeInfo.setEjkscxq(jsonObject.get("ejkscxq").toString());
        employeeInfo.setYwsyq(jsonObject.get("ywsyq").toString());
        employeeInfo.setYbcfq(jsonObject.get("ybcfq").toString());
        employeeInfo.setYydxyqcfq(jsonObject.get("yydxyqcfq").toString());
        employeeInfo.setYlqtlcfq(jsonObject.get("ylqtlcfq").toString());
        employeeInfo.setHzyqq(jsonObject.get("hzyqq").toString());
        employeeInfo.setHzchq(jsonObject.get("hzchq").toString());
        employeeInfo.setSqyxqx(jsonObject.get("sqyxqx").toString());
        employeeInfo.setKsxdfwhqx(jsonObject.get("ksxdfwhqx").toString());
        employeeInfo.setQyxdfwhqx(jsonObject.get("qyxdfwhqx").toString());
        employeeInfo.setQygmxxzfqx(jsonObject.get("qygmxxzfqx").toString());
        employeeInfo.setBkysdmjsjdxgqx(jsonObject.get("bkysdmjsjdxgqx").toString());
        employeeInfo.setQyysdmjsjdxgqx(jsonObject.get("qyysdmjsjdxgqx").toString());
        employeeInfo.setBmfglqx(jsonObject.get("bmfglqx").toString());
        employeeInfo.setKszpglwhqx(jsonObject.get("kszpglwhqx").toString());
        employeeInfo.setQyzpglwhqx(jsonObject.get("qyzpglwhqx").toString());
        employeeInfo.setQydzblmbbjq(jsonObject.get("qydzblmbbjq").toString());
        employeeInfo.setDzysbz(jsonObject.get("dzysbz").toString());
        employeeInfo.setKzrshqx(jsonObject.get("kzrshqx").toString());
        employeeInfo.setKfcfq(jsonObject.get("kfcfq").toString());
        employeeInfo.setRoleIds(new Long[]{4l});
        boolean issuccess=false;
        if(count>0){
            //修改
            employeeInfo.setUpdateBy("admin");
            employeeInfo.setUpdateTime(new Date());
            QueryWrapper<SysUser> whereWrapper = new QueryWrapper<>();
            whereWrapper.eq("employee_id", employeeInfo.getEmployeeId());
            boolean result = userService.update(employeeInfo, whereWrapper);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }else{
            //添加
            employeeInfo.setUserName(jsonObject.get("employeeId").toString());
            employeeInfo.setNickName(jsonObject.get("employeeName").toString());
            employeeInfo.setPassword(SecurityUtils.encryptPassword("123456"));
            employeeInfo.setStatus("0");
            employeeInfo.setDelFlag("0");
            employeeInfo.setCreateBy("admin");
            employeeInfo.setCreateTime(new Date());
            boolean result = userService.insertUser(employeeInfo);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }
        return issuccess;
    }

    /*
     * 添加或修改科室信息
     * */
    private boolean setDeptInfo(int count, JSONObject jsonObject){
        DeptInfo deptInfo=new DeptInfo();
        deptInfo.setOrgCode(jsonObject.get("orgCode").toString());
        deptInfo.setDeptCode(jsonObject.get("deptCode").toString());
        deptInfo.setDeptName(jsonObject.get("deptName").toString());
        deptInfo.setPy(jsonObject.get("py").toString());
        deptInfo.setWb(jsonObject.get("wb").toString());
        deptInfo.setInputCode(jsonObject.get("inputCode").toString());
        deptInfo.setDeptCodeOne(jsonObject.get("deptCodeOne").toString());
        deptInfo.setDeptNameOne(jsonObject.get("deptNameOne").toString());
        deptInfo.setDeptCodeTwo(jsonObject.get("deptCodeTwo").toString());
        deptInfo.setDeptNameTwo(jsonObject.get("deptNameTwo").toString());
        deptInfo.setMedDeptCode(jsonObject.get("medDeptCode").toString());
        deptInfo.setMedDeptName(jsonObject.get("medDeptName").toString());
        deptInfo.setAccountDeptCode(jsonObject.get("accountDeptCode").toString());
        deptInfo.setAccountDeptName(jsonObject.get("accountDeptName").toString());
        deptInfo.setDeptTypeCode(new BigDecimal(jsonObject.get("deptTypeCode").toString()));
        deptInfo.setDeptAddr(jsonObject.get("deptAddr").toString());
        String depositWarLine=jsonObject.get("depositWarLine").toString();
        deptInfo.setDepositWarLine(new BigDecimal(depositWarLine));
        deptInfo.setErSign(jsonObject.get("ERSign").toString());
        deptInfo.setSpecialtySign(jsonObject.get("specialtySign").toString());
        deptInfo.setChildSign(jsonObject.get("childSign").toString());
        deptInfo.setRupplyRoomSign(jsonObject.get("rupplyRoomSign").toString());
        deptInfo.setChineseMedSign(jsonObject.get("chineseMedSign").toString());
        deptInfo.setOweCtrlSign(jsonObject.get("oweCtrlSign").toString());
        deptInfo.setDeptSign(jsonObject.get("deptSign").toString());
        if(jsonObject.get("limitNo") instanceof Number){
            deptInfo.setLimitNo(((Number) jsonObject.get("limitNo")).intValue());
        }else {
            deptInfo.setLimitNo(0);
        }
        if(jsonObject.get("chiefDoctNo") instanceof Number){
            deptInfo.setChiefDoctNo(((Number) jsonObject.get("chiefDoctNo")).intValue());
        }else {
            deptInfo.setChiefDoctNo(0);
        }
        if(jsonObject.get("resiDoctNo") instanceof Number){
            deptInfo.setResiDoctNo(((Number) jsonObject.get("resiDoctNo")).intValue());
        }else {
            deptInfo.setResiDoctNo(0);
        }
        if(jsonObject.get("atndDoctNo") instanceof Number){
            deptInfo.setAtndDoctNo(((Number) jsonObject.get("atndDoctNo")).intValue());
        }else {
            deptInfo.setAtndDoctNo(0);
        }
        if(jsonObject.get("nursNo") instanceof Number){
            deptInfo.setNursNo(((Number) jsonObject.get("nursNo")).intValue());
        }else {
            deptInfo.setNursNo(0);
        }
        if(jsonObject.get("assessedBedsNo") instanceof Number){
            deptInfo.setAssessedBedsNo(((Number) jsonObject.get("assessedBedsNo")).intValue());
        }else {
            deptInfo.setAssessedBedsNo(0);
        }
        deptInfo.setDepositBndonLine(new BigDecimal(jsonObject.get("depositBndonLine").toString()));
        if(jsonObject.containsKey("tcmEmrSign")){
            deptInfo.setTcmEmrSign(jsonObject.get("tcmEmrSign").toString());
        }
        deptInfo.setNurseStationIp(jsonObject.get("nurseStationIP").toString());
        if(jsonObject.get("authorizeBeds") instanceof Number){
            deptInfo.setAuthorizeBeds(((Number) jsonObject.get("authorizeBeds")).intValue());
        }else {
            deptInfo.setAuthorizeBeds(0);
        }
        if(jsonObject.get("authorizeHomeBeds") instanceof Number){
            deptInfo.setAuthorizeHomeBeds(((Number) jsonObject.get("authorizeHomeBeds")).intValue());
        }else {
            deptInfo.setAuthorizeHomeBeds(0);
        }
        deptInfo.setConfirmDeptSign(jsonObject.get("confirmDeptSign").toString());
        deptInfo.setSubmitDeptCode(jsonObject.get("submitDeptCode").toString());
        deptInfo.setSubmitDeptName(jsonObject.get("submitDeptName").toString());
        deptInfo.setSelfRegisterSign(jsonObject.get("selfRegisterSign").toString());
        deptInfo.setPharmSign(jsonObject.get("pharmSign").toString());
        deptInfo.setSpecDiseaseSign(jsonObject.get("specDiseaseSign").toString());
        deptInfo.setDeptIp(jsonObject.get("deptIP").toString());
        deptInfo.setCorrespondingDeptCode(jsonObject.get("correspondingDeptCode").toString());
        deptInfo.setCorrespondingDeptName(jsonObject.get("correspondingDeptName").toString());
        deptInfo.setGenerPracStationSign(jsonObject.get("generPracStationSign").toString());
        deptInfo.setTriagePrefix(jsonObject.get("triagePrefix").toString());
        deptInfo.setAljkSign(jsonObject.get("aljkSign").toString());
        deptInfo.setDeptLocation(jsonObject.get("deptLocation").toString());
        deptInfo.setDeptLocation2(jsonObject.get("deptLocation2").toString());
        deptInfo.setDeptLocation3(jsonObject.get("deptLocation3").toString());
        deptInfo.setDeptLocation4(jsonObject.get("deptLocation4").toString());
        deptInfo.setSpecialistSign(jsonObject.get("specialistSign").toString());
        deptInfo.setApntSign(jsonObject.get("apntSign").toString());
        deptInfo.setMemo(jsonObject.get("memo").toString());
        deptInfo.setValidStartDTime(jsonObject.get("validStartDTime").toString());
        deptInfo.setValidEndDTime(jsonObject.get("validEndDTime").toString());
        deptInfo.setActiveSign(jsonObject.get("activeSign").toString());
        deptInfo.setVerNo(jsonObject.get("verNo").toString());
        deptInfo.setOrderno(jsonObject.get("ORDERNO").toString());
        deptInfo.setYjbj(jsonObject.get("YJBJ").toString());
        deptInfo.setZzms(jsonObject.get("ZZMS").toString());
        boolean issuccess=false;
        if(count>0){
            deptInfo.setUpdateBy("admin");
            deptInfo.setUpdateTime(new Date());
            //修改
            QueryWrapper<DeptInfo> whereWrapper = new QueryWrapper<>();
            whereWrapper.eq("dept_code", deptInfo.getDeptCode());
            boolean result = deptInfoService.update(deptInfo, whereWrapper);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }else{
            //添加
            deptInfo.setCreateBy("admin");
            deptInfo.setCreateTime(new Date());
            boolean result = deptInfoService.save(deptInfo);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }
        return issuccess;
    }

    /*
     * 添加或修改科室信息SysDept
     * */
    private boolean setDeptInfo1(int count, JSONObject jsonObject){
        SysDept deptInfo=new SysDept();
        deptInfo.setOrgCode(jsonObject.get("orgCode").toString());
        deptInfo.setDeptCode(jsonObject.get("deptCode").toString());
        deptInfo.setDeptName(jsonObject.get("deptName").toString());
        deptInfo.setPy(jsonObject.get("py").toString());
        deptInfo.setWb(jsonObject.get("wb").toString());
        deptInfo.setInputCode(jsonObject.get("inputCode").toString());
        deptInfo.setDeptCodeOne(jsonObject.get("deptCodeOne").toString());
        deptInfo.setDeptNameOne(jsonObject.get("deptNameOne").toString());
        deptInfo.setDeptCodeTwo(jsonObject.get("deptCodeTwo").toString());
        deptInfo.setDeptNameTwo(jsonObject.get("deptNameTwo").toString());
        deptInfo.setMedDeptCode(jsonObject.get("medDeptCode").toString());
        deptInfo.setMedDeptName(jsonObject.get("medDeptName").toString());
        deptInfo.setAccountDeptCode(jsonObject.get("accountDeptCode").toString());
        deptInfo.setAccountDeptName(jsonObject.get("accountDeptName").toString());
        String deptTypeCode=jsonObject.get("deptTypeCode").toString();
        if(deptTypeCode!=null&&deptTypeCode!=""&&!deptTypeCode.equals("null")&&!deptTypeCode.isEmpty()){
            deptInfo.setDeptTypeCode(Long.valueOf(deptTypeCode));
        }
        deptInfo.setDeptAddr(jsonObject.get("deptAddr").toString());
        String depositWarLine=jsonObject.get("depositWarLine").toString();
        deptInfo.setDepositWarLine(new BigDecimal(depositWarLine));
        deptInfo.setErSign(jsonObject.get("ERSign").toString());
        deptInfo.setSpecialtySign(jsonObject.get("specialtySign").toString());
        deptInfo.setChildSign(jsonObject.get("childSign").toString());
        deptInfo.setRupplyRoomSign(jsonObject.get("rupplyRoomSign").toString());
        deptInfo.setChineseMedSign(jsonObject.get("chineseMedSign").toString());
        deptInfo.setOweCtrlSign(jsonObject.get("oweCtrlSign").toString());
        deptInfo.setDeptSign(jsonObject.get("deptSign").toString());
        if(jsonObject.get("limitNo") instanceof Number){
            deptInfo.setLimitNo(((Number) jsonObject.get("limitNo")).intValue());
        }else {
            deptInfo.setLimitNo(0);
        }
        if(jsonObject.get("chiefDoctNo") instanceof Number){
            deptInfo.setChiefDoctNo(((Number) jsonObject.get("chiefDoctNo")).intValue());
        }else {
            deptInfo.setChiefDoctNo(0);
        }
        if(jsonObject.get("resiDoctNo") instanceof Number){
            deptInfo.setResiDoctNo(((Number) jsonObject.get("resiDoctNo")).intValue());
        }else {
            deptInfo.setResiDoctNo(0);
        }
        if(jsonObject.get("atndDoctNo") instanceof Number){
            deptInfo.setAtndDoctNo(((Number) jsonObject.get("atndDoctNo")).intValue());
        }else {
            deptInfo.setAtndDoctNo(0);
        }
        if(jsonObject.get("nursNo") instanceof Number){
            deptInfo.setNursNo(((Number) jsonObject.get("nursNo")).intValue());
        }else {
            deptInfo.setNursNo(0);
        }
        if(jsonObject.get("assessedBedsNo") instanceof Number){
            deptInfo.setAssessedBedsNo(((Number) jsonObject.get("assessedBedsNo")).intValue());
        }else {
            deptInfo.setAssessedBedsNo(0);
        }
        deptInfo.setDepositBndonLine(new BigDecimal(jsonObject.get("depositBndonLine").toString()));
        if(jsonObject.containsKey("tcmEmrSign")){
            deptInfo.setTcmEmrSign(jsonObject.get("tcmEmrSign").toString());
        }
        deptInfo.setNurseStationIp(jsonObject.get("nurseStationIP").toString());
        if(jsonObject.get("authorizeBeds") instanceof Number){
            deptInfo.setAuthorizeBeds(((Number) jsonObject.get("authorizeBeds")).intValue());
        }else {
            deptInfo.setAuthorizeBeds(0);
        }
        if(jsonObject.get("authorizeHomeBeds") instanceof Number){
            deptInfo.setAuthorizeHomeBeds(((Number) jsonObject.get("authorizeHomeBeds")).intValue());
        }else {
            deptInfo.setAuthorizeHomeBeds(0);
        }
        deptInfo.setConfirmDeptSign(jsonObject.get("confirmDeptSign").toString());
        deptInfo.setSubmitDeptCode(jsonObject.get("submitDeptCode").toString());
        deptInfo.setSubmitDeptName(jsonObject.get("submitDeptName").toString());
        deptInfo.setSelfRegisterSign(jsonObject.get("selfRegisterSign").toString());
        deptInfo.setPharmSign(jsonObject.get("pharmSign").toString());
        deptInfo.setSpecDiseaseSign(jsonObject.get("specDiseaseSign").toString());
        deptInfo.setDeptIp(jsonObject.get("deptIP").toString());
        deptInfo.setCorrespondingDeptCode(jsonObject.get("correspondingDeptCode").toString());
        deptInfo.setCorrespondingDeptName(jsonObject.get("correspondingDeptName").toString());
        deptInfo.setGenerPracStationSign(jsonObject.get("generPracStationSign").toString());
        deptInfo.setTriagePrefix(jsonObject.get("triagePrefix").toString());
        deptInfo.setAljkSign(jsonObject.get("aljkSign").toString());
        deptInfo.setDeptLocation(jsonObject.get("deptLocation").toString());
        deptInfo.setDeptLocation2(jsonObject.get("deptLocation2").toString());
        deptInfo.setDeptLocation3(jsonObject.get("deptLocation3").toString());
        deptInfo.setDeptLocation4(jsonObject.get("deptLocation4").toString());
        deptInfo.setSpecialistSign(jsonObject.get("specialistSign").toString());
        deptInfo.setApntSign(jsonObject.get("apntSign").toString());
        deptInfo.setMemo(jsonObject.get("memo").toString());
        deptInfo.setValidStartDTime(jsonObject.get("validStartDTime").toString());
        deptInfo.setValidEndDTime(jsonObject.get("validEndDTime").toString());
        deptInfo.setActiveSign(jsonObject.get("activeSign").toString());
        deptInfo.setVerNo(jsonObject.get("verNo").toString());
        deptInfo.setOrderno(jsonObject.get("ORDERNO").toString());
        deptInfo.setYjbj(jsonObject.get("YJBJ").toString());
        deptInfo.setZzms(jsonObject.get("ZZMS").toString());
        boolean issuccess=false;
        if(count>0){
            deptInfo.setUpdateBy("admin");
            deptInfo.setUpdateTime(new Date());
            //修改
            QueryWrapper<SysDept> whereWrapper = new QueryWrapper<>();
            whereWrapper.eq("dept_code", deptInfo.getDeptCode());
            boolean result = deptService.update(deptInfo, whereWrapper);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }else{
            //添加
            deptInfo.setParentId(0L);
            deptInfo.setAncestors("0");
            deptInfo.setStatus("0");
            deptInfo.setDelFlag("0");
            deptInfo.setCreateBy("admin");
            deptInfo.setCreateTime(new Date());
            boolean result = deptService.save(deptInfo);
            if (result) {
                issuccess=true;
            } else {
                issuccess=false;
            }
        }
        return issuccess;
    }

    /*
     * 使用正则表达式匹配"null"并替换为""
     * */
    private static String replaceNullInRequestBody(String body) {
        Pattern pattern = Pattern.compile("null");
        Matcher matcher = pattern.matcher(body);
        return matcher.replaceAll("\"\"");
    }
}