package com.zjrs.zwnw.zj.bpo.impl;

import io.micrometer.core.instrument.util.StringUtils;
import org.mohrss.leaf.core.framework.domain.bpo.impl.BPOImpl;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.util.CurrentUser;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import com.zjrs.zwnw.jbxxgl.po.VSAc01PO;
import com.zjrs.zwnw.zj.blo.GccrcBLO;
import com.zjrs.zwnw.zj.bpo.GccrcBPO;
import com.zjrs.zwnw.zj.dto.*;
import com.zjrs.zwnw.zj.po.GccrcFjPO;
import com.zjrs.zwnw.zj.po.GccrcLsPO;
import com.zjrs.zwnw.zj.po.GccrcPO;
import com.zjrs.zwnw.zj.po.GccrcQfPO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class GccrcBPOImpl  extends BPOImpl implements GccrcBPO {
    @Resource
    private GccrcBLO gccrcBLO;

    @Override
    public GccrcInfoDTO getGccrcInfo(GccrcQueryByIdDTO dto) {
        return this.gccrcBLO.getGccrcInfo(dto);
    }

    @Override
    public PageResult getGccrcList(GccrcQueryDTO dto, int page, int rows) {
        return this.gccrcBLO.getGccrcList(dto, page, rows);
    }

    @Override
    public AjaxResponse saveOrUpdGccrc(GccrcSaveDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        GccrcInfoDTO gccrcInfoDTO = new GccrcInfoDTO();
        GccrcPO gccrcPO = new GccrcPO();
        BeanUtils.copyProperties(dto, gccrcInfoDTO);
        BeanUtils.copyProperties(dto, gccrcPO);
        if(StringUtils.isBlank(dto.getCzlx())) {
            //首次认定
            gccrcPO.setSqlx("1");
        }else if(dto.getCzlx().equals("1")){
            //续卡
            gccrcPO.setSqlx("2");
        }else if(dto.getCzlx().equals("2")){
            //换卡
            gccrcPO.setSqlx("3");
        }else{
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("操作类型字典有误");
            return ajaxResponse;
        }
        gccrcInfoDTO.setSqlx(gccrcPO.getSqlx());
        //2.保存高层次人才信息时，需根据证件类型+证件号码校验唯一，同一人员只能有一条高层次人才信息记录
        int cnt=gccrcBLO.queryCntById(gccrcPO.getRsZjGccrcLsh(),gccrcPO.getZtid());
        if(cnt>0){
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("该人员已存在高层次人才信息，不可重复保存");
            return ajaxResponse;
        }
        /*若某一人员在一窗通办服务平台有正在办理中的湛江市高层次人才业务，
        则不能同时在高层次人才管理菜单下新增该人员的高层次人才信息*/
        Long n=gccrcBLO.getCntByZtid(dto);
        if(n>0){
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("该人员已在一窗通办服务平台办理中的湛江市高层次人才业务，不可重复保存");
            return ajaxResponse;
        }
        CurrentUser currentUser = getCurrentUser();
        String userid = currentUser.getUserid() == null ? "" : currentUser.getUserid().trim();
        String Orgid = currentUser.getOrgid();
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dataString = dateFormat.format(date);
        GccrcLsPO gccrcLsPO=new GccrcLsPO();
        if(StringUtils.isBlank(gccrcPO.getRsZjGccrcLsh())) {
            gccrcLsPO.setRsZjGccrcLsh(gccrcPO.getRsZjGccrcLsh());
            gccrcLsPO.setBgnr("手工新增。");
            gccrcLsPO.setBgr(userid);
            gccrcLsPO.setBgrjg(Orgid);
            gccrcLsPO.setBgsj(dataString);
        }else{
            //保存变更内容
            GccrcQueryByIdDTO idDTO=new GccrcQueryByIdDTO();
            idDTO.setRsZjGccrcLsh(gccrcPO.getRsZjGccrcLsh());
            GccrcInfoDTO gccrcInfoOldDTO=gccrcBLO.getGccrcInfo(idDTO);

            if(StringUtils.isNotBlank(gccrcInfoOldDTO.getSqlx())&&gccrcPO.getSqlx().equals("1")) {
                gccrcPO.setSqlx(gccrcInfoOldDTO.getSqlx());
                gccrcInfoDTO.setSqlx(gccrcInfoOldDTO.getSqlx());
            }
            //查询变更内容
            String bgnr=getBgnr(gccrcInfoDTO,gccrcInfoOldDTO);
            if(!isNullstr(gccrcInfoDTO.getRcklx()).equals(isNullstr(gccrcInfoOldDTO.getRcklx()))||
                    !isNullstr(gccrcInfoDTO.getDwmc()).equals(isNullstr(gccrcInfoOldDTO.getDwmc()))||
                    !isNullstr(gccrcInfoDTO.getTyccid()).equals(isNullstr(gccrcInfoOldDTO.getTyccid()))){
                gccrcPO.setQfzt("2");
            }else{
                gccrcPO.setQfzt(gccrcInfoOldDTO.getQfzt());
            }
            gccrcLsPO.setRsZjGccrcLsh(gccrcPO.getRsZjGccrcLsh());
            gccrcLsPO.setBgnr(bgnr);
            gccrcLsPO.setBgr(userid);
            gccrcLsPO.setBgrjg(Orgid);
            gccrcLsPO.setBgsj(dataString);
        }
        if(StringUtils.isBlank(gccrcPO.getZcxl())) {
            gccrcPO.setZcxl("");
        }
        if(StringUtils.isBlank(gccrcPO.getZczymc())) {
            gccrcPO.setZczymc("");
        }
        if(StringUtils.isBlank(gccrcPO.getLdhtjzrq())) {
            gccrcPO.setLdhtjzrq("");
        }
        if(StringUtils.isBlank(gccrcPO.getShzlmc())) {
            gccrcPO.setShzlmc("");
        }

        String rsZjGccrcLsh= gccrcBLO.saveOrUpd(gccrcPO,gccrcLsPO);
        gccrcInfoDTO.setRsZjGccrcLsh(rsZjGccrcLsh);
        ajaxResponse.setData("data",gccrcInfoDTO);
        return ajaxResponse;
    }

    @Override
    public PageResult getBglsList(GccrcQueryByIdPageDTO dto, int page, int rows) {
        return this.gccrcBLO.getBglsList(dto, page, rows);
    }

    @Override
    public GccrcQfInfoDTO getDzkxx(GccrcQfQueryDTO dto) {
        return this.gccrcBLO.getDzkxx(dto);
    }

    @Override
    public AjaxResponse saveIsZxGccrc(GccrcSaveIsZxDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();

        GccrcQueryByIdDTO idDTO=new GccrcQueryByIdDTO();
        idDTO.setRsZjGccrcLsh(dto.getRsZjGccrcLsh());
        GccrcInfoDTO info=gccrcBLO.getGccrcInfo(idDTO);
        //1.只有人才卡状态为“正常”的记录才显示“注销”操作按钮。
        if(!isNullstr(info.getRckzt()).equals("1")&&isNullstr(dto.getRckzt()).equals("3")){
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("该人员卡状态异常，无法注销");
            return ajaxResponse;
        }
        //2.只有人才卡状态为“注销”的记录才显示“取消注销”操作按钮。
        if(!isNullstr(info.getRckzt()).equals("3")&&isNullstr(dto.getRckzt()).equals("1")){
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("只有人才卡状态为“注销”的记录才可取消注销");
            return ajaxResponse;
        }
        /*
        3.操作“取消注销”按钮时，需要结合“有效日期”判断，若当前日期早于或等于“有效日期”，
            则点击“取消注销”按钮时弹出取消注销操作界面；
            若当前日期晚于“有效日期”，则不允许操作“取消注销”，
            点击“取消注销”按钮时提示：“当前操作人员的人才卡已过有效期，无法取消注销。”，
            示例：某条人才卡状态为“注销”的数据，有效日期为2020-12-12，在2020-12-11操作“取消注销”按钮，则可弹出取消注销操作界面；
            若在2020-12-13操作“取消注销”按钮，则提示对应信息，不允许操作。
        * */
        String yxrq=info.getYxrq();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date nowDate = new Date();
            String nowS = sdf.format(nowDate);
            if(yxrq.compareTo(nowS)<0&&isNullstr(dto.getRckzt()).equals("1")){
                ajaxResponse.setAppcode("1");
                ajaxResponse.setErrorMsg("当前操作人员的人才卡已过有效期，无法取消注销。");
                return ajaxResponse;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        GccrcLsPO gccrcLsPO=new GccrcLsPO();
        CurrentUser currentUser = getCurrentUser();
        String userid = currentUser.getUserid() == null ? "" : currentUser.getUserid().trim();
        String Orgid = currentUser.getOrgid();
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dataString = dateFormat.format(date);

        String bgnr="";
        if(isNullstr(dto.getRckzt()).equals("3")){
            bgnr="【人才卡状态】由“正常”变更为“注销”；【注销原因】由“”变更为“"+dto.getZxyy()+"”。";
        }else{
            bgnr="【人才卡状态】由“注销”变更为“正常”；【取消注销原因】由“”变更为“"+dto.getZxyy()+"”。";
        }
        gccrcLsPO.setRsZjGccrcLsh(dto.getRsZjGccrcLsh());
        gccrcLsPO.setBgnr(bgnr);
        gccrcLsPO.setBgr(userid);
        gccrcLsPO.setBgrjg(Orgid);
        gccrcLsPO.setBgsj(dataString);

        gccrcBLO.saveIsZxGccrc(dto,gccrcLsPO);
        return ajaxResponse;
    }

    @Override
    public PageResult getDzkqfList(GccrcQueryByIdPageDTO dto, int page, int rows) {
        return this.gccrcBLO.getDzkqfList(dto, page, rows);
    }

    @Override
    public AjaxResponse saveQfzt(GccrcQfQueryListDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        List<GccrcQueryByIdDTO> idList=dto.getRsZjGccrcLshList();
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowDate = dateFormat.format(date);
        CurrentUser currentUser = getCurrentUser();
        String userid = currentUser.getUserid() == null ? "" : currentUser.getUserid().trim();
        String Orgid = currentUser.getOrgid();
        for(int i=0;i<idList.size();i++){
            GccrcQueryByIdDTO idDTO=idList.get(i);
            String yxrq="";
            String yxrq2="";
            /*1.若“劳动合同期限”选择的是“固定期限”，则需判断签发操作日期和“劳动合同截止日期”的日期区间，
            若日期区间小于或等于5年，则有效日期为：劳动合同截止日期；若大于5年，则有效日期为：签发操作日期+5年。
            若“劳动合同期限”选择的是“无固定期限”，则有效日期为：签发操作日期+5年
            * */
            GccrcInfoDTO gccrcInfoOldDTO=gccrcBLO.getGccrcInfo(idDTO);
            if(isNullstr(gccrcInfoOldDTO.getLdhtqx()).equals("1")){
                String ldhtjzrq=gccrcInfoOldDTO.getLdhtjzrq();
                String dd = new SimpleDateFormat("yyyy-MM-dd").format(date);
                int ns=compareDate(dd,ldhtjzrq,2);
                if(ns<=5){
                    try{
                        Date d = new SimpleDateFormat("yyyy-MM-dd").parse(ldhtjzrq);
                        yxrq=new SimpleDateFormat("yyyy年MM月dd日").format(d.getTime());
                        yxrq2 = new SimpleDateFormat("yyyy-MM-dd").format(d.getTime());
                    }catch (Exception ex){
                        ex.printStackTrace();
                    }
                }else{
                    Calendar cal = Calendar.getInstance();
                    cal.add(Calendar.YEAR, 5);
                    cal.add(Calendar.DAY_OF_YEAR, -1);
                    yxrq=new SimpleDateFormat("yyyy年MM月dd日").format(cal.getTime());
                    yxrq2 = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
                }
            }else if(isNullstr(gccrcInfoOldDTO.getLdhtqx()).equals("2")){
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.YEAR, 5);
                cal.add(Calendar.DAY_OF_YEAR, -1);
                yxrq=new SimpleDateFormat("yyyy年MM月dd日").format(cal.getTime());
                yxrq2 = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
            }
            /*（1）格式：年份（4位）+类别编号（2位）+流水号（5位）。
                （2）年份：取值签发操作时间所在年份。
                （3）类别编号：A类为01，B类为02，C类为03。
                流水号：不同类别的单独一个流水号，流水号不逢年归一，延续上年的流水号继续使用。
            * */
            String rcklx="0"+gccrcInfoOldDTO.getRcklx();
            String nowRckhm=isNullstr(gccrcInfoOldDTO.getRckhm());
            String rckhm="";
            if(!nowRckhm.equals("")){
                if(nowRckhm.substring(5,6).equals(gccrcInfoOldDTO.getRcklx())) {
                    rckhm = nowRckhm;
                }else{
                }
            }
            if(rckhm.equals("")){
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date());
                String yyyy=new SimpleDateFormat("yyyy").format(cal.getTime());
                String lsh=gccrcBLO.getMaxLsh(gccrcInfoOldDTO);
                rckhm=yyyy+rcklx+lsh;
            }

            GccrcLsPO gccrcLsPO=new GccrcLsPO();
            StringBuffer sb=new StringBuffer();
            if(!rckhm.equals(nowRckhm)){
                sb.append("【人才卡号码】由“").append(isNullstr(gccrcInfoOldDTO.getRckhm())).append("”变更为“").append(rckhm).append("”；");
            }
            if(!isNullstr(gccrcInfoOldDTO.getYxrq()).equals(yxrq2)){
                sb.append("【有效日期】由“").append(isNullstr(gccrcInfoOldDTO.getYxrq())).append("”变更为“").append(yxrq2).append("”；");
            }
            if(!isNullstr(gccrcInfoOldDTO.getRckzt()).equals("1")){
                sb.append("【人才卡状态】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_RCKZT",gccrcInfoOldDTO.getRckzt()))).append(
                        "”变更为“正常”；");
            }
            if(!isNullstr(gccrcInfoOldDTO.getQfzt()).equals("1")){
                sb.append("【电子卡签发状态】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_QFZT",gccrcInfoOldDTO.getQfzt()))).append(
                        "”变更为“已签发”；");
            }
            gccrcLsPO.setRsZjGccrcLsh(idDTO.getRsZjGccrcLsh());
            if(sb.toString().length()>0){
                gccrcLsPO.setBgnr(sb.toString().substring(0,sb.toString().length()-1)+"。");
            }
            gccrcLsPO.setBgr(userid);
            gccrcLsPO.setBgrjg(Orgid);
            gccrcLsPO.setBgsj(nowDate);

            gccrcInfoOldDTO.setRckhm(rckhm);
            gccrcInfoOldDTO.setYxrq(yxrq2);
            gccrcInfoOldDTO.setQfzt("1");
            gccrcInfoOldDTO.setRckzt("1");

            GccrcQfPO gccrcQfPO=new GccrcQfPO();
            gccrcQfPO.setGj(gccrcInfoOldDTO.getGj());
            gccrcQfPO.setDwmc(gccrcInfoOldDTO.getDwmc());
            gccrcQfPO.setQfr(userid);
            gccrcQfPO.setQfsj(nowDate);
            gccrcQfPO.setRckhm(rckhm);
            gccrcQfPO.setRcklx(gccrcInfoOldDTO.getRcklx());
            gccrcQfPO.setXm(gccrcInfoOldDTO.getXm());
            gccrcQfPO.setZjlx(gccrcInfoOldDTO.getZjlx());
            gccrcQfPO.setZjhm(gccrcInfoOldDTO.getZjhm());
            gccrcQfPO.setYxrq(yxrq);
            gccrcQfPO.setGsqs(gccrcInfoOldDTO.getGsqs());
            gccrcQfPO.setTyccid(gccrcInfoOldDTO.getTyccid());
            gccrcQfPO.setRsZjGccrcLsh(gccrcInfoOldDTO.getRsZjGccrcLsh());

            gccrcBLO.saveQfzt(gccrcInfoOldDTO,gccrcQfPO,gccrcLsPO,nowDate);
        }
        return ajaxResponse;
    }

    @Override
    public void exportGccrc(GccrcQueryDTO dto, HttpServletResponse res) {
        gccrcBLO.exportGccrc(dto,res);
    }

    @Override
    public VSAc01PO queryRyxx(AC01DTO dto) {
        return gccrcBLO.queryRyxx(dto);
    }

    @Override
    public void updateRckzt() {
        gccrcBLO.updateRckzt();
    }

    @Override
    public PageResult getFjList(GccrcQueryByIdPageDTO dto, int page, int rows) {
        return this.gccrcBLO.getFjList(dto, page, rows);
    }

    @Override
    public AjaxResponse saveFj(GccrcFjDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        GccrcFjPO gccrcFjPO = new GccrcFjPO();
        BeanUtils.copyProperties(dto, gccrcFjPO);
        gccrcFjPO.setTsYxbz("1");
        gccrcBLO.saveFj(gccrcFjPO);
        return ajaxResponse;
    }

    @Override
    public AjaxResponse delFj(GccrcFjDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        GccrcFjPO gccrcFjPO = new GccrcFjPO();
        BeanUtils.copyProperties(dto, gccrcFjPO);
        gccrcFjPO.setTsYxbz("0");
        gccrcBLO.delFj(gccrcFjPO);
        return ajaxResponse;
    }

    @Override
    public AjaxResponse batchGsqs(GccrcGsqsDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        List<GccrcQueryByIdDTO> idList=dto.getRsZjGccrcLshList();
        for(int i=0;i<idList.size();i++){
            GccrcQueryByIdDTO idDTO=idList.get(i);
            gccrcBLO.updateGsqs(idDTO,dto.getGsqs());
        }
        return ajaxResponse;
    }

    @Override
    public Map<String, String> importGccrc(InputStream is) throws Exception {
        return this.gccrcBLO.importGccrc(is);
    }

    @Override
    public List<Map<String,Integer>> queryGccrcDrhz(DrDTO dto) {
        return this.gccrcBLO.queryGccrcDrhz(dto);
    }

    @Override
    public PageResult queryGccrcDrsb(DrDTO dto, int page, int rows) {
        return this.gccrcBLO.queryGccrcDrsb(dto, page, rows);
    }

    @Override
    public PageResult queryGccrcDrcg(DrDTO dto, int page, int rows) {
        return this.gccrcBLO.queryGccrcDrcg(dto, page, rows);
    }

    @Override
    public Map<String, String> importPhoto(MultipartFile file, String suffix) throws Exception {
        return this.gccrcBLO.importPhoto(file,suffix);
    }

    @Override
    public List<Map<String, Integer>> queryPhotoDrhz(DrDTO dto) {
        return this.gccrcBLO.queryPhotoDrhz(dto);
    }

    @Override
    public PageResult queryPhotoDrsb(DrDTO dto, int page, int rows) {
        return this.gccrcBLO.queryPhotoDrsb(dto, page, rows);
    }

    @Override
    public PageResult queryPhotoDrcg(DrDTO dto, int page, int rows) {
        return this.gccrcBLO.queryPhotoDrcg(dto, page, rows);
    }

    public String getDictAAA103(String AAA100, String AAA102) {
        return gccrcBLO.getDictAAA103(AAA100,AAA102);
    }

    public String getBgnr(GccrcInfoDTO newPO,GccrcInfoDTO oldPO){
        StringBuffer sb=new StringBuffer();
        if(!isNullstr(newPO.getCsgzhy()).equals(isNullstr(oldPO.getCsgzhy()))){
            sb.append("【从事工作行业】由“").append(isNullstr(getDictAAA103("JBXX_AAB022",oldPO.getCsgzhy()))).append(
                    "”变更为“").
                    append(isNullstr(getDictAAA103("JBXX_AAB022",newPO.getCsgzhy()))).append("”；");
        }
        if(!isNullstr(newPO.getLyfs()).equals(isNullstr(oldPO.getLyfs()))){
            sb.append("【来源方式】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_LYFS",oldPO.getLyfs()))).
                    append("”变更为“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_LYFS",newPO.getLyfs()))).append("”；");
        }
        if(!isNullstr(newPO.getDzjjycysj()).equals(isNullstr(oldPO.getDzjjycysj()))){
            sb.append("【到湛江就业创业时间】由“").append(isNullstr(oldPO.getDzjjycysj())).append("”变更为“").
                    append(isNullstr(newPO.getDzjjycysj())).append("”；");
        }
        if(!isNullstr(newPO.getCyyykqk()).equals(isNullstr(oldPO.getCyyykqk()))){
            sb.append("【持有优粤卡情况】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_CYYYKQK",oldPO.getCyyykqk()))).
                    append("”变更为“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_CYYYKQK",newPO.getCyyykqk()))).append("”；");
        }
        if(!isNullstr(newPO.getXl()).equals(isNullstr(oldPO.getXl()))){
            sb.append("【学历】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_XL",oldPO.getXl()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_XL",newPO.getXl()))).append("”；");
        }
        if(!isNullstr(newPO.getQrzzgxlbyxxlx()).equals(isNullstr(oldPO.getQrzzgxlbyxxlx()))){
            sb.append("【全日制最高学历毕业学校类型】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_BYXXLX",
                    oldPO.getQrzzgxlbyxxlx()))).
                    append("”变更为“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_BYXXLX",newPO.getQrzzgxlbyxxlx()))).append("”；");
        }
        if(!isNullstr(newPO.getQrzzgxlbyxxmc()).equals(isNullstr(oldPO.getQrzzgxlbyxxmc()))){
            sb.append("【全日制最高学历毕业学校名称】由“").append(isNullstr(oldPO.getQrzzgxlbyxxmc())).append("”变更为“").
                    append(isNullstr(newPO.getQrzzgxlbyxxmc())).append("”；");
        }
        if(!isNullstr(newPO.getQrzzgxlzydl()).equals(isNullstr(oldPO.getQrzzgxlzydl()))){
            sb.append("【全日制最高学历专业大类】由“").append(isNullstr(oldPO.getQrzzgxlzydl())).append("”变更为“").
                    append(isNullstr(newPO.getQrzzgxlzydl())).append("”；");
        }
        if(!isNullstr(newPO.getQrzzgxlzyxl()).equals(isNullstr(oldPO.getQrzzgxlzyxl()))){
            sb.append("【全日制最高学历专业小类】由“").append(isNullstr(oldPO.getQrzzgxlzyxl())).append("”变更为“").
                    append(isNullstr(newPO.getQrzzgxlzyxl())).append("”；");
        }
        if(!isNullstr(newPO.getZcdj()).equals(isNullstr(oldPO.getZcdj()))){
            sb.append("【职称等级】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_ZCDJ",oldPO.getZcdj()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_ZCDJ",newPO.getZcdj()))).append("”；");
        }
        if(!isNullstr(newPO.getZcxl()).equals(isNullstr(oldPO.getZcxl()))){
            sb.append("【职称系列】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_ZCXL",oldPO.getZcxl()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_ZCXL",newPO.getZcxl()))).append("”；");
        }
        if(!isNullstr(newPO.getZczymc()).equals(isNullstr(oldPO.getZczymc()))){
            sb.append("【职称专业名称】由“").append(isNullstr(oldPO.getZczymc())).append("”变更为“").
                    append(isNullstr(newPO.getZczymc())).append("”；");
        }
        if(!isNullstr(newPO.getJndj()).equals(isNullstr(oldPO.getJndj()))){
            sb.append("【技能等级】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_JNDJ",oldPO.getJndj()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_JNDJ",newPO.getJndj()))).append("”；");
        }
        if(!isNullstr(newPO.getJnzy()).equals(isNullstr(oldPO.getJnzy()))){
            sb.append("【技能专业】由“").append(isNullstr(oldPO.getJnzy())).append("”变更为“").
                    append(isNullstr(newPO.getJnzy())).append("”；");
        }
        if(!isNullstr(newPO.getDwmc()).equals(isNullstr(oldPO.getDwmc()))){
            sb.append("【单位名称】由“").append(isNullstr(oldPO.getDwmc())).append("”变更为“").
                    append(isNullstr(newPO.getDwmc())).append("”；");
        }
        if(!isNullstr(newPO.getDwsshy()).equals(isNullstr(oldPO.getDwsshy()))){
            sb.append("【单位所属行业】由“").append(isNullstr(getDictAAA103("JBXX_AAB022",oldPO.getDwsshy()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("JBXX_AAB022",newPO.getDwsshy()))).append("”；");
        }
        if(!isNullstr(newPO.getDwxz()).equals(isNullstr(oldPO.getDwxz()))){
            sb.append("【单位性质】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_DWXZ",oldPO.getDwxz()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_DWXZ",newPO.getDwxz()))).append("”；");
        }
        if(!isNullstr(newPO.getDwgx()).equals(isNullstr(oldPO.getDwgx()))){
            sb.append("【单位管辖】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_DWGX",oldPO.getDwgx()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_DWGX",newPO.getDwgx()))).append("”；");
        }
        if(!isNullstr(newPO.getGwszxsq()).equals(isNullstr(oldPO.getGwszxsq()))){
            sb.append("【单位所在县市区】由“").append(isNullstr(gccrcBLO.getArea(oldPO.getGwszxsq()))).append("”变更为“").
                    append(isNullstr(gccrcBLO.getArea(newPO.getGwszxsq()))).append("”；");
        }
        if(!isNullstr(newPO.getGzgwxz()).equals(isNullstr(oldPO.getGzgwxz()))){
            sb.append("【工作岗位性质】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_GZGWXZ",oldPO.getGzgwxz()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_GZGWXZ",newPO.getGzgwxz()))).append("”；");
        }
        if(!isNullstr(newPO.getLdhtqx()).equals(isNullstr(oldPO.getLdhtqx()))){
            sb.append("【劳动合同期限】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_LDHTQX",oldPO.getLdhtqx()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_LDHTQX",newPO.getLdhtqx()))).append("”；");
        }
        if(!isNullstr(newPO.getLdhtjzrq()).equals(isNullstr(oldPO.getLdhtjzrq()))){
            sb.append("【劳动合同截止日期】由“").append(isNullstr(oldPO.getLdhtjzrq())).append("”变更为“").
                    append(isNullstr(newPO.getLdhtjzrq())).append("”；");
        }
        if(!isNullstr(newPO.getGjjzdrcxmmc()).equals(isNullstr(oldPO.getGjjzdrcxmmc()))){
            sb.append("【国家级重点人才项目名称】由“").append(isNullstr(oldPO.getGjjzdrcxmmc())).append("”变更为“").
                    append(isNullstr(newPO.getGjjzdrcxmmc())).append("”；");
        }
        if(!isNullstr(newPO.getSjjzdrcxmmc()).equals(isNullstr(oldPO.getSjjzdrcxmmc()))){
            sb.append("【省级重点人才项目名称】由“").append(isNullstr(oldPO.getSjjzdrcxmmc())).append("”变更为“").
                    append(isNullstr(newPO.getSjjzdrcxmmc())).append("”；");
        }
        if(!isNullstr(newPO.getShijjzdrcxmmc()).equals(isNullstr(oldPO.getShijjzdrcxmmc()))){
            sb.append("【市级重点人才项目名称】由“").append(isNullstr(oldPO.getShijjzdrcxmmc())).append("”变更为“").
                    append(isNullstr(newPO.getShijjzdrcxmmc())).append("”；");
        }
        if(!isNullstr(newPO.getShzlqk()).equals(isNullstr(oldPO.getShzlqk()))){
            sb.append("【所获专利情况】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_SHZLQK",oldPO.getShzlqk()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_SHZLQK",newPO.getShzlqk()))).append("”；");
        }
        if(!isNullstr(newPO.getShzlmc()).equals(isNullstr(oldPO.getShzlmc()))){
            sb.append("【所获专利名称】由“").append(isNullstr(oldPO.getShzlmc())).append("”变更为“").
                    append(isNullstr(newPO.getShzlmc())).append("”；");
        }
        if(!isNullstr(newPO.getGjjjxmc()).equals(isNullstr(oldPO.getGjjjxmc()))){
            sb.append("【国家级奖项名称】由“").append(isNullstr(oldPO.getGjjjxmc())).append("”变更为“").
                    append(isNullstr(newPO.getGjjjxmc())).append("”；");
        }
        if(!isNullstr(newPO.getSjjxmc()).equals(isNullstr(oldPO.getSjjxmc()))){
            sb.append("【省级奖项名称】由“").append(isNullstr(oldPO.getSjjxmc())).append("”变更为“").
                    append(isNullstr(newPO.getSjjxmc())).append("”；");
        }
        if(!isNullstr(newPO.getShijjxmc()).equals(isNullstr(oldPO.getShijjxmc()))){
            sb.append("【市级奖项名称】由“").append(isNullstr(oldPO.getShijjxmc())).append("”变更为“").
                    append(isNullstr(newPO.getShijjxmc())).append("”；");
        }
        if(!isNullstr(newPO.getRcklx()).equals(isNullstr(oldPO.getRcklx()))){
            sb.append("【认定湛江人才卡类型】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_RCKLX",oldPO.getRcklx()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_RCKLX",newPO.getRcklx()))).append("”；");
        }
        if(!isNullstr(newPO.getTyccid()).equals(isNullstr(oldPO.getTyccid()))){
            sb.append("更新照片；");
        }
        if(!isNullstr(newPO.getRcklx()).equals(isNullstr(oldPO.getRcklx()))||
                !isNullstr(newPO.getDwmc()).equals(isNullstr(oldPO.getDwmc()))&&!oldPO.getQfzt().equals("2")){
            sb.append("【电子卡签发状态】由“").append(getDictAAA103("RS_ZJ_GCCRC_QFZT",oldPO.getQfzt())).append(
                    "”变更为“未签发”；");
        }
        if(!isNullstr(newPO.getRdtj()).equals(isNullstr(oldPO.getRdtj()))){
            sb.append("【认定条件】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_RDTJ",oldPO.getRdtj()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_RDTJ",newPO.getRdtj()))).append("”；");
        }
        if(!isNullstr(newPO.getRdzyyj()).equals(isNullstr(oldPO.getRdzyyj()))){
            sb.append("【认定主要依据】由“").append(isNullstr(oldPO.getRdzyyj())).append("”变更为“").
                    append(isNullstr(newPO.getRdzyyj())).append("”；");
        }
        if(!isNullstr(newPO.getGsqs()).equals(isNullstr(oldPO.getGsqs()))){
            sb.append("【公示期数】由“").append(isNullstr(oldPO.getGsqs())).append("”变更为“").
                    append(isNullstr(newPO.getGsqs())).append("”；");
        }
        if(!isNullstr(newPO.getBz()).equals(isNullstr(oldPO.getBz()))){
            sb.append("【备注】由“").append(isNullstr(oldPO.getBz())).append("”变更为“").
                    append(isNullstr(newPO.getBz())).append("”；");
        }
        if(!isNullstr(newPO.getSqlx()).equals(isNullstr(oldPO.getSqlx()))){
            sb.append("【申请类型】由“").append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_SQLX_JG",oldPO.getSqlx()))).append("”变更为“").
                    append(isNullstr(getDictAAA103("RS_ZJ_GCCRC_SQLX_JG",newPO.getSqlx()))).append("”；");
        }

        if(!isNullstr(newPO.getYdwmc()).equals(isNullstr(oldPO.getYdwmc()))){
            sb.append("【原单位名称】由“").append(isNullstr(oldPO.getYdwmc())).append("”变更为“").
                    append(isNullstr(newPO.getYdwmc())).append("”；");
        }
        if(!isNullstr(newPO.getYdwszd()).equals(isNullstr(oldPO.getYdwszd()))){
            sb.append("【原单位所在地区】由“").append(isNullstr(oldPO.getYdwszd())).append("”变更为“").
                    append(isNullstr(newPO.getYdwszd())).append("”；");
        }
        if(!isNullstr(newPO.getLdhtqsrq()).equals(isNullstr(oldPO.getLdhtqsrq()))){
            sb.append("【劳动合同起始日期】由“").append(isNullstr(oldPO.getLdhtqsrq())).append("”变更为“").
                    append(isNullstr(newPO.getLdhtqsrq())).append("”；");
        }

        if(sb.toString().length()>0){
            return sb.toString().substring(0,sb.toString().length()-1)+"。";
        }
        return " ";
    }
    public int compareDate(String startDay,String endDay,int stype){
        int n = 0;
        String[] u = {"天","月","年"};
        String formatStyle = stype==1?"yyyy-MM":"yyyy-MM-dd";

        DateFormat df = new SimpleDateFormat(formatStyle);
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        try {
            c1.setTime(df.parse(startDay));
            c2.setTime(df.parse(endDay));
        } catch (Exception e3) {

        }
        while (!c1.after(c2)) {
            n++;
            if(stype==1){
                c1.add(Calendar.MONTH, 1);
            }
            else{
                c1.add(Calendar.DATE, 1);
            }
        }
        n = n-1;
        if(stype==2){
            n = (int)n/365;
        }
        return n;
    }
    public String isNullstr(Object str){
        if(str == null || "".equals(str) || "null".equals(str)){
            return "";
        }else{
            return str.toString();
        }
    }
}
