Browse Source

Merge remote-tracking branch 'origin/dev'

chenw 7 years ago
parent
commit
981b3bd596
17 changed files with 440 additions and 53 deletions
  1. 7 4
      applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml
  2. 7 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CurrencyController.java
  3. 4 0
      applications/money/money-server/pom.xml
  4. 8 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalanceMapper.java
  5. 101 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/CustAramount.java
  6. 18 6
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/ApcheckServiceImpl.java
  7. 56 37
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  8. 156 0
      applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml
  9. 12 4
      applications/purchase/purchase-api/src/main/java/com/usoftchina/saas/purchase/api/ProdInOutApi.java
  10. 2 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdIODetailDTO.java
  11. 24 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdInOutStatusDTO.java
  12. 14 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/controller/ProdInOutController.java
  13. 2 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java
  14. 2 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdIODetail.java
  15. 9 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java
  16. 11 1
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java
  17. 7 1
      applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml

+ 7 - 4
applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml

@@ -112,7 +112,9 @@
             #账户余额
             (
             select ifnull(balance_,0) balanceTotal from (
-            select sum(ifnull(bk_thisamount,0)) balance_ from bankinformation where companyid=#{componyId})d
+            select sum(thisamount*(case when ifnull(cr_rate,0)=0 then 1 else ifnull(cr_rate,0) end)) balance_ from
+            (select bk_currency,sum(ifnull(bk_thisamount,0)) thisamount from bankinformation where companyid=#{componyId}
+              group by bk_currency) t left join currencys on bk_currency=cr_name and currencys.companyId=#{componyId} )d
             )d1
             );
     </select>
@@ -122,7 +124,7 @@
       (
         #前5数据
         select group_concat('{"x":"',custname,'","y":',profit/10000,',"z":"',shortname,'"}') five_profit   from (
-        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
         pi_custcode,max(pi_custname) custname,max(ifnull(cu_shortname,'')) shortname  from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
         where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}
@@ -133,13 +135,14 @@
 		select concat('{"z":"其它","x":"其它","y":',(all_profit - five_profit)/10000,'}') other_profit from (
         #总共
         (
-        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) all_profit
+        select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) all_profit
         from prodinout left join prodiodetail on pi_id=pd_piid
         where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId} )a1_,
         #前5总和
         (
-        select sum(profit) five_profit from (select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        select sum(profit) five_profit from (select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )
+        - ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
         pi_custcode,max(pi_custname) custname,prodinout.companyid from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
          where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}

+ 7 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CurrencyController.java

@@ -49,4 +49,11 @@ public class CurrencyController {
     public Result<CurrencyDTO> getStandard(){
         return Result.success(currencyService.getStandard());
     }
+
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id){
+        currencyService.removeByPrimaryKey(id);
+        return Result.success();
+    }
+
 }

+ 4 - 0
applications/money/money-server/pom.xml

@@ -105,6 +105,10 @@
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>document-dto</artifactId>
         </dependency>
+      <dependency>
+        <groupId>com.usoftchina.saas</groupId>
+        <artifactId>purchase-api</artifactId>
+      </dependency>
         <dependency>
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>document-server</artifactId>

+ 8 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalanceMapper.java

