|
|
@@ -8,13 +8,7 @@ import com.uas.platform.b2b.core.util.ThreadUtils;
|
|
|
import com.uas.platform.b2b.dao.CommonDao;
|
|
|
import com.uas.platform.b2b.dao.PurchaseApCheckItemInfoDao;
|
|
|
import com.uas.platform.b2b.dao.VendorDao;
|
|
|
-import com.uas.platform.b2b.model.ApcheckKeyWord;
|
|
|
-import com.uas.platform.b2b.model.DateFilter;
|
|
|
-import com.uas.platform.b2b.model.ErpProdIODetail;
|
|
|
-import com.uas.platform.b2b.model.ErpProdIo;
|
|
|
-import com.uas.platform.b2b.model.ProductIoGroup;
|
|
|
-import com.uas.platform.b2b.model.PurchaseApCheckItemInfo;
|
|
|
-import com.uas.platform.b2b.model.Vendor;
|
|
|
+import com.uas.platform.b2b.model.*;
|
|
|
import com.uas.platform.b2b.publicapi.model.ApCheckAmount;
|
|
|
import com.uas.platform.b2b.service.ErpProdIODetailService;
|
|
|
import com.uas.platform.b2b.service.PurchaseApCheckService;
|
|
|
@@ -30,6 +24,7 @@ import org.apache.axis.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.persistence.Id;
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
@@ -817,4 +812,186 @@ public class ErpProdIODetailServiceImpl implements ErpProdIODetailService {
|
|
|
}
|
|
|
return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的委外验退单
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 委外验退单
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getMakeReturnById(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select mr_code as inoutno, mr_date as pidate, mr_rate as rate, mr_receivecode as receivecode, " +
|
|
|
+ "mr_receivename as receivename, '客户委外验退单' as piclass, 'make$returnitem' as sourcetable, ma_code as ordercode, 0 as orderdetno, " +
|
|
|
+ "mri_number as detno, (-(1) * mri_qty ) as qty, mri_orderpice as orderprice, mr_currency as currency, mri_taxrate as taxrate, " +
|
|
|
+ "mri_whname as whname, mri_ycheckqty as ycheckqty, make$orders.pr_code as prodcode, make$orders.pr_spec as prodspec, " +
|
|
|
+ "make$orders.pr_title as prodtitle, make$orders.pr_unit as produnit, " +
|
|
|
+ "((-(1) * mri_qty ) - coalesce(mri_ycheckqty, 0)) as thischeckqty, mr_enuu as custuu, ma_useruu custuseruu, mr_venduu as enuu, mri_id as sourceid, " +
|
|
|
+ "mr_sendcode as sendcode, ma_factory as pd_factory, en_name custname, mri_payment payment from make$return " +
|
|
|
+ "join make$returnitem on mr_id = mri_paid " +
|
|
|
+ "join make$orders on mri_odid = ma_id " +
|
|
|
+ "left join sec$enterprises on mr_enuu = en_uu " +
|
|
|
+ " where mri_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的委外验收单
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 委外验收单
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getMakeAcceptById(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select make$accept.ma_code as inoutno, make$accept.ma_date as pidate, make$accept.ma_rate as rate, " +
|
|
|
+ "ma_receivecode as receivecode, ma_receivename as receivename, '客户委外验收单' as piclass, 'make$acceptitem' as sourcetable, " +
|
|
|
+ "make$orders.ma_code as ordercode, 0 as orderdetno, mai_number as detno, mai_qty as qty, mai_orderpice as orderprice, " +
|
|
|
+ "make$accept.ma_currency as currency, mai_taxrate as taxrate, mai_whname as whname, mai_ycheckqty as ycheckqty, " +
|
|
|
+ "make$orders.pr_code as prodcode, make$orders.pr_spec as prodspec, make$orders.pr_title as prodtitle, make$orders.pr_unit as produnit, " +
|
|
|
+ "(mai_qty - coalesce(mai_ycheckqty, 0)) as thischeckqty, make$accept.ma_enuu as custuu, make$orders.ma_useruu custuseruu, make$accept.ma_venduu as enuu, " +
|
|
|
+ "mai_id as sourceid, ma_sendcode as sendcode, ma_factory as factory, en_name custname, mai_payment payment from make$accept " +
|
|
|
+ "join make$acceptitem on make$accept.ma_id = mai_paid " +
|
|
|
+ "join make$orders on mai_odid = make$orders.ma_id " +
|
|
|
+ "left join sec$enterprises on make$accept.ma_enuu = en_uu " +
|
|
|
+ "where mai_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的客户不良品出库单
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 客户不良品出库单
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getBadOutById(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select po_code as inoutno, po_date as pidate, po_rate as rate, po_receivecode as receivecode, " +
|
|
|
+ "po_receivename as receivename, '客户不良品出库单' as piclass, 'purc$badoutitem' as sourcetable, pu_code as pd_ordercode, " +
|
|
|
+ "purc$orderitems.pd_number as orderdetno, poi_number as detno, (-(1) * poi_qty ) as qty, 0 as pd_orderprice, po_currency as currency, " +
|
|
|
+ "poi_taxrate as taxrate, poi_whname as whname, poi_ycheckqty as ycheckqty, pr_code as prodcode, pr_spec as prodspec, pr_title as prodtitle, pr_unit as produnit, " +
|
|
|
+ "((-(1) * poi_qty ) - coalesce( poi_ycheckqty, 0)) as thischeckqty, po_enuu as custuu, pu_useruu custuseruu, po_venduu as enuu, poi_id as sourceid, " +
|
|
|
+ "po_sendcode as sendcode, purc$orderitems.pd_factory as factory, en_name custname, poi_payment payment from purc$badout " +
|
|
|
+ "join purc$badoutitem on po_id = poi_poid " +
|
|
|
+ "left join purc$orderitems on poi_pdid = pd_id " +
|
|
|
+ "left join purc$orders on pu_id = pd_puid " +
|
|
|
+ "left join sec$enterprises on po_enuu = en_uu " +
|
|
|
+ "where poi_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的客户不良品入库单
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 客户不良品入库单
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getBadInById(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select pb_code as inoutno, pb_date as pidate, pb_rate as rate, pb_receivecode as receivecode, " +
|
|
|
+ "pb_receivename as receivename, '客户不良品入库单' as piclass, 'purc$badinitem' as sourcetable, pu_code as ordercode, " +
|
|
|
+ "pd_number as orderdetno, pbi_number as detno, pbi_qty as qty, 0 as pd_orderprice, pb_currency as currency, pbi_taxrate as taxrate, " +
|
|
|
+ "pbi_whname as whname, pbi_ycheckqty as ycheckqty, pr_code as prodcode, pr_spec as prodspec, pr_title as prodtitle, pr_unit as produnit, " +
|
|
|
+ "(pbi_qty - coalesce(pbi_ycheckqty, 0)) as thischeckqty, pb_enuu as custuu, pu_useruu custuseruu, pb_venduu as enuu, pbi_id as sourceid, " +
|
|
|
+ "pb_sendcode as sendcode, pd_factory as factory, en_name custname, pbi_payment payment from purc$badin " +
|
|
|
+ "join purc$badinitem on pb_id = pbi_pbid " +
|
|
|
+ "left join purc$orderitems on pbi_pdid = pd_id " +
|
|
|
+ "left join purc$orders on pu_id = pd_puid " +
|
|
|
+ "left join sec$enterprises on pb_enuu = en_uu " +
|
|
|
+ "where pbi_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的客户采购验退单信息
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 客户采购验退单信息
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getSaleReturnById(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select purc$return.pr_code as inoutno, pr_date as pidate, pr_rate as rate, pr_receivecode as receivecode, " +
|
|
|
+ "pr_receivename as receivename, '客户采购验退单' as piclass, 'purc$returnitem' as sourcetable, pu_code as ordercode, pd_number as orderdetno, " +
|
|
|
+ "pri_number as detno, (-(1) * pri_qty ) as qty, pri_orderprice as orderprice, pr_currency as currency, pri_taxrate as taxrate, " +
|
|
|
+ "pri_whname as whname, purc$returnitem.pr_code as prodcode, purc$returnitem.pr_spec as prodspec, purc$returnitem.pr_title as prodtitle, purc$returnitem.pr_unit as produnit, " +
|
|
|
+ "pri_ycheckqty as ycheckqty, ((-(1) * pri_qty ) - coalesce(pri_ycheckqty, 0)) as thischeckqty, pr_enuu as custuu, pu_useruu custuseruu, pr_venduu as enuu, " +
|
|
|
+ "pri_id as sourceid, pr_sendcode as sendcode, pd_factory as factory, en_name custname, pri_payment payment from purc$return " +
|
|
|
+ "join purc$returnitem on pr_id = pri_prid " +
|
|
|
+ "left join purc$orderitems on pri_pdid = pd_id " +
|
|
|
+ "left join purc$orders on pu_id = pd_puid " +
|
|
|
+ "left join sec$enterprises on pr_enuu = en_uu " +
|
|
|
+ "where pri_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的客户采购验收单信息
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 客户采购验收单信息
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getSaleAcceptById(Long id) {
|
|
|
+ StringBuilder sql = new StringBuilder("select pa_code as inoutno, pa_date as pidate, pa_rate as rate, pa_receivecode as receivcode, pa_receivename as receivename, '客户采购验收单' as piclass, 'purc$acceptitem' as sourcetable, pu_code as ordercode," +
|
|
|
+ " pd_number as orderdetno, pai_number as detno, pai_qty as qty, pai_orderprice as orderprice, pa_currency as currency," +
|
|
|
+ " pai_taxrate as taxrate, pai_whname as whname, purc$acceptitem.pr_code as prodcode, purc$acceptitem.pr_spec as prodspec, purc$acceptitem.pr_unit as produnit," +
|
|
|
+ " purc$acceptitem.pr_title as prodtitle, pai_ycheckqty as ycheckqty, (pai_qty - coalesce(pai_ycheckqty, 0)) as thischeckqty," +
|
|
|
+ " pa_enuu as custuu, pu_useruu custuseruu, pa_venduu as enuu, pai_id as sourceid, pa_sendcode as sendcode, pd_factory as factory, en_name custname," +
|
|
|
+ " pai_payment payment, b2b_si_id sendId,si_price sendPrice,si_qty sendQty from purc$accept" +
|
|
|
+ " join purc$acceptitem on pai_paid = pa_id" +
|
|
|
+ " left join purc$orderitems on pai_pdid = pd_id" +
|
|
|
+ " left join purc$orders on purc$orders.pu_id = pd_puid" +
|
|
|
+ " left join sec$enterprises on pa_enuu = en_uu" +
|
|
|
+ " left join sale$senditem on b2b_si_id = si_id" +
|
|
|
+ " where pai_id =").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待对账的货款调账信息
|
|
|
+ *
|
|
|
+ * @param id 明细id
|
|
|
+ * @return 货款调账信息
|
|
|
+ */
|
|
|
+ private List<ErpProdIODetail> getAdjustmentByid(Long id) {
|
|
|
+ StringBuffer sql = new StringBuffer("select aa_inoutno inoutno, aa_orderdate pidate, aa_rate rate, aa_receivecode receivecode, " +
|
|
|
+ "aa_receivename receivename, '货款调账' as piclass, 'purc$apbilladjustment' as sourcetable, aa_ordercode ordercode, " +
|
|
|
+ "aa_orderdetno orderdetno, aa_detno detno, aa_prid prid, aa_prodcode prodcode, aa_prodspec prodspec, aa_prodtitle prodtitle, aa_produnit as produnit, " +
|
|
|
+ "aa_qty qty, aa_orderprice orderprice, aa_currency currency, aa_taxrate taxrate, aa_whname whname, aa_ycheckqty ycheckqty, " +
|
|
|
+ "(aa_qty - coalesce(aa_ycheckqty, 0)) as thischeckqty, aa_custuu custuu, aa_custuseruu custuseruu, aa_enuu enuu, aa_id sourceid, aa_sendcode sendcode, " +
|
|
|
+ "aa_factory factory, aa_custname custname, aa_payment payment from purc$apbilladjustment" +
|
|
|
+ " where aa_id = ").append(id);
|
|
|
+ return commonDao.query(sql.toString(), ErpProdIODetail.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id获取验收明细
|
|
|
+ *
|
|
|
+ * @param sourceTable
|
|
|
+ * @param sourceId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ErpProdIODetail> getBySourceTableAndSourceId(String sourceTable, Long sourceId) {
|
|
|
+ List<ErpProdIODetail> erpProdIODetails = new ArrayList<>();
|
|
|
+ switch (sourceTable) {
|
|
|
+ case ApCheckTable.ADJUSTMENT:
|
|
|
+ erpProdIODetails = getAdjustmentByid(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.MAKE_ACCEPT:
|
|
|
+ erpProdIODetails = getMakeAcceptById(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.MAKE_RETURN:
|
|
|
+ erpProdIODetails = getMakeReturnById(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.SALE_ACCEPT:
|
|
|
+ erpProdIODetails = getSaleAcceptById(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.SALE_BADIN:
|
|
|
+ erpProdIODetails = getBadInById(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.SALE_BADOUT:
|
|
|
+ erpProdIODetails = getBadOutById(sourceId);
|
|
|
+ break;
|
|
|
+ case ApCheckTable.SALE_RETURN:
|
|
|
+ erpProdIODetails = getSaleReturnById(sourceId);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return erpProdIODetails;
|
|
|
+ }
|
|
|
}
|