|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getNewCode(Map<String, String> map) { | 
|---|
|  |  |  | SysCodeRule codeRule = baseDao.getCodeRule(map); | 
|---|
|  |  |  | String newCodeTemplet = codeRule.getFunCode(); | 
|---|
|  |  |  | String newCodeTemplet = codeRule.getCodeRule(); | 
|---|
|  |  |  | if (map.get("projectId")!=null){ | 
|---|
|  |  |  | String projectIdentity = baseDao.getProjectIdentity(map.get("projectId")); | 
|---|
|  |  |  | newCodeTemplet = newCodeTemplet.replace("[项目编号]",projectIdentity); | 
|---|
|  |  |  | 
|---|
|  |  |  | String year = sdf.format(new Date()); | 
|---|
|  |  |  | newCodeTemplet = newCodeTemplet.replace("[年份]",year); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String xhTemplet = StringUtils.substring("__________",0,codeRule.getNoByteNum()-1); | 
|---|
|  |  |  | String xhTemplet = StringUtils.substring("__________",0,codeRule.getNoByteNum()); | 
|---|
|  |  |  | newCodeTemplet = newCodeTemplet.replace("[序号]",xhTemplet); | 
|---|
|  |  |  | int xhStartPosition = newCodeTemplet.indexOf(xhTemplet); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String maxCode = baseDao.getMaxCode(codeRule.getTableName(),newCodeTemplet); | 
|---|
|  |  |  | String maxCodeXh = "0"; | 
|---|
|  |  |  | if (StringUtils.isNotBlank(maxCode)) | 
|---|
|  |  |  | maxCodeXh = StringUtils.substring(maxCode,xhStartPosition,xhStartPosition+codeRule.getNoByteNum()-1); | 
|---|
|  |  |  | String newCodeXh = String.format("%0"+codeRule.getNoByteNum()+"d", Convert.toInt(maxCodeXh)+1); | 
|---|
|  |  |  | maxCodeXh = StringUtils.substring(maxCode,xhStartPosition,xhStartPosition+codeRule.getNoByteNum()); | 
|---|
|  |  |  | Integer a = Convert.toInt(maxCodeXh)+1; | 
|---|
|  |  |  | String newCodeXh = String.format("%0"+codeRule.getNoByteNum()+"d", a); | 
|---|
|  |  |  | String newCode = newCodeTemplet.replace(xhTemplet,newCodeXh); | 
|---|
|  |  |  | return newCode; | 
|---|
|  |  |  | } | 
|---|