|
@@ -2,7 +2,9 @@ package salogis;
|
|
|
|
|
|
|
|
import baseclass.PaoCust;
|
|
import baseclass.PaoCust;
|
|
|
import baseclass.tools.GetFieldsName;
|
|
import baseclass.tools.GetFieldsName;
|
|
|
|
|
+import baseclass.tools.Math;
|
|
|
import openapi.base.SQLFactory;
|
|
import openapi.base.SQLFactory;
|
|
|
|
|
+import openapi.base.data.Row;
|
|
|
import openapi.base.data.Rows;
|
|
import openapi.base.data.Rows;
|
|
|
import openapi.base.data.db.DBConnect;
|
|
import openapi.base.data.db.DBConnect;
|
|
|
import p2.common.parse.S;
|
|
import p2.common.parse.S;
|
|
@@ -12,6 +14,8 @@ import p2.pao.PaoSetRemote;
|
|
|
import p2.util.P2AppException;
|
|
import p2.util.P2AppException;
|
|
|
import p2.util.P2Exception;
|
|
import p2.util.P2Exception;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+
|
|
|
public class salogis extends PaoCust {
|
|
public class salogis extends PaoCust {
|
|
|
public salogis(PaoSet arg0) {
|
|
public salogis(PaoSet arg0) {
|
|
|
super(arg0);
|
|
super(arg0);
|
|
@@ -181,9 +185,26 @@ public class salogis extends PaoCust {
|
|
|
public void check(boolean ischeck) throws P2Exception {
|
|
public void check(boolean ischeck) throws P2Exception {
|
|
|
super.check(ischeck);
|
|
super.check(ischeck);
|
|
|
|
|
|
|
|
|
|
+ DBConnect dbConnect = new DBConnect();
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t.saorderdetailid,t.finvoiceamount-t.finvoiceamount2 as finvoiceamount from (\n" +
|
|
|
|
|
+ "select t4.saorderdetailid,isnull(t4.finvoiceamount,0)as finvoiceamount,sum(isnull(t3.finvoiceamount,0))finvoiceamount2 from salogis t1\n" +
|
|
|
|
|
+ "inner join salogisdetail t2 on t1.salogisid=t2.fparentid\n" +
|
|
|
|
|
+ "inner join sainvoicedetail t3 on t2.fsourceid=t3.fparentid and t2.fsourceobject='SAINVOICE'\n" +
|
|
|
|
|
+ "inner join saorderdetail t4 on t3.fsourceid=t4.saorderdetailid\n" +
|
|
|
|
|
+ "where t1.salogisid='" + getUniqueIDValue() + "'\n" +
|
|
|
|
|
+ "group by t4.saorderdetailid,t4.finvoiceamount\n" +
|
|
|
|
|
+ ")t where t.finvoiceamount-t.finvoiceamount2>0");
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<Long, Double> finvoiceamountmap = new HashMap();//可分配开票金额map
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
|
|
+ finvoiceamountmap.put(row.getLong("saorderdetailid"), row.getDouble("finvoiceamount"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
PaoSetRemote salogisdetailSet = getPaoSet("salogisdetail");
|
|
PaoSetRemote salogisdetailSet = getPaoSet("salogisdetail");
|
|
|
|
|
+
|
|
|
int i = 0;
|
|
int i = 0;
|
|
|
while (salogisdetailSet.getPao(i) != null) {
|
|
while (salogisdetailSet.getPao(i) != null) {
|
|
|
|
|
+ PaoSetRemote sainvoicedetail = salogisdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
PaoSetRemote sainvoiceSet = salogisdetailSet.getPao(i).getPaoSet("sainvoice");
|
|
PaoSetRemote sainvoiceSet = salogisdetailSet.getPao(i).getPaoSet("sainvoice");
|
|
|
sainvoiceSet.getPao(0).setValue("fstatus", ischeck ? "关闭" : "复核", 11L);
|
|
sainvoiceSet.getPao(0).setValue("fstatus", ischeck ? "关闭" : "复核", 11L);
|
|
|
sainvoiceSet.getPao(0).setValue("closeby", ischeck ? getUserName() : "", 11L);
|
|
sainvoiceSet.getPao(0).setValue("closeby", ischeck ? getUserName() : "", 11L);
|
|
@@ -200,7 +221,7 @@ public class salogis extends PaoCust {
|
|
|
|
|
|
|
|
//工具序列号状态变更
|
|
//工具序列号状态变更
|
|
|
String saordertype = sainvoiceSet.getPao(0).getPaoSet("saorder").getPao(0).getString("ftype");
|
|
String saordertype = sainvoiceSet.getPao(0).getPaoSet("saorder").getPao(0).getString("ftype");
|
|
|
- PaoSetRemote sainvoicedetail = salogisdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
|
|
|
|
+
|
|
|
int n = 0;
|
|
int n = 0;
|
|
|
while (sainvoicedetail.getPao(n) != null) {
|
|
while (sainvoicedetail.getPao(n) != null) {
|
|
|
PaoSetRemote salogis_toolscodeSet = sainvoicedetail.getPao(n).getPaoSet("salogis_toolscode");
|
|
PaoSetRemote salogis_toolscodeSet = sainvoicedetail.getPao(n).getPaoSet("salogis_toolscode");
|
|
@@ -218,6 +239,22 @@ public class salogis extends PaoCust {
|
|
|
ttoolscodePao.setValue("fagentnum", ischeck ? getString("fagentnum") : "", 11L);
|
|
ttoolscodePao.setValue("fagentnum", ischeck ? getString("fagentnum") : "", 11L);
|
|
|
m++;
|
|
m++;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (ischeck) {
|
|
|
|
|
+ double famount = sainvoicedetail.getPao(n).getDouble("famount");
|
|
|
|
|
+ long saorderdetailid = sainvoicedetail.getPao(n).getLong("fsourceid");
|
|
|
|
|
+ if (finvoiceamountmap.containsKey(saorderdetailid)) {
|
|
|
|
|
+ if (famount > finvoiceamountmap.get(saorderdetailid)) {
|
|
|
|
|
+ sainvoicedetail.getPao(n).setValue("finvoiceamount", finvoiceamountmap.get(saorderdetailid));
|
|
|
|
|
+ finvoiceamountmap.remove(saorderdetailid);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sainvoicedetail.getPao(n).setValue("finvoiceamount", famount);
|
|
|
|
|
+ finvoiceamountmap.put(saorderdetailid, Math.sub(finvoiceamountmap.get(saorderdetailid), famount));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sainvoicedetail.getPao(n).setValue("finvoiceamount", 0, 11L);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sainvoicedetail.getPao(n).setValue("finvoiceamount", 0, 11L);
|
|
|
|
|
+ }
|
|
|
n++;
|
|
n++;
|
|
|
}
|
|
}
|
|
|
i++;
|
|
i++;
|