lisai17@sina.com 2020-12-28 23:15:18 +08:00
parent e11cb40d75
commit 80861ce523
1 changed files with 37 additions and 30 deletions

View File

@ -10,7 +10,9 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class InvoiceUseService { public class InvoiceUseService {
private static Log log = Log.getLog(InvoiceUseService.class); private static Log log = Log.getLog(InvoiceUseService.class);
@ -131,44 +133,49 @@ public class InvoiceUseService {
paramord.add(invoice_type); paramord.add(invoice_type);
} }
if (order_state != null) {
logsql += " and o.state = ? \n";
ordsql += " and t.state = ? \n";
paramlog.add(order_state);
paramord.add(order_state);
}
List<Record> list = new ArrayList<>(); List<Record> list = new ArrayList<>();
if (order_state != null) { if (invoice_state != null) {
if (order_state == 9) { if (invoice_state == 9) {
logsql += " and o.state = ? \n";
paramlog.add(order_state);
list = Db.find(logsql + " order by t.create_time", paramlog.toArray()); list = Db.find(logsql + " order by t.create_time", paramlog.toArray());
} else { } else if (invoice_state == 5) {
logsql += " and o.state = ? \n"; list = Db.find(ordsql + " order by t.create_time", paramord.toArray());
ordsql += " and t.state = ? \n"; }
paramlog.add(order_state); } else {
paramord.add(order_state); paramlog.addAll(paramord);
if (invoice_state != null) { List<Record> l1 = Db.find(logsql + " order by t.create_time", paramlog.toArray());
if (invoice_state == 9) { List<Record> l2 = Db.find(ordsql + " order by t.create_time", paramord.toArray());
list = Db.find(logsql + " order by t.create_time", paramlog.toArray());
} else if (invoice_state == 5) {
list = Db.find(ordsql + " order by t.create_time", paramord.toArray());
}
} else {
paramlog.addAll(paramord);
list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); Map<String, Record> map1 = new HashMap<>();
Map<String, Record> map2 = new HashMap<>();
for(Record record : l1){
String key = record.getStr("order_sn") + "_" +record.getStr("invoice_number") + "_" +record.getStr("invoice_code");
map1.put(key, record);
}
for(Record record : l2){
String key = record.getStr("order_sn") + "_" +record.getStr("invoice_number") + "_" +record.getStr("invoice_code");
map2.put(key, record);
}
for(Map.Entry<String, Record> entry : map2.entrySet()){
if(map1.containsKey(entry.getKey())){
map1.remove(entry.getKey()); // 从 map1 中移除相同的
} }
} }
}else {
if (invoice_state != null) {
if (invoice_state == 9) {
list = Db.find(logsql + " order by t.create_time", paramlog.toArray());
} else if (invoice_state == 5) {
list = Db.find(ordsql + " order by t.create_time", paramord.toArray());
}
} else {
paramlog.addAll(paramord);
list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray()); map2.putAll(map1); // 剩下的不同的全部加到 map2 中
}
list = new ArrayList<>(map2.values());
} }
Record out = new Record(); Record out = new Record();