/** @param 从业人员信息(t_qyryxx) 修改与t_qyryxx表有直接或间接外键关联的所有表的qyid,但不包括人员历史表 */ public boolean updateQyryxxForeignKey(Qyryxx qyryxx, Qyryxx qyryxx_bak) { int ryid_bak = qyryxx_bak.getRyid(); int qyid_bak = qyryxx_bak.getQyid(); boolean isSuccess = false; Qyryxx qyryxxlz = new Qyryxx(); qyryxxlz.setRyid(qyryxx_bak.getRyid()); Date currentDate = new Date(); qyryxxlz.setScbz(2); qyryxxDao.updateQyryxx(qyryxxlz); // 插入旧的从业人员信息,企业id改变了 Qyryxx qyryxxOld = new Qyryxx(); qyryxxOld = qyryxx_bak; qyryxxOld.setQyid(qyryxx.getQyid()); qyryxxOld = qyryxxDao.insertQyryxx(qyryxxOld); qyryxx.setRyid(qyryxxOld.getRyid()); // 更新新插入的信息 qyryxxDao.updateQyryxx(qyryxx); // 更新icksl表 Qyjbxx qyjbxxa = new Qyjbxx(); qyjbxxa.setQyid(qyryxx.getQyid()); qyjbxxa = qyjbxxDao.getQyjbxx(qyjbxxa); /*Icksl icksla = new Icksl(); icksla.setRyid(ryid_bak); icksla.setZxbz("0"); icksla =ickslDao.getIckslyj(icksla);//拿出这个ryid的最后的icksl记录 Icksl ickslgx = new Icksl(); ickslgx.setIckslid(icksla.getIckslid()); ickslgx.setQybm(qyjbxxa.getQybm()); ickslgx.setQyid(qyjbxxa.getQyid()); ickslgx.setRyid(qyryxx.getRyid()); ickslgx.setHylbdm(qyryxx.getHylbdm()); ickslgx.setHylb(qyryxx.getHylb()); ickslDao.updateIckslByqybg(ickslgx);*/ // 更新qyrysh Qyrysh qyrysh = new Qyrysh(); qyrysh.setRyid(ryid_bak); qyrysh.setQyid(qyjbxxa.getQyid()); qyrysh.setNewRyid(qyryxx.getRyid()); isSuccess = qyryshDao.updateQyryshByqybg(qyrysh) > 0; // 新插入从表数据 int ryid = qyryxx.getRyid(); int qyid = qyryxx.getQyid(); // 照片 Qyry_zp qyry_zp = new Qyry_zp(); qyry_zp.setRyid(ryid_bak); qyry_zp.setQyid(qyid_bak); qyry_zp.setTplx("0"); qyry_zp = qyry_zpDao.getQyry_zp(qyry_zp); if (qyry_zp != null) { qyry_zp.setRyid(ryid); qyry_zp.setQyid(qyid); qyry_zpDao.updateQyrybg_zp(qyry_zp); qyryxx.setZpid(qyry_zp.getZpid()); } // 外国 Wgcyryxx wgcyryxx = new Wgcyryxx(); wgcyryxx.setRyid(ryid_bak); wgcyryxx.setQyid(qyid_bak); wgcyryxx = wgcyryxxDao.getWgcyryxx(wgcyryxx); if (wgcyryxx != null) { wgcyryxx.setRyid(ryid); wgcyryxx.setQyid(qyid); wgcyryxxDao.insertWgcyryxx(wgcyryxx); } // 奖惩 Ryjcxx ryjcxx = new Ryjcxx(); ryjcxx.setRyid(ryid_bak); ryjcxx.setQyid(qyid_bak); List list = ryjcxxDao.getListRyjcxx(ryjcxx); if (list != null) { for (int i = 0; i < list.size(); i++) { ryjcxx = (Ryjcxx) list.get(i); ryjcxx.setRyid(ryid); ryjcxx.setQyid(qyid); ryjcxxDao.insertRyjcxx(ryjcxx); } } // 核查 Qyryxxhc qyryxxhc = new Qyryxxhc(); qyryxxhc.setRyid(ryid_bak); qyryxxhc.setQyid(qyid_bak); qyryxxhc = qyryxxhcDao.getQyryxxhc(qyryxxhc); if (qyryxxhc != null) { qyryxxhc.setRyid(ryid); qyryxxhc.setQyid(qyid); qyryxxhcDao.insertQyryxxhc(qyryxxhc); } // 体检 Qyry_tjxx qyry_tjxx = new Qyry_tjxx(); qyry_tjxx.setRyid(ryid_bak); qyry_tjxx.setQyid(qyid_bak); List listTjxx = qyry_tjxxDao.getListQyry_tjxx(qyry_tjxx); if (listTjxx != null) { for (int j = 0; j < listTjxx.size(); j++) { qyry_tjxx = (Qyry_tjxx) listTjxx.get(j); qyry_tjxx.setRyid(ryid); qyry_tjxx.setQyid(qyid); qyry_tjxxDao.insertQyry_tjxx(qyry_tjxx); } } qyryxx_bak.setRyid(ryid_bak); qyryxx_bak.setQyid(qyid_bak); return isSuccess; }
/** @param 企业人员信息(t_qyryxx) 修改 */ public boolean updateQyryxx(Qyryxx qyryxx) throws Exception { // qyryxx.setQyid(2); // TODO: implement boolean isSuccess = false; Date currentDate = new Date(); Qyry_zp qyry_zp = new Qyry_zp(); Wgcyryxx wgcyryxx = new Wgcyryxx(); // 保存人员历史信息 Qyryxx_lsxx qyryxx_lsxx = new Qyryxx_lsxx(); Qyryxx qyryxx_bak = new Qyryxx(); Wgcyryxx wgcyryxx_bak = new Wgcyryxx(); qyryxx_bak.setRyid(qyryxx.getRyid()); wgcyryxx_bak.setRyid(qyryxx.getRyid()); qyryxx_bak = qyryxxDao.getQyryxx(qyryxx_bak); wgcyryxx_bak = wgcyryxxDao.getWgcyryxx(wgcyryxx_bak); if (qyryxx_bak != null) BeanUtils.copyProperties(qyryxx_lsxx, qyryxx_bak); if (wgcyryxx_bak != null) BeanUtils.copyProperties(qyryxx_lsxx, wgcyryxx_bak); qyryxx_lsxx.setCzlx("修改"); qyryxx_lsxx.setBcsj(new Date()); qyryxx_lsxx = qyryxx_lsxxDao.insertQyryxx_lsxx(qyryxx_lsxx); // 修改从业人员信息表 if ("11".equals(qyryxx.getCyryztdm())) { qyryxx.setIslzrqNull("1"); } else if (null == qyryxx.getLzrq() || "".equals(qyryxx.getLzrq())) { qyryxx.setCyryzt("在职"); qyryxx.setIslzrqNull("1"); } else { qyryxx.setCyryzt("离职"); } if (qyryxx.getWgcyryxx() == null) { if (qyryxx_bak.getZt() != null) { if (qyryxx_bak.getZt().equals("2")) { qyryxx.setZt("3"); } else if (qyryxx_bak.getZt().equals("0")) { if ("1".equals(qyryxx.getZjzt())) { qyryxx.setZt("5"); } } else if (qyryxx_bak.getZt().equals("11")) { qyryxx.setZt("12"); } } } else { // 若为境外从业人员,则姓名字段为英文名+" "+英文姓 if (qyryxx.getXm() == null || "".equals(qyryxx.getXm())) { qyryxx.setXm(qyryxx.getWgcyryxx().getYwm() + " " + qyryxx.getWgcyryxx().getYwx()); } if (qyryxx_bak.getZt() != null) { if (qyryxx_bak.getZt().equals("2")) { qyryxx.setZt("3"); } else if (qyryxx_bak.getZt().equals("11")) { qyryxx.setZt("12"); } } } if (qyryxx.getXm() != null) qyryxx.setXmpy(PinYinUtil.getHanyuPingYin(qyryxx.getXm())); int zpidfalg = 0; // 0 表示没有变更企业,1表示变更企业了 // 若从业人员服务场所改变,则需修改与t_cyryxx表有直接或间接外键关联的所有表的qyid,但不包括人员历史表和IC卡受理变更表 if (!qyryxx_bak.getQyid().equals(qyryxx.getQyid())) { Qyjbxx qyjbxxNow = new Qyjbxx(); qyjbxxNow.setQyid(qyryxx.getQyid()); qyjbxxNow = qyjbxxDao.getQyjbxx(qyjbxxNow); qyryxx.setHylbdm(qyjbxxNow.getHylbdm()); qyryxx.setHylb(qyjbxxNow.getHylb()); updateQyryxxForeignKey(qyryxx, qyryxx_bak); zpidfalg = 1; } else { qyryxxDao.updateQyryxx(qyryxx); } // 更新账号 String errCode = "0"; qyryxx.setGwbh(qyryxx_bak.getGwbh()); errCode = updateUser(qyryxx, qyryxx_bak); if (errCode.equals("1")) return false; if (null != qyryxx.getLzrq() && !"".equals(qyryxx.getLzrq())) { //// 注销员工用户 int errResult = 0; if (sczhFlag(qyryxx.getHylbdm(), qyryxx.getGwbh()).equals("1")) { if (getUser(qyryxx.getCyrybh()).equals("1")) { GgQyyh qyyh = new GgQyyh(); qyyh.setRyid(qyryxx.getRyid()); qyyh.setIsval("0"); // 是否可见 errResult = ggQyyhDao.zhuxQyYgyh(qyyh); } } } else { int errResult = 0; if (sczhFlag(qyryxx.getHylbdm(), qyryxx.getGwbh()).equals("1")) { if (getUser(qyryxx.getCyrybh()).equals("1")) { GgQyyh qyyh = new GgQyyh(); qyyh.setRyid(qyryxx.getRyid()); qyyh.setIsval("1"); // 是否可见 errResult = ggQyyhDao.zhuxQyYgyh(qyyh); } } } // 修改从业人员照片表 if (qyryxx.getQyry_zp() != null) { // 照片 Qyry_zp qyry_zpbak = new Qyry_zp(); qyry_zpbak.setRyid(qyryxx_bak.getRyid()); qyry_zpbak.setQyid(qyryxx_bak.getQyid()); qyry_zpbak.setTplx("0"); qyry_zpbak = qyry_zpDao.getQyry_zp(qyry_zpbak); if (qyry_zpbak == null) { // 无,新增 qyry_zp = qyryxx.getQyry_zp(); qyry_zp.setRyid(qyryxx.getRyid()); qyry_zp.setQyid(qyryxx.getQyid()); qyry_zp.setTplx("0"); qyry_zp = qyry_zpDao.insertQyry_zp(qyry_zp); qyryxx.setZpid(qyry_zp.getZpid()); } else { // 有,更新 qyry_zp = qyryxx.getQyry_zp(); qyry_zp.setTplx("0"); qyry_zp.setRyid(qyryxx.getRyid()); if (zpidfalg == 1) { qyry_zp.setZpid(qyryxx.getZpid()); } qyry_zpDao.updateQyry_zp(qyry_zp); } } // 若从业人员状态为5-证件号码错,则插入从业人员核查表 if (qyryxx.getWgcyryxx() == null) { if ("5".equals(qyryxx.getZt())) { Garkktbsj garkktbsj = new Garkktbsj(); garkktbsj = garkktbsjService.insertGarkktbsj(garkktbsj); Qyryxxhc qyryxxhc = new Qyryxxhc(); qyryxxhc.setRyid(qyryxx.getRyid()); qyryxxhc.setGarkktbsjid(garkktbsj.getGarkktbsjid()); qyryxxhc.setHcwt("证件号码错"); qyryxxhcService.insertQyryxxhcByRyid(qyryxxhc); } } // 更新外国从业人员信息 if (qyryxx.getWgcyryxx() != null) { wgcyryxx = qyryxx.getWgcyryxx(); wgcyryxx.setRyid(qyryxx.getRyid()); wgcyryxxDao.updateWgcyryxx(wgcyryxx); } // 更新场所总人数 if (!qyryxx_bak.getQyid().equals(qyryxx.getQyid())) { Map map = new HashMap(); map.put("p_oldQyid", qyryxx_bak.getQyid()); map.put("p_newQyid", qyryxx.getQyid()); qyZrsProcDao.updateQyzrs(map); } // 人员信息操作日志 Qyjbxx qyjbxx = new Qyjbxx(); qyjbxx.setQyid(qyryxx.getQyid()); qyjbxx = qyjbxxDao.getQyjbxx(qyjbxx); Ryxxczrz ryxxczrz = new Ryxxczrz(); ryxxczrz.setCzsj(currentDate); ryxxczrz.setCzlx("修改"); ryxxczrz.setCzr(qyryxx.getCzr()); ryxxczrz.setQybm(qyjbxx.getQybm()); ryxxczrz.setCyrybh(qyryxx_bak.getCyrybh()); ryxxczrzDao.insertRyxxczrz(ryxxczrz); isSuccess = true; return isSuccess; }