需求:
合同编码逻辑:
地区简写+00+人员编码+两位数的流水
GZ+00+code+num(01)
分析:
两个地方会涉及到新增签订合同的地方【合同处理中心】和【合同签订】
新增时需要系统带出合同编码,编码规则:地区简写+00+人员编码+两位数的流水号
流水号是以个人签订合同次数作为流水,首次签订为01
代码逻辑:系统原有的ZD编码方式保留,新建逻辑类供调用
代码:
合同新增规则类QueryMakeBillCode.java:
package nc.ui.hrcm.utils;
import java.util.*;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.pub.BusinessException;
public class QueryMakeBillCode {
private IUAPQueryBS iUapQueryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String maxCode = null;
public String getMaxCode(String tablename, String zdCodeBefore,
String pk_org) throws BusinessException {
String sql = "";
int length = 10;
if(tablename.equalsIgnoreCase("hi_psndoc_ctrt"))
sql = (new StringBuilder()).append("select contractnum maxcontractnum from ").append(tablename).append(" where contractnum like '").append(zdCodeBefore).append("%' and length(contractnum) = ").append(length).append(" order by contractnum desc").toString();
else
sql = (new StringBuilder()).append("select contcode maxcontractnum from ").append(tablename).append(" where contcode like '").append(zdCodeBefore).append("%' and length(contcode) = ").append(length).append(" order by contcode desc").toString();
List listResult= (List) iUapQueryBS.executeQuery(sql.toString(), new MapListProcessor());
if (listResult != null) {
for(Iterator i$ = listResult.iterator(); i$.hasNext();)
{
HashMap map = (HashMap)i$.next();
String contcode = (String)map.get("maxcontractnum");
try
{
return contcode;
}
catch(NumberFormatException e)
{
Logger.error(e);
}
}
}
return null;
}
public String getNextCode(String codeStr,String maxCode)
{
if (maxCode == null) {
maxCode = (codeStr + "01");
} else {
maxCode= (maxCode.substring(0, 8) + getNextFlowNumBuCur(maxCode.substring(8)));
}
return maxCode;
}
public String getCodeStr(String pk_org,String psncode) {
String zdCodeBefore=""+psncode;
if ("00016H10000000000BH1".equals(pk_org)) {
zdCodeBefore="GZ00"+psncode;
}else if (pk_org=="00016H10000000000BHZ") {
zdCodeBefore="SZ00"+psncode;
}else if (pk_org=="00016H10000000000BGG") {
zdCodeBefore="BJ00"+psncode;
}else if (pk_org=="00016H10000000000BGQ") {
zdCodeBefore="DG00"+psncode;
}else if (pk_org=="00016H10000000000BHK") {
zdCodeBefore="SH00"+psncode;
}else if (pk_org=="00016H10000000000BHN") {
zdCodeBefore="SU00"+psncode;
}
return zdCodeBefore;
}
private String getNextFlowNumBuCur(String substring) {
int cur = Integer.parseInt(substring);
cur++;
String str = "";
if (cur < 10) {
str = "0";
}
return str + cur;
}
}
合同编码调用显示类,即合同新增类:合同签订类PsnWizardStepListener
package nc.ui.hrcm.make.wizard.listener;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.hr.utils.BillCodeHelper;
import nc.hr.utils.HRCMTermUnitUtils;
import nc.hr.utils.PubEnv;
import nc.hr.utils.ResHelper;
import nc.itf.hr.frame.IHrBillCode;
import nc.itf.hrcm.IQueryMakeService;
import nc.itf.hrcm.ITempletBatchQueryService;
import nc.pub.billcode.vo.BillCodeContext;
import nc.pub.tools.HRCMUtils;
import nc.pub.tools.HiCacheUtils;
import nc.ui.bd.ref.AbstractRefModel;
import nc.ui.hrcm.make.CMTemplateContainer;
import nc.ui.hrcm.make.MakeAppModelService;
import nc.ui.hrcm.make.factory.CMMethodFactory;
import nc.ui.hrcm.make.factory.WizardFirstInterface;
import nc.ui.hrcm.make.model.MakeAppModelDataManager;
import nc.ui.hrcm.make.model.MakeBillManageModel;
import nc.ui.hrcm.make.view.MakeUtil;
import nc.ui.hrcm.make.view.ShereBillForm;
import nc.ui.hrcm.make.wizard.panel.CtrtBillForm;
import nc.ui.hrcm.processor.CardCheckProcessorImpl;
import nc.ui.hrcm.utils.DefauteCode;
import nc.ui.hrcm.utils.QueryMakeBillCode;
import nc.ui.pub.beans.UIRefPane;
import nc.ui.pub.beans.wizard.IWizardStepListener;
import nc.ui.pub.beans.wizard.WizardModel;
import nc.ui.pub.beans.wizard.WizardStep;
import nc.ui.pub.beans.wizard.WizardStepEvent;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillItem;
import nc.ui.uif2.model.AbstractAppModel;
import nc.vo.hi.psndoc.CtrtVO;
import nc.vo.hrcm.contopinion.ContopinionVO;
import nc.vo.hrcm.share.PsnSelListVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.IAttributeMeta;
import nc.vo.pub.IVOMeta;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFLiteralDate;
import nc.vo.uif2.LoginContext;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
public class PsnWizardStepListener
implements IWizardStepListener
{
private ITempletBatchQueryService templetBatchQueryService;
public void stepActived(WizardStepEvent event)
{
WizardStep prestep = event.getPreStep();
if (prestep == null) {
return;
}
WizardStep step0 = event.getStep();
WizardModel model = step0.getModel();
WizardStep step1 = (WizardStep)model.getSteps().get(model.getCurStepIndex() + 1);
CtrtBillForm form = (CtrtBillForm)step1.getComp();
AbstractAppModel outMode = form.getMode();
MakeBillManageModel makeMode = (MakeBillManageModel)outMode;
makeMode.rollBackCode();
}
private SuperVO[] getValidateVOs(PsnSelListVO[] selPsnInf)
{
String[] psndocPks = new String[selPsnInf.length];
for (int i = 0; i < selPsnInf.length; i++) {
psndocPks[i] = selPsnInf[i].getPk_psndoc();
}
SuperVO[] vos = null;
try
{
vos = ((IQueryMakeService)NCLocator.getInstance().lookup(IQueryMakeService.class)).getValidateVOsByPsndocPks(psndocPks);
}
catch (BusinessException e)
{
Logger.error(e);
}
return vos;
}
public void stepDisactived(WizardStepEvent event)
{
WizardStep step0 = event.getStep();
WizardModel model = step0.getModel();
WizardStep step1 = (WizardStep)model.getSteps().get(model.getCurStepIndex() + 1);
PsnSelListVO[] selPsnInf = (PsnSelListVO[])step0.getAttr("psnSelectList");
step1.putAttr("psnList", selPsnInf);
SuperVO[] validateVOs = getValidateVOs(selPsnInf);
step1.putAttr("validateVOs", validateVOs);
CtrtBillForm form = (CtrtBillForm)step1.getComp();
AbstractAppModel outMode = form.getMode();
MakeBillManageModel makeMode = (MakeBillManageModel)outMode;
ShereBillForm billForm = form.getBillForm();
Object value = billForm.getValue();
BillCardPanel cardPanel = billForm.getBillCardPanel();
PsnSelListVO firstVO = selPsnInf[0];
AbstractAppModel appModle = billForm.getModel();
String modeName = "hi_psndoc_ctrt";
if ((appModle instanceof MakeBillManageModel)) {
modeName = ((MakeBillManageModel)appModle).getModeName();
}
LoginContext context = appModle.getContext();
String pk_org = context.getPk_org();
String pk_group = context.getPk_group();
String nodecode = context.getNodeCode();
UFDateTime date = PubEnv.getServerTime();
UFLiteralDate literalDate = new UFLiteralDate(date.getDate().toStdString());
Integer conttype = Integer.valueOf(HRCMUtils.getNodeCodeTermType(appModle.getContext().getNodeCode()));
ContopinionVO[] contopinionVOs = (ContopinionVO[])step0.getAttr("contopinionVO");
setContCode((SuperVO)value, selPsnInf, modeName, context, cardPanel, makeMode);
PsnSelListVO pslvo = new PsnSelListVO();
if (!ArrayUtils.isEmpty(selPsnInf))
{
StringBuffer code = new StringBuffer();
StringBuffer name = new StringBuffer();
StringBuffer conractnum = new StringBuffer();
for (int i = 0; i < selPsnInf.length; i++)
{
if (i == 3)
{
code.append("...");
name.append("...");
conractnum.append("...");
break;
}
code.append(",").append(selPsnInf[i].getPsncode());
name.append(",").append(selPsnInf[i].getPsnname());
conractnum.append(",").append(selPsnInf[i].getVcontractnum());
}
pslvo.setPsncode(code.toString().substring(1));
pslvo.setPsnname(name.toString().substring(1));
pslvo.setVcontractnum(conractnum.toString().substring(1));
}
if (("60110extend".equals(nodecode)) || ("60110change".equals(nodecode)) || ("60110release".equals(nodecode)) || ("60110finish".equals(nodecode)))
{
CMTemplateContainer template = (CMTemplateContainer)form.getBillForm().getTemplateContainer();
HashMap<String, Class<?>> protocolNodeKeyToClassMap = template.getProtocolNodeKeyToClassMap();
Class contClass = (Class)protocolNodeKeyToClassMap.get(form.getBillForm().getNodekey());
MakeAppModelService service = (MakeAppModelService)((MakeBillManageModel)appModle).getService();
IQueryMakeService queryService = service.getQueryService();
SuperVO svo = null;
try
{
svo = (SuperVO)queryService.queryByPk(firstVO.getPk_cont(), contClass);
if ("60110extend".equals(nodecode))
{
if (selPsnInf.length == 1)
{
UFLiteralDate oldEnddate = (UFLiteralDate)svo.getAttributeValue("enddate");
UFLiteralDate begindate = oldEnddate == null ? literalDate : ((UFLiteralDate)oldEnddate.clone()).getDateAfter(1);
if (ArrayUtils.isEmpty(contopinionVOs))
{
svo.setAttributeValue("begindate", begindate.clone());
String termtype = (String)svo.getAttributeValue("termtype");
if (StringUtils.isNotBlank(termtype)) {
if ("CM01".equals(termtype))
{
svo.setAttributeValue("enddate", null);
svo.setAttributeValue("termmonth", null);
}
else if (("CM02".equals(termtype)) || ("CM03".equals(termtype)))
{
svo.setAttributeValue("termmonth", null);
svo.setAttributeValue("enddate", null);
}
else
{
svo.setAttributeValue("termmonth", svo.getAttributeValue("termmonth"));
svo.setAttributeValue("enddate", svo.getAttributeValue("enddate"));
}
}
}
else
{
svo.setAttributeValue("termtype", contopinionVOs[0].getTermtype());
svo.setAttributeValue("termmonth", contopinionVOs[0].getItermmonth());
svo.setAttributeValue("begindate", begindate.clone());
svo.setAttributeValue("enddate", contopinionVOs[0].getSedenddate());
}
oldEnddate = null;
begindate = null;
}
else if (selPsnInf.length > 1)
{
svo.setAttributeValue("begindate", null);
MakeUtil.getHeadItem(cardPanel, "begindate").setEnabled(Boolean.FALSE.booleanValue());
MakeUtil.getHeadItem(cardPanel, "begindate").setNull(false);
if (!ArrayUtils.isEmpty(contopinionVOs))
{
svo.setAttributeValue("termtype", contopinionVOs[0].getTermtype());
svo.setAttributeValue("termmonth", contopinionVOs[0].getItermmonth());
svo.setAttributeValue("enddate", contopinionVOs[0].getSedenddate());
}
}
}
else
{
svo.setAttributeValue("begindate", svo.getAttributeValue("begindate"));
svo.setAttributeValue("enddate", svo.getAttributeValue("enddate"));
}
UFLiteralDate begin = (UFLiteralDate)svo.getAttributeValue("begindate");
UFLiteralDate end = (UFLiteralDate)svo.getAttributeValue("enddate");
if ((begin != null) && (end != null)) {
if (((UFLiteralDate)begin.clone()).after((UFLiteralDate)end.clone())) {
svo.setAttributeValue("enddate", null);
}
}
begin = null;
end = null;
SuperVO newVO = (SuperVO)contClass.newInstance();
newVO.setAttributeValue("conttype", conttype);
newVO.setAttributeValue("signdate", literalDate.clone());
newVO.setAttributeValue("begindate", svo.getAttributeValue("begindate"));
newVO.setAttributeValue("enddate", svo.getAttributeValue("enddate"));
newVO.setAttributeValue("pk_psndoc", svo.getAttributeValue("pk_psndoc"));
newVO.setAttributeValue("pk_psnorg", svo.getAttributeValue("pk_psnorg"));
newVO.setAttributeValue("assgid", svo.getAttributeValue("assgid"));
newVO.setAttributeValue("pk_psnjob", svo.getAttributeValue("pk_psnjob"));
newVO.setAttributeValue("pk_group", svo.getAttributeValue("pk_group"));
newVO.setAttributeValue("pk_conttext", svo.getAttributeValue("pk_conttext"));
newVO.setAttributeValue("pk_majorcorp", svo.getAttributeValue("pk_majorcorp"));
newVO.setAttributeValue("signaddr", svo.getAttributeValue("signaddr"));
newVO.setAttributeValue("creator", svo.getAttributeValue("creator"));
newVO.setAttributeValue("creationtime", svo.getAttributeValue("creationtime"));
newVO.setAttributeValue("contid", svo.getAttributeValue("contid"));
newVO.setAttributeValue("cont_unit", svo.getAttributeValue("cont_unit"));
if (svo.getAttributeValue("termmonth") != null) {
newVO.setAttributeValue("termmonth", svo.getAttributeValue("termmonth"));
}
if ("hi_psndoc_ctrt".equals(modeName))
{
newVO.setAttributeValue("contractnum", svo.getAttributeValue("contractnum"));
newVO.setAttributeValue("termtype", svo.getAttributeValue("termtype"));
newVO.setAttributeValue("continuetime", svo.getAttributeValue("continuetime"));
}
else
{
newVO.setAttributeValue("contcode", svo.getAttributeValue("contcode"));
}
setGlbdef(nodecode, svo, newVO);
if ("60110release".equals(nodecode))
{
if ("hi_psndoc_ctrt".equals(modeName))
{
newVO.setAttributeValue("presenter", "1");
String tablename = MakeUtil.getTablename(cardPanel);
UIRefPane pane = (UIRefPane)cardPanel.getHeadItem(tablename + ".pk_unchreason").getComponent();
pane.getRefModel().setPara1("1002Z71000000000PJRJ");
pane.getRefModel().setCacheEnabled(false);
pane.getRefModel().setRefNodeName(ResHelper.getString("6011make", "06011make0093"));
}
else
{
String tablename = MakeUtil.getTablename(cardPanel);
UIRefPane pane = (UIRefPane)cardPanel.getHeadItem(tablename + ".pk_unchreason").getComponent();
pane.getRefModel().setPara1("1002Z71000000000PJRM");
pane.getRefModel().setRefTitle(ResHelper.getString("6011make", "06011make0094"));
}
}
else if ("60110finish".equals(nodecode)) {
if ("hi_psndoc_ctrt".equals(modeName))
{
String tablename = MakeUtil.getTablename(cardPanel);
UIRefPane pane = (UIRefPane)cardPanel.getHeadItem(tablename + ".pk_unchreas