|
|
@@ -1,162 +0,0 @@
|
|
|
-package com.uas.platform.b2b.service.impl;
|
|
|
-
|
|
|
-import com.uas.platform.b2b.dao.ApbillAdjustmentDao;
|
|
|
-import com.uas.platform.b2b.dao.CommonDao;
|
|
|
-import com.uas.platform.b2b.erp.model.PurchaseAPBill;
|
|
|
-import com.uas.platform.b2b.model.ApbillAdjustment;
|
|
|
-import com.uas.platform.b2b.service.ApbillAdjustmentService;
|
|
|
-import com.uas.platform.b2b.support.SystemSession;
|
|
|
-import com.uas.platform.core.model.Constant;
|
|
|
-import com.uas.platform.core.model.Status;
|
|
|
-import org.apache.axis.utils.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-
|
|
|
-@Service
|
|
|
-public class ApbillAdjustmentServiceImpl implements ApbillAdjustmentService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ApbillAdjustmentDao apbillAdjustmentDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private CommonDao commonDao;
|
|
|
-
|
|
|
- @Override
|
|
|
- public void save(List<ApbillAdjustment> apBilladjustments) {
|
|
|
- apbillAdjustmentDao.save(apBilladjustments);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ApbillAdjustment> getAdjustList(List<Long> filter, String keyword, Long fromDate, Long endDate) {
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- String querySql = "select t.aa_id id,t.aa_currency currency,t.aa_custname custname,t.aa_custuu custuu,t.aa_detno detno,t.aa_enuu enuu,"
|
|
|
- + " t.aa_factory factory,t.aa_inoutno inoutno,t.aa_ordercode ordercode,t.aa_prodspec prodspec,t.aa_prodcode prodcode,t.aa_prodtitle prodtitle,t.aa_qty qty,"
|
|
|
- + "t.aa_rate rate,t.aa_receivecode receivecode,t.aa_receivename receivename,t.aa_sendcode sendcode,t.aa_sourceid sourceid,t.aa_orderprice orderprice,t.aa_orderdate orderdate,"
|
|
|
- + "t.aa_taxrate taxrate,t.aa_thischeckqty thischeckqty,t.aa_whname whname,t.aa_ycheckqty ycheckqty,t.aa_prid prid from purc$apbilladjustment t where t.aa_enuu =?";
|
|
|
- if (!StringUtils.isEmpty(keyword)) {
|
|
|
- String[] strs = keyword.split("\\|");
|
|
|
- if (strs.length == 1) {
|
|
|
- querySql = querySql + " and t.aa_custname = '" + strs[0] + "'";
|
|
|
- }
|
|
|
- if (strs.length == 2) {
|
|
|
- if (strs[0].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_custname = '" + strs[0] + "'";
|
|
|
- }
|
|
|
- querySql = querySql + " and t.aa_receivename = '" + strs[1] + "'";
|
|
|
- }
|
|
|
- if (strs.length == 3) {
|
|
|
- if (strs[0].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_custname = '" + strs[0] + "'";
|
|
|
- }
|
|
|
- if (strs[1].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_receivename = '" + strs[1] + "'";
|
|
|
- }
|
|
|
- querySql = querySql + " and t.aa_factory = '" + strs[2] + "'";
|
|
|
- }
|
|
|
- if (strs.length == 4) {
|
|
|
- if (strs[0].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_custname = '" + strs[0] + "'";
|
|
|
- }
|
|
|
- if (strs[1].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_receivename = '" + strs[1] + "'";
|
|
|
- }
|
|
|
- if (strs[2].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_factory = '" + strs[2] + "'";
|
|
|
- }
|
|
|
- querySql = querySql + " and t.aa_prodtitle = '" + strs[3] + "'";
|
|
|
- }
|
|
|
- if (strs.length == 5) {
|
|
|
- if (strs[0].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_custname = '" + strs[0] + "'";
|
|
|
- }
|
|
|
- if (strs[1].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_receivename = '" + strs[1] + "'";
|
|
|
- }
|
|
|
- if (strs[2].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_factory = '" + strs[2] + "'";
|
|
|
- }
|
|
|
- if (strs[3].length() != 0) {
|
|
|
- querySql = querySql + " and t.aa_prodtitle = '" + strs[3] + "'";
|
|
|
- }
|
|
|
- querySql = querySql + " and t.aa_prodspec = '" + strs[4] + "'";
|
|
|
- }
|
|
|
- }
|
|
|
- if (fromDate != null) {
|
|
|
- querySql = querySql + " and t.aa_orderdate>=" + "str_to_date('"
|
|
|
- + new java.sql.Date(new Date(fromDate).getTime())
|
|
|
- + "','%Y-%m-%d')";
|
|
|
- }
|
|
|
- if (endDate != null) {
|
|
|
- querySql = querySql + " and t.aa_orderdate <=" + "str_to_date('"
|
|
|
- + new java.sql.Date(new Date(endDate).getTime())
|
|
|
- + "','%Y-%m-%d')";
|
|
|
- }
|
|
|
- Object[] args = new Object[] { enuu };
|
|
|
- if (!CollectionUtils.isEmpty(filter)) {
|
|
|
- String[] str = new String[filter.size()];
|
|
|
- Long[] lon = new Long[filter.size() + 1];
|
|
|
- String s = "";
|
|
|
- for (int i = 0; i < filter.size(); i++) {
|
|
|
- if (i != filter.size() - 1) {
|
|
|
- str[i] = "?,";
|
|
|
- } else {
|
|
|
- str[i] = "?";
|
|
|
- }
|
|
|
- lon[i + 1] = filter.get(i);
|
|
|
- s = s + str[i];
|
|
|
- }
|
|
|
- querySql = querySql + " and t.aa_custuu in (" + s + ")";
|
|
|
- lon[0] = enuu;
|
|
|
- args = lon;
|
|
|
- }
|
|
|
- querySql = querySql + " order by t.aa_orderdate desc";
|
|
|
- try {
|
|
|
- List<ApbillAdjustment> list = commonDao.query(querySql, args, ApbillAdjustment.class);
|
|
|
- return list;
|
|
|
- } catch (EmptyResultDataAccessException e) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ApbillAdjustment> convertnonPostAdjustment(List<PurchaseAPBill> apBills) {
|
|
|
- List<ApbillAdjustment> adjusts = new ArrayList<ApbillAdjustment>();
|
|
|
- if (!CollectionUtils.isEmpty(apBills)) {
|
|
|
- Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- for (PurchaseAPBill apBill : apBills) {
|
|
|
- List<ApbillAdjustment> list = apbillAdjustmentDao.findByCustuuAndInoutno(enUU, apBill.getAb_code());
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- for (ApbillAdjustment adjust : list) {
|
|
|
- adjusts.add(adjust);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return adjusts;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void nonPosting(List<ApbillAdjustment> adjustments) {
|
|
|
- if (!CollectionUtils.isEmpty(adjustments)) {
|
|
|
- for (ApbillAdjustment adjustment : adjustments) {
|
|
|
- if (adjustment.getSendstatus() != null) {
|
|
|
- // 已传输到供应商ERP,修改单据反过账状态
|
|
|
- if (adjustment.getSendstatus() == Status.DOWNLOADED.value()) {
|
|
|
- adjustment.setNonposting(Constant.YES);
|
|
|
- apbillAdjustmentDao.save(adjustment);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 未传输到供应商ERP,直接删除平台上的单据
|
|
|
- apbillAdjustmentDao.delete(adjustment);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|