|
|
@@ -20,6 +20,7 @@ import com.uas.eis.utils.HuToolUtils;
|
|
|
import com.uas.eis.vo.HttpResultResponse;
|
|
|
import io.xlate.edi.schema.EDISchemaException;
|
|
|
import io.xlate.edi.stream.EDIStreamException;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import okhttp3.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -57,6 +58,26 @@ public class GEServiceImpl implements GEService {
|
|
|
private String asnUrl;
|
|
|
|
|
|
|
|
|
+ final static String SALE_PRICE_CCP = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where spd_arcustcode=? and spd_prodcode=? and spd_currency=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+ final static String SALE_PRICE_CCPR = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where spd_arcustcode=? and spd_prodcode=? and spd_currency=? AND spd_taxrate=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+ final static String SALE_PRICE_KCP = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where spd_prodcode=? and spd_currency=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and spd_pricetype=? and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+ final static String SALE_PRICE_PC = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where spd_prodcode=? and spd_currency=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+ final static String SALE_PRICE_PCR = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where spd_prodcode=? and spd_currency=? and spd_taxrate=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+ final static String SALE_PRICE_SCP = "select spd_id,spd_price,spd_taxrate from (select spd_id,spd_price,spd_taxrate,spd_remark,spd_ratio from SalePriceDetail left join SalePrice on spd_spid=sp_id"
|
|
|
+ + " where sp_kind=? and spd_prodcode=? and spd_currency=? and to_char(sp_fromdate,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') and nvl(spd_lapqty,0)<=? and"
|
|
|
+ + " to_char(sp_todate,'yyyymmdd')>=to_char(sysdate,'yyyymmdd') AND spd_statuscode='VALID' and sp_statuscode='AUDITED' ORDER BY SalePrice.sp_indate DESC,SalePriceDetail.spd_price) where rownum<2";
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public GRApiResult<String> getPoordergr(HttpServletRequest request, PoInternalDTO dtop) {
|
|
|
PoOrderGrDTO dto = dtop.getPo();
|
|
|
@@ -151,7 +172,7 @@ public class GEServiceImpl implements GEService {
|
|
|
"SCG_CUSTGRCODE,SCG_CUSTGRNAME,SCG_CUSTCODE,SCG_CUSTNAME,SCG_SAKIND,SCG_POCODE,SCG_CURRENCY,SCG_RATE," +
|
|
|
"SCG_SADATE,SCG_GRPOCODE,SCG_GRHID,SCG_GRPOID)" +
|
|
|
"select "+scgid+",'"+scgcode+"',sysdate,'王平','在录入','ENTERING','','','', " +
|
|
|
- "PARTYCODE,PARTYNAME,nvl(cd_varchar50_1,PARTYCODE),nvl(cd_varchar50_2,PARTYNAME),'标准订单','poNo',currency,case when rate = 'null' then '0' else rate end," +
|
|
|
+ "PARTYCODE,PARTYNAME,nvl(cd_varchar50_1,PARTYCODE),nvl(cd_varchar50_2,PARTYNAME),'正常订单','poNo',currency,case when rate = 'null' then '0' else rate end," +
|
|
|
"poDate,soNo,case when HID = 'null' then '0' else HID end,POID " +
|
|
|
"from POORDERGR left join POORDERADDRINFOSGR on APOID = POID and nvl(PARTYTYPE,' ') = 'BY' " +
|
|
|
"left join N_HUASL_QD.CUSTOMTABLE on ct_caller='GECUSTDZ' left join N_HUASL_QD.CUSTOMTABLEDETAIL ON CD_CTID = CT_ID and ct_varchar50_5 = PARTYNAME " +
|
|
|
@@ -168,12 +189,97 @@ public class GEServiceImpl implements GEService {
|
|
|
"where DPOID = " + poid);
|
|
|
sqls.add("update SALECONFIRMGRDETAIL set SCGD_TOTAL = round(nvl(SCGD_QTY,0)*nvl(SCGD_PRICE,0),2) where SCGD_SCGID = " + scgid);
|
|
|
baseDao.execute(sqls);
|
|
|
+ getPrice(scgid);
|
|
|
ReturnData returnData = new ReturnData();
|
|
|
returnData.setSuccess("true");
|
|
|
returnData.setTransId(dto.getTransId());
|
|
|
return new GRApiResult(returnData);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void getPrice(int scg_id) {
|
|
|
+ Object sakind = baseDao.getFieldDataByCondition("SALECONFIRMGR", "scg_sakind", "scg_id=" + scg_id);
|
|
|
+ Object pricekind = baseDao.getFieldDataByCondition("SaleKind", "sk_pricekind", "sk_name='" + sakind + "'");
|
|
|
+ List<Object[]> objects = baseDao.getFieldsDatasByCondition(
|
|
|
+ "SALECONFIRMGRDETAIL left join SALECONFIRMGR on SCGD_SCGID=SCG_ID left join Customer on scg_custcode=cu_code", new String[] { "scgd_prcode",
|
|
|
+ "scg_custcode", "scg_currency", "scgd_qty", "scgd_id", "cu_pricetype", "nvl(scgd_xtprice,0)", "nvl(cu_taxrate,0)"}, " scg_id="
|
|
|
+ + scg_id);
|
|
|
+ JSONObject js = null;
|
|
|
+ if(baseDao.isDBSetting("Sale","getPriceBySale")){
|
|
|
+ for (Object[] obj : objects) {
|
|
|
+ Double a = 0.0;
|
|
|
+ Double b = 0.0;
|
|
|
+ if(Double.parseDouble(obj[8].toString()) == 0.0){
|
|
|
+ Object[] last = baseDao.getFieldsDataByCondition("(select * from sale left join saledetail on sa_id=sd_said where sa_custcode='"+obj[1]+"' and sa_currency='"+obj[2]+"' and sd_prodcode='"+obj[0]+"' and sa_statuscode='AUDITED' order by sa_date desc)", new String[]{"nvl(sd_price,0)","nvl(sd_taxrate,0)"}, "rownum<2");
|
|
|
+ if(last != null){
|
|
|
+ a = last[0] == null ? 0.0 : Double.parseDouble(last[0].toString());
|
|
|
+ baseDao.execute("update SALECONFIRMGRDETAIL set scgd_xtprice="+a+" where scgd_id="+obj[4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for (Object[] obj : objects) {
|
|
|
+ Object oqty = baseDao.getFieldDataByCondition("SALECONFIRMGRDETAIL", "sum(scgd_qty)",
|
|
|
+ " SCGD_SCGID=" + scg_id + " and scgd_prcode='" + String.valueOf(obj[0]) + "'");
|
|
|
+ if (pricekind == null
|
|
|
+ || (!"CCPR".equals(pricekind) && !"CCP".equals(pricekind) && !"KCP".equals(pricekind) && !"PC".equals(pricekind) && !"SCP"
|
|
|
+ .equals(pricekind)&&!"PCR".equals(pricekind))) {
|
|
|
+
|
|
|
+ } else
|
|
|
+ js = getSalePrice_N(String.valueOf(obj[1]), String.valueOf(sakind), String.valueOf(obj[0]), String.valueOf(obj[2]),
|
|
|
+ String.valueOf(obj[5]), pricekind, Double.parseDouble(oqty.toString()), Double.parseDouble(obj[7].toString()));
|
|
|
+ double price = 0;
|
|
|
+ double tax = 0;
|
|
|
+ double p = 0;
|
|
|
+ int spdid = 0;
|
|
|
+ if (js != null) {
|
|
|
+ price = js.getDouble("sd_price");
|
|
|
+ tax = js.getDouble("sd_taxrate");
|
|
|
+ spdid = js.getInt("spd_id");
|
|
|
+ }
|
|
|
+ if (price != 0) {
|
|
|
+ p = price;
|
|
|
+ baseDao.updateByCondition("SALECONFIRMGRDETAIL", "scgd_xtprice=" + p, "scgd_id=" + obj[4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public JSONObject getSalePrice_N(String custcode, String sakind, String prodcode, String currency, String cukind, Object pricekind,
|
|
|
+ Double sumqty, Double taxrate) {
|
|
|
+ SqlRowList rs = null;
|
|
|
+ /**
|
|
|
+ * 反馈编号:2017030117
|
|
|
+ * 西博泰科UAS:销售类型-取价原则,增加一种原则PCR:“料号+币别+税率”;
|
|
|
+ */
|
|
|
+ if (pricekind != null) {
|
|
|
+ if ("CCP".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_CCP, custcode, prodcode, currency, sumqty);
|
|
|
+ } else if ("CCPR".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_CCPR, custcode, prodcode, currency, taxrate, sumqty);
|
|
|
+ } else if ("KCP".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_KCP, prodcode, currency, cukind, sumqty);
|
|
|
+ } else if ("PC".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_PC, prodcode, currency, sumqty);
|
|
|
+ } else if ("SCP".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_SCP, sakind, prodcode, currency, sumqty);
|
|
|
+ } else if ("PCR".equals(pricekind)) {
|
|
|
+ rs = baseDao.queryForRowSet(SALE_PRICE_PCR,prodcode, currency, taxrate,sumqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rs.next()) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("sd_price", rs.getObject("spd_price") == null ? 0 : rs.getObject("spd_price"));
|
|
|
+ obj.put("sd_taxrate", rs.getObject("spd_taxrate") == null ? 0 : rs.getObject("spd_taxrate"));
|
|
|
+ obj.put("spd_id", rs.getObject("spd_id") == null ? 0 : rs.getObject("spd_id"));
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public ApiResult<String> pushSenderInfo(PoOrderGrDTO dto) {
|
|
|
|