客户编码生成修改

This commit is contained in:
yjf 2022-02-24 21:20:22 +08:00
parent 3ba8c38d43
commit dc91e64e70
4 changed files with 84 additions and 88 deletions

View File

@ -5,6 +5,7 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT;
import jbo.com.tenwa.entity.comm.flow.FLOW_WORK_FLAG;
import jbo.com.tenwa.entity.comm.serialutil.T_SERIAL_DISCARD_NUMBER;
@ -41,26 +42,36 @@ public class FlowUtil {
public static synchronized String getRentOutNoNumber(JBOTransaction tx) throws Exception{
return FlowUtil.getSerialNumber("PR{year}{month}{maxOrderNumber}",4,null, "", null, tx);
}
//获取1位的凭证号凭证号--123
public static synchronized String getVoucher_Number(JBOTransaction tx) throws Exception{
return String.valueOf(Integer.parseInt(FlowUtil.getSerialNumber("{maxOrderNumber}",6,null, "凭证号", Integer.parseInt("2018"), tx)));
}
//获取1位的客户编号--123
public static synchronized String getCustomer_Number(JBOTransaction tx) throws Exception{
return String.valueOf(Integer.parseInt(FlowUtil.getSerialNumber("{maxOrderNumber}",15,null, "客户编号", Integer.parseInt("2018"), tx)));
public static synchronized String getCustomer_Number(boolean isCompany ,String custType) throws Exception {
JBOTransaction tx = null;
try {
tx = JBOFactory.createJBOTransaction();
ImmutableMap<String, String> model = ImmutableMap.of("custType", custType);
String serial = FlowUtil.getSerialNumber("APZL{custType}{maxOrderNumber}", 15, model, isCompany?"·¨È˿ͻ§±àºÅ":"¿Í»§±àºÅ", null, tx);
tx.commit();
return serial;
} catch (Exception e) {
if (tx != null) tx.rollback();
throw e;
}
//获取法人customerid--123
public static synchronized String getCustomer_Id(JBOTransaction tx) throws Exception{
return String.valueOf(Integer.parseInt(FlowUtil.getSerialNumber("{maxOrderNumber}",15,null, "法人客户编号", Integer.parseInt("2018"), tx)));
}
//获取经销商编号
public static synchronized String getDistributorSerialNumber(JBOTransaction tx) throws Exception{
return FlowUtil.getSerialNumber("DSTB{year}{month}{day}{maxOrderNumber}",6,null, "经销商编号", null, tx);
}
protected static synchronized String getSerialNumber(String serialNumberPattern,int numberCount,Map<String,String> model,String type,Integer queryYear,JBOTransaction tx) throws Exception
{
String currentDateTime = DateAssistant.getTodayNow();

View File

@ -340,52 +340,57 @@ public class SerialNumberUtil {
* **/
protected static synchronized String getSerialNumberByDay(String serialNumberPattern,int numberCount,Map<String,String> model,String type,Integer queryYear,Integer queryMonth,Integer queryDay,JBOTransaction tx) throws Exception
{
JBOTransaction newTx=JBOFactory.createJBOTransaction();
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0,4);
String monthStr = currentDateTime.substring(5,7);
String dayStr = currentDateTime.substring(8,10);
String hour = currentDateTime.substring(11,13);
String minute = currentDateTime.substring(14,16);
String second = currentDateTime.substring(17,19);
int year = Integer.parseInt(currentYear);
int month = Integer.parseInt(monthStr);
int day = Integer.parseInt(dayStr);
if(null != queryYear){
year = queryYear;
JBOTransaction newTx = null;
try {
newTx = JBOFactory.createJBOTransaction();
String currentDateTime = DateAssistant.getTodayNow();
String currentYear = currentDateTime.substring(0, 4);
String monthStr = currentDateTime.substring(5, 7);
String dayStr = currentDateTime.substring(8, 10);
String hour = currentDateTime.substring(11, 13);
String minute = currentDateTime.substring(14, 16);
String second = currentDateTime.substring(17, 19);
int year = Integer.parseInt(currentYear);
int month = Integer.parseInt(monthStr);
int day = Integer.parseInt(dayStr);
if (null != queryYear) {
year = queryYear;
}
if (null != queryMonth) {
month = queryMonth;
}
if (null != queryDay) {
day = queryDay;
}
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("year", year + "");
paramMap.put("month", monthStr + "");
paramMap.put("day", dayStr + "");
paramMap.put("hour", hour + "");
paramMap.put("minute", minute + "");
paramMap.put("second", second + "");
int maxOrderNumber = getMaxOrderNumberByDay(type, year, month, day, newTx);
StringBuffer numberFormat = new StringBuffer();
for (int i = 0; i < numberCount; i++) {
numberFormat.append("0");
}
DecimalFormat df = new DecimalFormat(numberFormat.toString());
String serialNumberFormat = df.format(maxOrderNumber);
paramMap.put("maxOrderNumber", serialNumberFormat);
if (null != model) {
paramMap.putAll(model);
}
String serialNumberString = getSerialNumber(paramMap, serialNumberPattern);
newTx.commit();
return serialNumberString;
} catch (Exception e) {
if (newTx != null) newTx.rollback();
throw e;
}
if(null != queryMonth){
month = queryMonth ;
}
if(null != queryDay){
day = queryDay ;
}
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("year", year+"");
paramMap.put("month", monthStr+"");
paramMap.put("day", dayStr+"");
paramMap.put("hour", hour+"");
paramMap.put("minute", minute+"");
paramMap.put("second", second+"");
int maxOrderNumber = getMaxOrderNumberByDay(type, year,month,day, newTx);
StringBuffer numberFormat = new StringBuffer();
for(int i=0;i<numberCount;i++)
{
numberFormat.append("0");
}
DecimalFormat df = new DecimalFormat(numberFormat.toString());
String serialNumberFormat = df.format(maxOrderNumber);
paramMap.put("maxOrderNumber", serialNumberFormat);
if(null != model){
paramMap.putAll(model);
}
String serialNumberString = getSerialNumber(paramMap, serialNumberPattern);
newTx.commit();
return serialNumberString;
}
//考虑并发情况必须采用同步机制
@SuppressWarnings("unchecked")

View File

@ -174,15 +174,7 @@ public class NewCustomerCompanyController{
if(customernum!="" && customernum!=null && customernum.length()>0){
newCustomer.setAttributeValue("customer_num", customernum);
}else{
//»ñÈ¡±àÂë¹æÔò
String serinum=FlowUtil.getCustomer_Id(tx);
String serin="";
if(serinum.length()<15){
for(int i=0;i<15-serinum.length();i++){
serin+="0";
}
}
newCustomer.setAttributeValue("customer_num", "APZLC"+serin+serinum);
newCustomer.setAttributeValue("customer_num", FlowUtil.getCustomer_Number(true,"C"));
}
newCustomer.setAttributeValue("inputtime", DateAssistant.getTodayNow());
custManager.saveObject(newCustomer);

View File

@ -229,33 +229,21 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness {
return sMessage;
}
private BizObject saveCustomerInfo(BizObjectManager bomCI,JBOTransaction tx,ASUser asUser,String distributoIid)throws JBOException{
private BizObject saveCustomerInfo(BizObjectManager bomCI,JBOTransaction tx,ASUser asUser,String distributoIid)throws Exception{
BizObject bmC = bomCI.newObject();//保存客户信息
try {
//客户信息表
String custty="03".equals(this.getAttribute("CustomerType"))? "Z":"F";
String serinum=FlowUtil.getCustomer_Number(tx);
String serin="";
if(serinum.length()<15){
for(int i=0;i<15-serinum.length();i++){
serin+="0";
}
}
bmC.setAttributeValue("customername", this.getAttribute("custname"));//自然人名称
bmC.setAttributeValue("customer_num", "APZL"+custty+serin+serinum);//自然人名称
bmC.setAttributeValue("customertype", this.getAttribute("CustomerType"));//客户类型
bmC.setAttributeValue("distributor_id", distributoIid);
bmC.setAttributeValue("certtype", this.getAttribute("certtype"));//证件类型
bmC.setAttributeValue("certid", this.getAttribute("certid"));//证件号
bmC.setAttributeValue("inputuserid", asUser.getUserID());//登记人
bmC.setAttributeValue("inputorgid", asUser.getOrgID());//登记部门
bmC.setAttributeValue("flowunid", this.getAttribute("FlowUnid"));//流程ID
bmC.setAttributeValue("inputtime", StringFunction.getTodayNow());//登记时间,系统当前时间
bomCI.saveObject(bmC);
} catch (Exception e) {
tx.rollback();
e.printStackTrace();
}
//客户信息表
String custty="03".equals(this.getAttribute("CustomerType"))? "Z":"F";
bmC.setAttributeValue("customername", this.getAttribute("custname"));//自然人名称
bmC.setAttributeValue("customer_num", FlowUtil.getCustomer_Number(false,custty));//自然人序号
bmC.setAttributeValue("customertype", this.getAttribute("CustomerType"));//客户类型
bmC.setAttributeValue("distributor_id", distributoIid);
bmC.setAttributeValue("certtype", this.getAttribute("certtype"));//证件类型
bmC.setAttributeValue("certid", this.getAttribute("certid"));//证件号
bmC.setAttributeValue("inputuserid", asUser.getUserID());//登记人
bmC.setAttributeValue("inputorgid", asUser.getOrgID());//登记部门
bmC.setAttributeValue("flowunid", this.getAttribute("FlowUnid"));//流程ID
bmC.setAttributeValue("inputtime", StringFunction.getTodayNow());//登记时间,系统当前时间
bomCI.saveObject(bmC);
return bmC;
}
private void savePersonOrCompany(BizObjectManager bomC,JBOTransaction tx,String colName,String customerId,ASUser asUser,BizObject lbat)throws JBOException{