Procházet zdrojové kódy

报告号字典生成规则修改

user5 před 3 roky
rodič
revize
9490f0cbd1

+ 25 - 8
src/main/java/com/jeeplus/modules/serialnum/service/SerialNumTplService.java

@@ -3,13 +3,13 @@
  */
 package com.jeeplus.modules.serialnum.service;
 
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
+import com.jeeplus.common.persistence.Page;
+import com.jeeplus.common.service.CrudService;
 import com.jeeplus.common.utils.DateUtils;
 import com.jeeplus.common.utils.IdGen;
 import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.modules.serialnum.dao.SerialNumTplDao;
+import com.jeeplus.modules.serialnum.entity.SerialNumTpl;
 import com.jeeplus.modules.serialnum.exception.SerialGenException;
 import com.jeeplus.modules.sys.entity.Office;
 import com.jeeplus.modules.sys.entity.User;
@@ -20,10 +20,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.jeeplus.common.persistence.Page;
-import com.jeeplus.common.service.CrudService;
-import com.jeeplus.modules.serialnum.entity.SerialNumTpl;
-import com.jeeplus.modules.serialnum.dao.SerialNumTplDao;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * 编号模板Service
@@ -134,9 +132,13 @@ public class SerialNumTplService extends CrudService<SerialNumTplDao, SerialNumT
             /*map.put("brspnm",office.getBranchSimpleName()==null?"":office.getBranchSimpleName());*/
             String branchShortname = UserUtils.getSysParam("branch_shortname", UserUtils.getUser());
             map.put("brspnm", StringUtils.isBlank(branchShortname)?"":branchShortname);
+
+            String smallYear = new SimpleDateFormat("yy", Locale.CHINESE).format(new Date());
+
 			map.put("year",year);
 			map.put("month",month);
 			map.put("serialNum",sb.toString());
+            map.put("smallYear", StringUtils.isBlank(smallYear)?"":smallYear);
 			String serNum = StringUtils.renderString(serialTpl, map);
 			return serNum;
 		} catch (Exception e) {
@@ -188,11 +190,26 @@ public class SerialNumTplService extends CrudService<SerialNumTplDao, SerialNumT
             if (i!=1){
                 throw new Exception("生成编号失败,请稍后重试");
             }
+            numTpl=dao.get(numTpl.getId());
+            String num = String.valueOf(numTpl.getSerialNum());
+            StringBuffer sb = new StringBuffer();
+            for(int x = 0; x < (numTpl.getSerialNumLen() - num.length()); x++) {
+                sb.append("0");
+            }
+            sb.append(num);
             String companyShortname = UserUtils.getSysParam("company_shortname", UserUtils.getUser());
             map.put("spnm",StringUtils.isBlank(companyShortname)?"":companyShortname);
             String branchShortname = UserUtils.getSysParam("branch_shortname", UserUtils.getUser());
             map.put("brspnm", StringUtils.isBlank(branchShortname)?"":branchShortname);
+
+            String month = DateUtils.formatDate(new Date(), "MM");
+            String smallYear = new SimpleDateFormat("yy", Locale.CHINESE).format(new Date());
+
             map.put("year",year);
+            map.put("month",month);
+            map.put("serialNum",sb.toString());
+            map.put("smallYear", StringUtils.isBlank(smallYear)?"":smallYear);
+
             String serNum = StringUtils.renderString(serialTpl, map);
             return serNum;
         } catch (Exception e) {