@@ -59,4 +59,12 @@ public interface RecbalanceMapper extends CommonBaseMapper<Recbalance> {
     String validateAudit(List<DocBaseDTO> baseDTOs);
 
     void updateByAmount(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    CustAramount selectCustArByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+
+    int updateCustAramountByPrimaryKeySelective(CustAramount record);
+
+    int updateCustleftamountByPrimaryKey(Integer cu_id);
+
+    int insertCustAramount(CustAramount record);
 }

+ 101 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/CustAramount.java

@@ -0,0 +1,101 @@
+package com.usoftchina.saas.money.po;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class CustAramount extends CommonBaseEntity implements Serializable {
+    private  Integer ca_custid;
+    private  String ca_custcode;
+    private  String ca_custname;
+    private  String ca_currency;
+    private  Date ca_begindate;
+    private  Double ca_beginaramount;
+    private  Double ca_beginprerecamount;
+    private  Double ca_preamount;
+    private  Double ca_recamount;
+    private  Double ca_leftamount;
+
+    public Integer getCa_custid() {
+        return ca_custid;
+    }
+
+    public void setCa_custid(Integer ca_custid) {
+        this.ca_custid = ca_custid;
+    }
+
+    public String getCa_custcode() {
+        return ca_custcode;
+    }
+
+    public void setCa_custcode(String ca_custcode) {
+        this.ca_custcode = ca_custcode;
+    }
+
+    public String getCa_custname() {
+        return ca_custname;
+    }
+
+    public void setCa_custname(String ca_custname) {
+        this.ca_custname = ca_custname;
+    }
+
+    public String getCa_currency() {
+        return ca_currency;
+    }
+
+    public void setCa_currency(String ca_currency) {
+        this.ca_currency = ca_currency;
+    }
+
+    public Date getCa_begindate() {
+        return ca_begindate;
+    }
+
+    public void setCa_begindate(Date ca_begindate) {
+        this.ca_begindate = ca_begindate;
+    }
+
+    public Double getCa_beginaramount() {
+        return ca_beginaramount;
+    }
+
+    public void setCa_beginaramount(Double ca_beginaramount) {
+        this.ca_beginaramount = ca_beginaramount;
+    }
+
+    public Double getCa_beginprerecamount() {
+        return ca_beginprerecamount;
+    }
+
+    public void setCa_beginprerecamount(Double ca_beginprerecamount) {
+        this.ca_beginprerecamount = ca_beginprerecamount;
+    }
+
+    public Double getCa_preamount() {
+        return ca_preamount;
+    }
+
+    public void setCa_preamount(Double ca_preamount) {
+        this.ca_preamount = ca_preamount;
+    }
+
+    public Double getCa_recamount() {
+        return ca_recamount;
+    }
+
+    public void setCa_recamount(Double ca_recamount) {
+        this.ca_recamount = ca_recamount;
+    }
+
+    public Double getCa_leftamount() {
+        return ca_leftamount;
+    }
+
+    public void setCa_leftamount(Double ca_leftamount) {
+        this.ca_leftamount = ca_leftamount;
+    }
+}

+ 18 - 6
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/ApcheckServiceImpl.java

@@ -9,7 +9,6 @@ import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.context.SpringContextHolder;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.b2b.dto.APCheck;
 import com.usoftchina.saas.money.mapper.ApcheckMapper;
@@ -18,6 +17,8 @@ import com.usoftchina.saas.money.po.ApcheckDetail;
 import com.usoftchina.saas.money.po.ApcheckForm;
 import com.usoftchina.saas.money.service.ApcheckService;
 import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.purchase.api.ProdInOutApi;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import com.usoftchina.saas.utils.JsonUtils;
 import com.usoftchina.saas.utils.StringUtils;
 import com.usoftchina.saas.utils.http.HttpUtil;
@@ -26,9 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author: guq
@@ -42,9 +41,10 @@ public class ApcheckServiceImpl implements ApcheckService{
 
     @Autowired
     private ApcheckMapper apcheckMapper;
-
     @Autowired
     private CompanyApi companyApi;
+    @Autowired
+    private ProdInOutApi prodInOutApi;
 
     private static final String URI = "/erp/sale/APCheck/reply?access_id=";
 
@@ -106,7 +106,19 @@ public class ApcheckServiceImpl implements ApcheckService{
                 } catch (Exception e) {
                 }
             }
-
+            //更新采购验收、验退单的对账状态
+            List<ApcheckDetail> apcheckDetailList = apcheckMapper.selectByFK(id);
+            List<ProdInOutStatusDTO> prodInOutStatusDTOList = new ArrayList<ProdInOutStatusDTO>();
+            for (ApcheckDetail apcheckDetail : apcheckDetailList) {
+                ProdInOutStatusDTO prodInOutStatusDTO = new ProdInOutStatusDTO(
+                        apcheckDetail.getAd_inoutno(),
+                        apcheckDetail.getAd_pdno().longValue(),
+                        apcheckDetail.getCompanyId(),
+                        "已对账"
+                );
+                prodInOutStatusDTOList.add(prodInOutStatusDTO);
+            }
+            prodInOutApi.updateApcheckStatus(prodInOutStatusDTOList);
         }
     }
 

