1.配件发货明细表(已发货)逻辑修改
This commit is contained in:
ljw 2024-12-06 17:35:26 +08:00
parent d26d5dcc7b
commit 9ceaea2803

View File

@ -75,14 +75,14 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
resDataSet = RptUtil.zeroNullNums(resDataSet);
DataSet selected = resDataSet.select(String.join(",", RptUtil.getDataSetFiledAlias(resDataSet)) +
",CASE WHEN (yem_contractamount = yem_salcontractclaamt) THEN paymenttime ELSE null END yem_paymenttime" +
// ",(yem_theamountdue-yem_theamountpaid) yem_theamountowed" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_theamountdue /yem_contractamount*yem_interestamt end) yem_interest" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_theamountdue /yem_contractamount*yem_creditamt end) yem_creditpremiums" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_theamountdue /yem_contractamount*yem_fundpoolamt end) yem_discountsaccessor" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_theamountdue /yem_contractamount*yem_premiumamt end) yem_insurance" +
",(case when yem_offeramount = 0 then yem_offeramount else yem_theamountdue /yem_offeramount*yem_origcurrepremium end) yem_actualcreditpremium" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_theamountdue /yem_contractamount*(yem_seafreight+yem_landcarrycost+yem_airliftcost+yem_expresscost) end) yem_freight");
selected = selected.select(String.join(",",RptUtil.getDataSetFiledAlias(selected))+
// ",(yem_amountandtax-yem_theamountpaid) yem_theamountowed" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_amountandtax /yem_contractamount*yem_interestamt end) yem_interest" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_amountandtax /yem_contractamount*yem_creditamt end) yem_creditpremiums" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_amountandtax /yem_contractamount*yem_fundpoolamt end) yem_discountsaccessor" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_amountandtax /yem_contractamount*yem_premiumamt end) yem_insurance" +
",(case when yem_offeramount = 0 then yem_offeramount else yem_amountandtax /yem_offeramount*yem_origcurrepremium end) yem_actualcreditpremium" +
",(case when yem_contractamount = 0 then yem_contractamount else yem_amountandtax /yem_contractamount*(yem_seafreight+yem_landcarrycost+yem_airliftcost+yem_expresscost) end) yem_freight");
selected = selected.select(String.join(",", RptUtil.getDataSetFiledAlias(selected)) +
",CASE WHEN yem_day > 0 AND (yem_paymenttime = null OR yem_duedate < yem_paymenttime) THEN yem_day ELSE '' END yem_daysoverdue");
selected = selected.removeFields("paymenttime");
selected = selected.distinct();
@ -111,16 +111,16 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
if (YEM.isNotEmpty(yem_shipdatesdis)) {
sb.append(" AND yem_shipdate <= '").append("%").append(yem_shipdatesdis).append("%").append("'");
}
if (YEM.isNotEmpty(yem_bd_producttype)){
if (YEM.isNotEmpty(yem_bd_producttype)) {
List<String> names = new ArrayList<>();
for (DynamicObject dynamicObject : yem_bd_producttype) {
String name = dynamicObject.getString("name");
names.add(name);
// sb.append(" AND yem_bd_products = ").append("'" +name + "'");
}
Map<String,Object> map = new HashMap<>();
map.put("var",names);
result = result.filter("yem_bd_products in var",map);
Map<String, Object> map = new HashMap<>();
map.put("var", names);
result = result.filter("yem_bd_products in var", map);
}
DataSet where = result.where(sb.toString());
@ -134,12 +134,12 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
objects.add(l);
}
DataSet rows = querySalesOrder_PayRate(objects);
distincted = distincted.leftJoin(rows).on("queryDeliverNoticeid","main_id_payrate_fk").select(RptUtil.getDataSetFiledAlias(distincted),RptUtil.getDataSetFiledAlias(rows)).finish();
distincted = distincted.leftJoin(rows).on("queryDeliverNoticeid", "main_id_payrate_fk").select(RptUtil.getDataSetFiledAlias(distincted), RptUtil.getDataSetFiledAlias(rows)).finish();
distincted = RptUtil.zeroNullNums(distincted);
distincted = distincted.select(String.join(",",RptUtil.getDataSetFiledAlias(distincted))+",yem_theamountdue * prod_rate/100 yem_theamountdueprod_rate" +//下单预收
",yem_theamountdue*ship_rate/100 yem_theamountdueship_rate"+//发货预收
",yem_theamountdue*final_rate/100 yem_theamountduefinal_rate"+//尾款
distincted = distincted.select(String.join(",", RptUtil.getDataSetFiledAlias(distincted)) + ",yem_theamountdue * prod_rate/100 yem_theamountdueprod_rate" +//下单预收
",yem_theamountdue*ship_rate/100 yem_theamountdueship_rate" +//发货预收
",yem_theamountdue*final_rate/100 yem_theamountduefinal_rate" +//尾款
",yem_theamountdue*prod_rate/100+yem_theamountdue*ship_rate/100 yem_theamountdueprod_ship" +//预收
",yem_theamountdue*final_rate/100+yem_theamountdue*prod_rate/100 yem_theamountduefinal_prod" +//下单预收+尾款
",yem_theamountdue*ship_rate/100+yem_theamountdue*prod_rate/100 yem_theamountdueship_prod" +//发货预收+尾款
@ -174,7 +174,7 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
" yem_theamountdueship_prod" +
//发货预收+尾款
" WHEN yem_endpaydate IS NOT NULL AND yem_endpaydate !='' AND yem_prodpaydate IS NOT NULL AND yem_prodpaydate !='' AND yem_shippaydate IS NOT NULL AND yem_shippaydate != '' THEN" +//
" yem_theamountduefinal_ship_prod"+
" yem_theamountduefinal_ship_prod" +
//预收+尾款
" ELSE " +
" 0.0" +
@ -185,6 +185,7 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
}
//(CASE WHEN true then 0 else (case where true then 1 else 0 end)end)
/**
* 查询收款单
*
@ -250,9 +251,9 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
*/
private DataSet queryDeliverNotice() {
QFilter qFilter = getBaseQFilter();
qFilter.and("yem_es_materialinfo.yem_businesssort",QCP.equals,"P");
qFilter.and("yem_es_materialinfo.yem_businesssort", QCP.equals, "P");
// qFilter.and("yem_signconfirmstatus",QCP.equals,"A");
qFilter.and("yem_cancelstatus",QCP.equals,"A");
qFilter.and("yem_cancelstatus", QCP.equals, "A");
List<String> selectfields = new ArrayList<>();
selectfields.add("id queryDeliverNoticeid");
selectfields.add("yem_operator.name yem_salesman");
@ -278,12 +279,13 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
// selectfields.add("yem_es_materialinfo.yem_businesssort yem_customsdeclaration1");
DataSet yemEsSalesorder = ORM.create().queryDataSet(algoKey, "yem_es_salesorder", String.join(",", selectfields), qFilter.toArray());
DataSet esSalesorder = yemEsSalesorder();
yemEsSalesorder=yemEsSalesorder.leftJoin(esSalesorder).on("queryDeliverNoticeid","yemEsSalesorderid")
yemEsSalesorder = yemEsSalesorder.leftJoin(esSalesorder).on("queryDeliverNoticeid", "yemEsSalesorderid")
.select(RptUtil.getDataSetFiledAlias(yemEsSalesorder), RptUtil.getDataSetFiledAlias(esSalesorder)).finish();
return yemEsSalesorder;
}
/**
* 外销合同
*
@ -291,27 +293,26 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
*/
private DataSet yemEsSalesorder() {
QFilter qFilter = getBaseQFilter();
qFilter.and("yem_es_materialinfo.yem_businesssort",QCP.equals,"P");
qFilter.and("yem_cancelstatus",QCP.equals,"A");
qFilter.and("yem_es_materialinfo.yem_businesssort", QCP.equals, "P");
qFilter.and("yem_cancelstatus", QCP.equals, "A");
List<String> selectfields = new ArrayList<>();
selectfields.add("id yemEsSalesorderid");
selectfields.add("yem_es_materialinfo.yem_qty yem_numbercontracts");
DataSet yemEsSalesorder = ORM.create().queryDataSet(algoKey, "yem_es_salesorder", String.join(",", selectfields), qFilter.toArray());
yemEsSalesorder =yemEsSalesorder.groupBy(new String[]{"yemEsSalesorderid"}).sum("yem_numbercontracts").finish();
yemEsSalesorder = yemEsSalesorder.groupBy(new String[]{"yemEsSalesorderid"}).sum("yem_numbercontracts").finish();
return yemEsSalesorder;
}
/**
* 订舱通知单
*
* @return
*/
private DataSet yemContainernumber() {
QFilter qFilter = getBaseQFilter(new String[]{"B","C"});
QFilter qFilter = getBaseQFilter(new String[]{"B", "C"});
List<String> selectfields = new ArrayList<>();
selectfields.add("id yemContainernumberid");
selectfields.add("yem_offeramount yem_offeramount");
@ -368,9 +369,9 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
selectfield.add("yem_receiptdetail.yem_claimdetail.yem_salcontractno.id yem_salcontractnoid");//收款单的合同号id
selectfield.add("TO_CHAR(yem_bizdate, 'yyyy-MM-dd') paymenttime");//收款单的合同金额 to_char(sysdate,'yyyy')
DataSet yemShippingdetail = ORM.create().queryDataSet(algoKey, "yem_gathering", String.join(",", selectfield), qFilter.toArray());
yemShippingdetails =yemShippingdetails.leftJoin(yemShippingdetail)
.on("yem_titleid","yem_salcontractnoid")
.select(RptUtil.getDataSetFiledAlias(yemShippingdetails),RptUtil.getDataSetFiledAlias(yemShippingdetail))
yemShippingdetails = yemShippingdetails.leftJoin(yemShippingdetail)
.on("yem_titleid", "yem_salcontractnoid")
.select(RptUtil.getDataSetFiledAlias(yemShippingdetails), RptUtil.getDataSetFiledAlias(yemShippingdetail))
.finish();
return yemShippingdetails.distinct();
}
@ -387,7 +388,7 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
selectfields.add("yem_transportstyle.name yem_shippingmethod");
selectfields.add("yem_sourcebillid yemShippingdetailsyem_sourcebillid");
DataSet yemShippingdetails = ORM.create().queryDataSet(algoKey, "yem_shippingdetails", String.join(",", selectfields), qFilter.toArray());
yemShippingdetails = yemShippingdetails.select(String.join(",",RptUtil.getDataSetFiledAlias(yemShippingdetails))+
yemShippingdetails = yemShippingdetails.select(String.join(",", RptUtil.getDataSetFiledAlias(yemShippingdetails)) +
",CASE WHEN yem_boardaccessor = 'A' THEN '是' ELSE '否' END yem_boardaccessory");
yemShippingdetails = yemShippingdetails
.groupBy(new String[]{"yemShippingdetailsyem_sourcebillid"})
@ -411,26 +412,26 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
selectfields.add("TO_CHAR(auditdate, 'yyyy-MM-dd') yem_shipdate");
selectfields.add("yem_duedate yem_duedate");//yem_daysoverdue
selectfields.add("yem_priceclause.name yem_deliverymethod");
selectfields.add("yem_totalallamount yem_theamountdue");//价税合计
selectfields.add("yem_totalallamount yem_amountandtax");//价税合计
selectfields.add("yem_currency.name yem_fullpaymenttime");
selectfields.add("yem_sourcebillid yemEsDelivernoticeyem_sourcebillid");
selectfields.add("yem_corebillid yem_corebillids");
selectfields.add("'' yem_day");
DataSet yemShippingdetails = ORM.create().queryDataSet(algoKey, "yem_es_delivernotice", String.join(",", selectfields), qFilter.toArray());
DynamicObjectCollection plainDynamicObjectCollection = ORM.create().toPlainDynamicObjectCollection(yemShippingdetails);
if (!plainDynamicObjectCollection.isEmpty()){
if (!plainDynamicObjectCollection.isEmpty()) {
for (DynamicObject dynamicObject : plainDynamicObjectCollection) {
Date yem_duedate = dynamicObject.getDate("yem_duedate");
Date data = new Date();
if (yem_duedate!=null){
if (yem_duedate != null) {
LocalDate date1 = convertDateToLocalDate(yem_duedate);
LocalDate date2 = convertDateToLocalDate(data);
long Chrono = ChronoUnit.DAYS.between(date1,date2 );
dynamicObject.set("yem_day",Chrono);
long Chrono = ChronoUnit.DAYS.between(date1, date2);
dynamicObject.set("yem_day", Chrono);
}
}
}
yemShippingdetails= RptUtil.plainDataSet(algoKey, yemShippingdetails,plainDynamicObjectCollection );
yemShippingdetails = RptUtil.plainDataSet(algoKey, yemShippingdetails, plainDynamicObjectCollection);
return yemShippingdetails;
}
@ -456,13 +457,15 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
// Date yem_shipdatesend = filter.getDate("yem_shipdatesend");
// Date yem_shipdatesdis = filter.getDate("yem_shipdatesdis");
QFilter qFilter = new QFilter("yem_es_materialinfo.yem_businesssort", QCP.equals, "P");
if (!yemContract.isEmpty()){
qFilter.and("billno",QCP.like,"%"+yemContract+"%");
if (!yemContract.isEmpty()) {
qFilter.and("billno", QCP.like, "%" + yemContract + "%");
}
List<String> selectfields = new ArrayList<>();
selectfields.add("id yemEsDelivernoticesid");
selectfields.add("yem_es_materialinfo.yem_businesssort yem_businesssorts");
selectfields.add("yem_es_materialinfo.yem_qty yem_qty");
DataSet yemShippingdetails = ORM.create().queryDataSet(algoKey, "yem_es_delivernotice", String.join(",", selectfields), qFilter.toArray());
yemShippingdetails = yemShippingdetails.where("yem_businesssorts = 'P'");
yemShippingdetails = yemShippingdetails.groupBy(new String[]{"yemEsDelivernoticesid"})
.sum("yem_qty")
.finish();
@ -471,7 +474,36 @@ public class SparepartsPlugin extends AbstractReportListDataPlugin {
.on("yemEsDelivernoticesid", "yemEsDelivernoticeid")
.select(RptUtil.getDataSetFiledAlias(yemShippingdetails), RptUtil.getDataSetFiledAlias(yemEsDelivernotice))
.finish();
DataSet addamountandtax = addamountandtax(reportQueryParam);
yemShippingdetails = yemShippingdetails.leftJoin(addamountandtax)
.on("yemEsDelivernoticesid", "addamountandtaxid")
.select(RptUtil.getDataSetFiledAlias(yemShippingdetails), RptUtil.getDataSetFiledAlias(addamountandtax))
.finish();
return yemShippingdetails;
}
/**
* 已审核的销售出库单商品明细业务分类为配件的价税合计汇总值
*
* @return
*/
private DataSet addamountandtax(ReportQueryParam reportQueryParam) {
FilterInfo filter = reportQueryParam.getFilter();
String yemContract = filter.getString("yem_billnos");
QFilter qFilter = new QFilter("yem_es_materialinfo.yem_businesssort", QCP.equals, "P");
if (!yemContract.isEmpty()) {
qFilter.and("billno", QCP.like, "%" + yemContract + "%");
}
List<String> selectfields = new ArrayList<>();
selectfields.add("id addamountandtaxid");
selectfields.add("yem_es_materialinfo.yem_businesssort yem_businesssort");
selectfields.add("yem_es_materialinfo.yem_amountandtax yem_theamountdue");
DataSet yemShippingdetails = ORM.create().queryDataSet(algoKey, "yem_es_delivernotice", String.join(",", selectfields), qFilter.toArray());
yemShippingdetails = yemShippingdetails.where("yem_businesssort = 'P'");
yemShippingdetails = yemShippingdetails.groupBy(new String[]{"addamountandtaxid"}).sum("yem_theamountdue").finish();
yemShippingdetails = yemShippingdetails.distinct();
return yemShippingdetails;
}
}