财报代码编写

This commit is contained in:
lvleigang 2025-04-29 14:21:02 +08:00
parent 9c15c7d45a
commit ff5d5e357b
2 changed files with 115 additions and 10 deletions

View File

@ -343,7 +343,7 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
* @return void
**/
private void saveMaterielToU8(List<ZjMaterielSynchronizationEventEntity> list,List<InventoryEntity> inventoryEntities) throws Exception {
Map<String,Integer> lsh = new HashMap<>();//当前流水号
Map<String,String> lsh = new HashMap<>();//当前流水号
List<InventoryEntity> savedata = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
@ -352,7 +352,7 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
InventorySubEntity inventorySubEntity = new InventorySubEntity();
//获取最大流水号
Integer maxnum = null;
String maxnum = null;
StringBuffer wlcode = new StringBuffer();
//设置编码
@ -382,9 +382,29 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
entity.setQuerycode(entity.getField0043code());
String num = zjMaterielSynchronizationEventDao.queryMaxLsh(entity);
num = num.substring(entity.getField0043code().length(),entity.getField0043code().length()+4);
maxnum = Integer.valueOf(num);
maxnum = num;
}
String formattedNum = String.format("%04d", ++maxnum);
String formattedNum = null;
char firstChar = Character.toUpperCase(maxnum.charAt(0));
if("9999".equals(maxnum)){
maxnum = "A000";
formattedNum = "A000";
}else if(firstChar >= 'A' && firstChar <= 'Z'){
String hm = maxnum.substring(maxnum.length() - 3);
if("999".equals(hm)){
hm = "000";
firstChar++;
}else {
hm = String.format("%03d", Integer.valueOf(hm)+1);
}
maxnum = firstChar+hm;
formattedNum = firstChar+hm;
}else {
formattedNum = String.format("%04d", Integer.valueOf(maxnum)+1);
maxnum = String.valueOf(Integer.valueOf(maxnum)+1);
}
lsh.put(entity.getField0043code(),maxnum);
wlcode.append(entity.getField0043code()).append(formattedNum);
if(entity.getField0008code() != null && !"".equals(entity.getField0008code())){
@ -422,9 +442,29 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
}
String num = zjMaterielSynchronizationEventDao.queryMaxLsh(entity);
num = num.substring(entity.getField0043code().length()+1,entity.getField0043code().length()+4);
maxnum = Integer.valueOf(num);
maxnum = num;
}
String formattedNum = String.format("%03d", ++maxnum);
String formattedNum = null;
char firstChar = Character.toUpperCase(maxnum.charAt(0));
if("999".equals(maxnum)){
maxnum = "A00";
formattedNum = "A00";
}else if(firstChar >= 'A' && firstChar <= 'Z'){
String hm = maxnum.substring(maxnum.length() - 2);
if("99".equals(hm)){
hm = "00";
firstChar++;
}else {
hm = String.format("%02d", Integer.valueOf(hm)+1);
}
maxnum = firstChar+hm;
formattedNum = firstChar+hm;
}else {
formattedNum = String.format("%03d", Integer.valueOf(maxnum)+1);
maxnum = String.valueOf(Integer.valueOf(maxnum)+1);
}
//String formattedNum = String.format("%03d", ++maxnum);
lsh.put(entity.getField0043code(),maxnum);
wlcode.append(entity.getField0043code());
if(entity.getField0017code() != null && "A贴片类".equals(entity.getField0017code())){
@ -457,9 +497,28 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
entity.setQuerycode(entity.getField0043code());
String num = zjMaterielSynchronizationEventDao.queryMaxLsh(entity);
num = num.substring(entity.getField0043code().length(),entity.getField0043code().length()+4);
maxnum = Integer.valueOf(num);
maxnum = num;
}
String formattedNum = String.format("%04d", ++maxnum);
String formattedNum = null;
char firstChar = Character.toUpperCase(maxnum.charAt(0));
if("9999".equals(maxnum)){
maxnum = "A000";
formattedNum = "A000";
}else if(firstChar >= 'A' && firstChar <= 'Z'){
String hm = maxnum.substring(maxnum.length() - 3);
if("999".equals(hm)){
hm = "000";
firstChar++;
}else {
hm = String.format("%03d", Integer.valueOf(hm)+1);
}
maxnum = firstChar+hm;
formattedNum = firstChar+hm;
}else {
formattedNum = String.format("%04d", Integer.valueOf(maxnum)+1);
maxnum = String.valueOf(Integer.valueOf(maxnum)+1);
}
lsh.put(entity.getField0043code(),maxnum);
wlcode.append(entity.getField0043code());
wlcode.append(formattedNum);
@ -479,9 +538,27 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
entity.setQuerycode(entity.getField0043code());
String num = zjMaterielSynchronizationEventDao.queryMaxLsh(entity);
num = num.substring(entity.getField0043code().length(),entity.getField0043code().length()+5);
maxnum = Integer.valueOf(num);
maxnum = num;
}
String formattedNum = null;
char firstChar = Character.toUpperCase(maxnum.charAt(0));
if("99999".equals(maxnum)){
maxnum = "A0000";
formattedNum = "A0000";
}else if(firstChar >= 'A' && firstChar <= 'Z'){
String hm = maxnum.substring(maxnum.length() - 4);
if("9999".equals(hm)){
hm = "0000";
firstChar++;
}else {
hm = String.format("%04d", Integer.valueOf(hm)+1);
}
maxnum = firstChar+hm;
formattedNum = firstChar+hm;
}else {
formattedNum = String.format("%05d", Integer.valueOf(maxnum)+1);
maxnum = String.valueOf(Integer.valueOf(maxnum)+1);
}
String formattedNum = String.format("%05d", ++maxnum);
lsh.put(entity.getField0043code(),maxnum);
wlcode.append(entity.getField0043code());
wlcode.append(formattedNum);

View File

@ -42,6 +42,34 @@ public class temButtom {
@Test
public void test01() {
String maxnum = "89988";
String formattedNum = null;
char firstChar = Character.toUpperCase(maxnum.charAt(0));
if("99999".equals(maxnum)){
maxnum = "A0000";
formattedNum = "A0000";
}else if(firstChar >= 'A' && firstChar <= 'Z'){
String hm = maxnum.substring(maxnum.length() - 4);
if("9999".equals(hm)){
hm = "0000";
firstChar++;
}else {
hm = String.format("%04d", Integer.valueOf(hm)+1);
}
maxnum = firstChar+hm;
formattedNum = firstChar+hm;
}else {
formattedNum = String.format("%05d", Integer.valueOf(maxnum)+1);
maxnum = String.valueOf(Integer.valueOf(maxnum)+1);
}
System.out.println(maxnum);
System.out.println(formattedNum);
String regex = "[\uFF00-\uFF5D\uFF5F-\uFFEF]";
// 编译正则表达式
Pattern pattern = Pattern.compile(regex);