+ 56 - 37
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -273,25 +273,35 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         updateRay.setRb_auditman(BaseContextHolder.getUserName());
         recbalanceMapper.updateByPrimaryKeySelective(updateRay);
         /**
-         * 更新客户资料
-         * cu_preamount=nvl(cu_preamount,0)+rb_preamount,
-         * cu_recamount=nvl(cu_recamount,0)-rb_rbdamount,
-         * cu_leftamount=cu_beginaramount-cu_beginprerecamount+cu_recamount-cu_preamount;
+         * 更新客户应收
          */
-        Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(recbalance.getRb_custid());
-        Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
-        Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
-        Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
-        Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
-
-        Customer customer = new Customer();
+        String con="ca_custid="+recbalance.getRb_custid()+" and ca_currency='"+recbalance.getRb_currency()+"'";
+        CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
         Double paybalancePreamount = recbalance.getRb_preamount();
-        customer.setId(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
-        customer.setId(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
-        customer.setCu_preamount(preamount+paybalancePreamount);
-        customer.setCu_recamount(recamount-amountTotal2);
-        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amountTotal2-preamount-paybalancePreamount);
-        recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
+        if (custar == null){
+            custar=new CustAramount();
+            custar.setCa_custid(recbalance.getRb_custid());
+            custar.setCa_custcode(recbalance.getRb_custcode());
+            custar.setCa_custname(recbalance.getRb_custname());
+            custar.setCa_currency(recbalance.getRb_currency());
+            custar.setCa_begindate(null);
+            custar.setCa_beginprerecamount(new Double(0));
+            custar.setCa_beginaramount(new Double(0));
+            custar.setCa_preamount(paybalancePreamount);
+            custar.setCa_recamount(new Double(0));
+            custar.setCa_leftamount(new Double(0)-paybalancePreamount);
+            custar.setCompanyId(companyId);
+            recbalanceMapper.insertCustAramount(custar);
+        }else {
+            Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
+            Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
+            Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
+            custar.setCa_preamount(capreamount+paybalancePreamount);
+            custar.setCa_recamount(carecamount-amountTotal2);
+            custar.setCa_leftamount(caleftamount-amountTotal2-paybalancePreamount);
+            recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
+        }
+        recbalanceMapper.updateCustleftamountByPrimaryKey(recbalance.getRb_custid());
 
         //更新本次核销金额
         for (Recbalancedetail detail: recbalancedetail) {
@@ -308,7 +318,6 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             subledger1.setSl_namount(namount-nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
-
         //计算期间金额
         Statsinfo statsinfo = new Statsinfo();
         List<Integer> ymList = recbalancedetMapper.selectYm(Math.toIntExact(id));
@@ -326,9 +335,6 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         this.updateProdInoutStatus(id);
 
         DocBaseDTO baseDTO = getBaseDTOById(id);
-//        commonService.commonAudit(BillCodeSeq.RECBALANCE.getCaller(),
-//                "rb_id="+baseDTO.getId(),"rb_status","rb_statuscode",
-//                "rb_auditdate","rb_auditman");
         //日志记录
         messageLogService.audit(baseDTO);
         return baseDTO;
@@ -371,27 +377,40 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
 
     @Override
     public void unAudit(Long id) {
-        //更新供应商资料
-        /**
-         * ve_preamount=nvl(ve_preamount,0)-pb_preamount,
-         * ve_payamount=nvl(ve_payamount,0)+pb_pbdamount,
-         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+        Long companyId = BaseContextHolder.getCompanyId();
+        /**客户应收
          */
         Recbalance rec = recbalanceMapper.selectByPrimaryKey(Math.toIntExact(id));
         Double pay_preamount = rec.getRb_preamount()==null?new Double(0):rec.getRb_preamount();
         Double pay_pbdamount = rec.getRb_rbdamount()==null?new Double(0):rec.getRb_rbdamount();
-        Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(rec.getRb_custid());
-        Double preamount = customerData.getCu_preamount()==null?(new Double(0)):customerData.getCu_preamount();
-        Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
-        Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
-        Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
-        Customer customer = new Customer();
-        customer.setId(Long.valueOf(String.valueOf(rec.getRb_custid())));
-        customer.setCu_preamount(preamount-pay_preamount);
-        customer.setCu_recamount(recamount+pay_pbdamount);
-        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+pay_pbdamount-preamount+pay_preamount);
-        recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
 
+        String con="ca_custid="+rec.getRb_custid()+" and ca_currency='"+rec.getRb_currency()+"'";
+        CustAramount custar=recbalanceMapper.selectCustArByCondition(con,companyId);
+        Double paybalancePreamount = rec.getRb_preamount();
+        if (custar == null){
+            custar=new CustAramount();
+            custar.setCa_custid(rec.getRb_custid());
+            custar.setCa_custcode(rec.getRb_custcode());
+            custar.setCa_custname(rec.getRb_custname());
+            custar.setCa_currency(rec.getRb_currency());
+            custar.setCa_begindate(null);
+            custar.setCa_beginprerecamount(new Double(0));
+            custar.setCa_beginaramount(new Double(0));
+            custar.setCa_preamount(new Double(0)-pay_preamount);
+            custar.setCa_recamount(pay_pbdamount);
+            custar.setCa_leftamount(new Double(0)- pay_pbdamount + pay_preamount);
+            custar.setCompanyId(companyId);
+            recbalanceMapper.insertCustAramount(custar);
+        }else {
+            Double capreamount = custar.getCa_preamount()==null?new Double(0):custar.getCa_preamount();
+            Double carecamount = custar.getCa_recamount()==null?new Double(0):custar.getCa_recamount();
+            Double caleftamount = custar.getCa_leftamount()==null?new Double(0):custar.getCa_leftamount();
+            custar.setCa_preamount(capreamount-pay_preamount);
+            custar.setCa_recamount(carecamount+pay_pbdamount);
+            custar.setCa_leftamount(caleftamount+pay_pbdamount+pay_preamount);
+            recbalanceMapper.updateCustAramountByPrimaryKeySelective(custar);
+        }
+        recbalanceMapper.updateCustleftamountByPrimaryKey(rec.getRb_custid());
         //更新账户资料金额
         List<Recbalancedet> recbalancedet = recbalancedetMapper.selectByPrimaryKey(Math.toIntExact(id));
         for (Recbalancedet det:recbalancedet) {

+ 156 - 0
applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml

@@ -879,4 +879,160 @@
   <select id="checkStatus" resultType="int">
     select count(1) from recbalance where ifnull(rb_statuscode,0)='AUDITED' and rb_id= #{id,jdbcType=INTEGER}
   </select>
+  <!--客户应收-->
+  <resultMap id="CustArResultMap" type="com.usoftchina.saas.money.po.CustAramount">
+    <id column="ca_id" jdbcType="INTEGER" property="id" />
+    <result column="ca_custid" jdbcType="INTEGER" property="ca_custid" />
+    <result column="ca_custcode" jdbcType="VARCHAR" property="ca_custcode" />
+    <result column="ca_custname" jdbcType="VARCHAR" property="ca_custname" />
+    <result column="ca_currency" jdbcType="VARCHAR" property="ca_currency" />
+    <result column="ca_begindate" jdbcType="TIMESTAMP" property="ca_begindate" />
+    <result column="ca_beginaramount" jdbcType="DOUBLE" property="ca_beginaramount" />
+    <result column="ca_beginprerecamount" jdbcType="DOUBLE" property="ca_beginprerecamount" />
+    <result column="ca_preamount" jdbcType="DOUBLE" property="ca_preamount" />
+    <result column="ca_recamount" jdbcType="DOUBLE" property="ca_recamount" />
+    <result column="ca_leftamount" jdbcType="DOUBLE" property="ca_leftamount" />
+    <result column="companyid" jdbcType="INTEGER" property="companyId" />
+  </resultMap>
+  <sql id="CustAramount_Column_List">
+    ca_id, ca_custid,ca_custcode, ca_custname, ca_currency,ca_begindate, ca_beginaramount, ca_beginprerecamount,
+    ca_recamount,ca_preamount,ca_leftamount,companyid
+  </sql>
+  <select id="selectCustArByCondition" resultMap="CustArResultMap">
+    select
+    <include refid="CustAramount_Column_List" />
+    from custaramount
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and   custaramount.companyId = #{companyId}
+      </if>
+    </where>
+  </select>
+  <update id="updateCustAramountByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.CustAramount">
+    update CustAramount
+    <set>
+      <if test="ca_custid != null">
+        ca_custid = #{ca_custid,jdbcType=INTEGER},
+      </if>
+      <if test="ca_custcode != null">
+        ca_custcode = #{ca_custcode,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_custname != null">
+        ca_custname = #{ca_custname,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_currency != null">
+        ca_currency = #{ca_currency,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_begindate != null">
+        ca_begindate = #{ca_begindate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="ca_beginaramount != null">
+        ca_beginaramount = #{ca_beginaramount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_beginprerecamount != null">
+        ca_beginprerecamount = #{ca_beginprerecamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_recamount != null">
+        ca_recamount = #{ca_recamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_preamount != null">
+        ca_preamount = #{ca_preamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_leftamount != null">
+        ca_leftamount = #{ca_leftamount,jdbcType=DOUBLE},
+      </if>
+      <if test="companyId != null">
+        companyid = #{companyId,jdbcType=INTEGER},
+      </if>
+    </set>
+    where ca_id = #{id}
+  </update>
+  <update id="updateCustleftamountByPrimaryKey" parameterType="java.lang.Integer">
+        update customer
+    <set>
+      cu_leftamount=ifnull((select sum(ca_leftamount*(case when ifnull(cr_rate,0)=0 then 1 else ifnull(cr_rate,0) end ))
+      from custaramount left join currencys on cr_name=ca_currency and custaramount.companyid=currencys.companyid
+      where custaramount.companyid=customer.companyid and ca_custid=#{cu_id,jdbcType=INTEGER}),0)
+    </set>
+    where cu_id = #{cu_id,jdbcType=INTEGER}
+  </update>
+  <insert id="insertCustAramount" parameterType="com.usoftchina.saas.money.po.CustAramount">
+    <selectKey resultType="java.lang.Long" keyProperty="id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into CustAramount
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="companyId != null">
+        companyId,
+      </if>
+      <if test="ca_custid != null">
+        ca_custid,
+      </if>
+      <if test="ca_custcode != null">
+        ca_custcode,
+      </if>
+      <if test="ca_custname != null">
+        ca_custname,
+      </if>
+      <if test="ca_currency != null">
+        ca_currency,
+      </if>
+      <if test="ca_begindate != null">
+        ca_begindate,
+      </if>
+      <if test="ca_beginaramount != null">
+        ca_beginaramount,
+      </if>
+      <if test="ca_beginprerecamount != null">
+        ca_beginprerecamount,
+      </if>
+      <if test="ca_recamount != null">
+        ca_recamount,
+      </if>
+      <if test="ca_preamount != null" >
+        ca_preamount,
+      </if>
+      <if test="ca_leftamount != null" >
+        ca_leftamount,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="companyId != null">
+        #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="ca_custid != null">
+        #{ca_custid,jdbcType=INTEGER},
+      </if>
+      <if test="ca_custcode != null">
+        #{ca_custcode,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_custname != null">
+        #{ca_custname,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_currency != null">
+        #{ca_currency,jdbcType=VARCHAR},
+      </if>
+      <if test="ca_begindate != null">
+        #{ca_begindate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="ca_beginaramount != null">
+        #{ca_beginaramount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_beginprerecamount != null">
+        #{ca_beginprerecamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_recamount != null">
+        #{ca_recamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_preamount != null" >
+        #{ca_preamount,jdbcType=DOUBLE},
+      </if>
+      <if test="ca_leftamount != null" >
+        #{ca_leftamount,jdbcType=DOUBLE},
+      </if>
+    </trim>
+  </insert>
 </mapper>

+ 12 - 4
applications/purchase/purchase-api/src/main/java/com/usoftchina/saas/purchase/api/ProdInOutApi.java

@@ -3,11 +3,11 @@ package com.usoftchina.saas.purchase.api;
 import com.usoftchina.saas.auth.client.interceptor.ServiceFeignInterceptor;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @Author chenwei
@@ -32,4 +32,12 @@ public interface ProdInOutApi {
      */
     @PostMapping("/prodinout/b2bStatus/update")
     Result updateB2BStatus(@RequestParam("id") Long id, @RequestParam("status") String status);
+
+    /**
+     * 更新明细对账状态
+     * @param prodInOutStatusDTO
+     * @return
+     */
+    @PostMapping("/prodinout/apcheckStatus/update")
+    Result updateApcheckStatus(@RequestBody List<ProdInOutStatusDTO> prodInOutStatusDTO);
 }

+ 2 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdIODetailDTO.java

@@ -91,6 +91,8 @@ public class ProdIODetailDTO extends CommonBaseDTO implements Serializable {
 
     private Integer iodetno;
 
+    private String apcheckStatus;
+
     private ProductDTO productDTO;
 
 }

+ 24 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdInOutStatusDTO.java

@@ -0,0 +1,24 @@
+package com.usoftchina.saas.purchase.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Description 更新明细对账状态
+ * @Author chenwei
+ * @Date 2019/03/09
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ProdInOutStatusDTO implements Serializable{
+
+    private String inoutNo;
+    private Long detno;
+    private Long companyId;
+    private String status;
+
+}

+ 14 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/controller/ProdInOutController.java

@@ -7,12 +7,15 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import com.usoftchina.saas.purchase.po.ProdInOutList;
 import com.usoftchina.saas.purchase.service.ProdInOutService;
 import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * Created by zdw
  * 2018-10-17 11:41.
@@ -227,4 +230,15 @@ public class ProdInOutController {
         prodInOutService.updateB2BStatus(id, status);
         return Result.success();
     }
+
+    /**
+     * 更新明细对账状态
+     * @param prodInOutStatusDTO
+     * @return
+     */
+    @PostMapping("/apcheckStatus/update")
+    public Result updateApcheckStatus(@RequestBody List<ProdInOutStatusDTO> prodInOutStatusDTO){
+        prodInOutService.updateApcheckStatus(prodInOutStatusDTO);
+        return Result.success();
+    }
 }

+ 2 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.purchase.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import com.usoftchina.saas.purchase.po.ProdIODetail;
 import org.apache.ibatis.annotations.Param;
 
@@ -33,4 +34,5 @@ public interface ProdIODetailMapper extends CommonBaseMapper<ProdIODetail> {
 
     void getDefaultWarehouseByProduct(@Param("pi_id") Long pi_id);
 
+    void updateApcheckStatus(ProdInOutStatusDTO prodInOutStatusDTO);
 }

+ 2 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdIODetail.java

@@ -86,6 +86,8 @@ public class ProdIODetail extends CommonBaseEntity implements Serializable {
 
     private Integer iodetno;
 
+    private String apcheckStatus;
+
     private ProductDTO productDTO;
 
 }

+ 9 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java

@@ -9,10 +9,13 @@ import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import com.usoftchina.saas.purchase.mapper.ProdInOutMapper;
 import com.usoftchina.saas.purchase.po.ProdInOut;
 import com.usoftchina.saas.purchase.po.ProdInOutList;
 
+import java.util.List;
+
 /**
  * Created by zdw
  * 2018-10-17 13:39.
@@ -92,4 +95,10 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      * @param status
      */
     void updateB2BStatus(Long id, String status);
+
+    /**
+     * 更新出入库明细对账状态
+     * @param prodInOutStatusDTO
+     */
+    void updateApcheckStatus(List<ProdInOutStatusDTO> prodInOutStatusDTO);
 }

+ 11 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -24,6 +24,7 @@ import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdIODetailDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
+import com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO;
 import com.usoftchina.saas.purchase.mapper.*;
 import com.usoftchina.saas.purchase.po.ProdIODetail;
 import com.usoftchina.saas.purchase.po.ProdInOut;
@@ -32,6 +33,7 @@ import com.usoftchina.saas.purchase.service.ProdInOutService;
 import com.usoftchina.saas.transfers.api.SendMessageApi;
 import com.usoftchina.saas.transfers.dto.MessageInfo;
 import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -89,6 +91,15 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         getMapper().updateByPrimaryKeySelective(prodInOut);
     }
 
+    @Override
+    public void updateApcheckStatus(List<ProdInOutStatusDTO> prodInOutStatusDTOList){
+        if (!CollectionUtils.isEmpty(prodInOutStatusDTOList)){
+            for (ProdInOutStatusDTO prodInOutStatusDTO : prodInOutStatusDTOList) {
+                prodIODetailMapper.updateApcheckStatus(prodInOutStatusDTO);
+            }
+        }
+    }
+
     @Override
     public PageInfo<ProdInOutList> getListData(PageRequest page, ListReqDTO req) {
         //设置默认分页
@@ -130,7 +141,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //将prodInOut实体对象转化为传输对象
         ProdInOutDTO main = BeanMapper.map(prodInOut,ProdInOutDTO.class);
         //查询从表
-
         List<ProdIODetail> prodIODetails =prodIODetailMapper.selectByFK(id);
         List<ProdIODetailDTO> items = BeanMapper.mapList(prodIODetails,ProdIODetailDTO.class);
         prodInOutFormDTO.setMain(main);

+ 7 - 1
applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -44,6 +44,7 @@
     <result column="pd_yqty" jdbcType="DOUBLE" property="pd_yqty" />
     <result column="pd_ioid" jdbcType="INTEGER" property="pd_ioid" />
     <result column="iocode" jdbcType="VARCHAR" property="iocode" />
+    <result column="apcheckStatus" jdbcType="VARCHAR" property="apcheckStatus" />
     <result column="iodetno" jdbcType="INTEGER" property="iodetno" />
     <association property="productDTO" javaType="com.usoftchina.saas.document.dto.ProductDTO">
       <id column="pr_id" property="id"/>
@@ -679,5 +680,10 @@
     where pd_piid = #{pi_id,jdbcType=INTEGER};
   </update>
 
-
+  <update id="updateApcheckStatus" parameterType="com.usoftchina.saas.purchase.dto.ProdInOutStatusDTO">
+    UPDATE prodiodetail SET apcheckStatus = #{status, jdbcType=VARCHAR}
+    WHERE pd_inoutno = #{inoutNo, jdbcType=VARCHAR}
+    AND pd_pdno = #{detno, jdbcType=INTEGER}
+    AND companyid = #{companyId, jdbcType=INTEGER}
+  </update>
 </mapper>