批次号自动生产工具类

master
Yangwl 7 months ago
parent a62f1b43de
commit 6e74b25f6a

@ -164,4 +164,12 @@ public class Constants {
//ZL0030-品质异常流程 //ZL0030-品质异常流程
public static final Integer WORKFLOWID_ZL0030=26256; public static final Integer WORKFLOWID_ZL0030=26256;
//榄菊集团缩写
public static final String LJ="LJ";
//产出状态
public static final String OUTPUT_STATUS_A="A";
} }

@ -1,15 +1,15 @@
package com.op.common.core.utils; package com.op.common.core.utils;
import java.util.Collection; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import com.op.common.core.constant.Constants; import com.op.common.core.constant.Constants;
import com.op.common.core.text.StrFormatter; import com.op.common.core.text.StrFormatter;
/** /**
* *
* *
* @author OP * @author OP
*/ */
public class StringUtils extends org.apache.commons.lang3.StringUtils { public class StringUtils extends org.apache.commons.lang3.StringUtils {
@ -21,7 +21,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param value defaultValue value * @param value defaultValue value
* @return value * @return value
*/ */
@ -31,7 +31,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * Collection ListSetQueue * * Collection ListSetQueue
* *
* @param coll Collection * @param coll Collection
* @return true false * @return true false
*/ */
@ -41,7 +41,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * CollectionListSetQueue * * CollectionListSetQueue
* *
* @param coll Collection * @param coll Collection
* @return true false * @return true false
*/ */
@ -51,7 +51,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param objects * @param objects
** @return true false ** @return true false
*/ */
@ -61,7 +61,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param objects * @param objects
* @return true false * @return true false
*/ */
@ -71,7 +71,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * Map * * Map
* *
* @param map Map * @param map Map
* @return true false * @return true false
*/ */
@ -81,7 +81,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * Map * * Map
* *
* @param map Map * @param map Map
* @return true false * @return true false
*/ */
@ -91,7 +91,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param str String * @param str String
* @return true false * @return true false
*/ */
@ -101,7 +101,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param str String * @param str String
* @return true false * @return true false
*/ */
@ -111,7 +111,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param object Object * @param object Object
* @return true false * @return true false
*/ */
@ -121,7 +121,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * * *
* *
* @param object Object * @param object Object
* @return true false * @return true false
*/ */
@ -131,7 +131,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* * Java * * Java
* *
* @param object * @param object
* @return true false * @return true false
*/ */
@ -148,7 +148,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param str * @param str
* @param start * @param start
* @return * @return
@ -174,7 +174,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param str * @param str
* @param start * @param start
* @param end * @param end
@ -212,7 +212,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param str value * @param str value
* @return * @return
*/ */
@ -238,7 +238,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* 使format("this is {} for {}", "a", "b") -> this is a for b<br> * 使format("this is {} for {}", "a", "b") -> this is a for b<br>
* {} format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> * {} format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
* \ format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> * \ format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
* *
* @param template {} * @param template {}
* @param params * @param params
* @return * @return
@ -252,7 +252,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* http(s)://开头 * http(s)://开头
* *
* @param link * @param link
* @return * @return
*/ */
@ -321,7 +321,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param str * @param str
* @param strs * @param strs
* @return true * @return true
@ -340,7 +340,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* 线线 * 线线
* HELLO_WORLD->HelloWorld * HELLO_WORLD->HelloWorld
* *
* @param name 线 * @param name 线
* @return * @return
*/ */
@ -398,7 +398,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* *
* *
* @param str * @param str
* @param strs * @param strs
* @return * @return
@ -417,7 +417,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* url: ? ; * ; ** ; * url: ? ; * ; ** ;
* *
* @param pattern * @param pattern
* @param url url * @param url url
* @return * @return
@ -434,7 +434,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* 0使size size * 0使size size
* *
* @param num * @param num
* @param size * @param size
* @return * @return
@ -445,7 +445,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* ssizesize * ssizesize
* *
* @param s * @param s
* @param size * @param size
* @param c * @param c
@ -470,4 +470,35 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
} }
return sb.toString(); return sb.toString();
} }
/**
*
* @param factoryCode
* @param lineCode 线
* @param productDate
* @param version
* @param productStatus A
* @param content (0)
* @return
*/
public static final List<String> batchAutoCreate(String factoryCode, String lineCode, Date productDate,String version, String content,int batchNum){
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyyMMdd");
// Create a Calendar instance and set it to the current date
Calendar calendar = Calendar.getInstance();
calendar.setTime(productDate);
// Add three years to the current date
calendar.add(Calendar.YEAR, 3);
// Subtract one day from the new date
calendar.add(Calendar.DAY_OF_MONTH, -1);
// Get the new date
Date futureDate = calendar.getTime();
// Format the new date
String toValidity = targetFormat.format(futureDate);
List<String> batchList=new ArrayList<>();
for (char letter = 'A'; letter < 'A' + batchNum; letter++) {
String BatchCode=toValidity+Constants.LJ+targetFormat.format(productDate)+lineCode+factoryCode+letter+Constants.OUTPUT_STATUS_A+content+version;
batchList.add(BatchCode);
}
return batchList;
}
} }

Loading…
Cancel
Save