Browse Source

1.反结账存储过程
2.客户供应商对账单德合计

heqinwei 7 years ago
parent
commit
27a3d2c694

+ 0 - 9
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/ListReqDTO.java

@@ -21,15 +21,6 @@ public class ListReqDTO implements Serializable {
 
     private String calculateFields;
 
-    private String ym;
-
-    public String getYm() {
-        return ym;
-    }
-
-    public void setYm(String ym) {
-        this.ym = ym;
-    }
 
     //将列拼成查询语句,直接查询出数据的格式为json
     public String getCalculateFieldsSql() {

+ 3 - 1
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/EndProductMapper.java

@@ -10,7 +10,7 @@ public interface EndProductMapper {
 
     void endProduct(Map<String, Object> map);
 
-    void endFund(Map<String, Object> map);
+    void end(Map<String, Object> map);
 
     String selectPeriod(@Param("companyId") Long companyId);
 
@@ -20,6 +20,8 @@ public interface EndProductMapper {
 
     void updatePeriodStatus(@Param("status") Long status,@Param("period") String period, @Param("companyId") Long companyId);
 
+    void updateRe(@Param("ym") String ym, @Param("companyId") Long companyId);
+
     int checkPay(Long companyId);
     int checkRec(Long companyId);
     void deleteSub(Long companyId);

+ 6 - 2
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/EndProductServiceImpl.java

@@ -16,6 +16,7 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
 import java.util.HashMap;
@@ -55,6 +56,7 @@ public class EndProductServiceImpl implements EndProductService {
         return map;
     }
 
+    @Transactional
     @Override
     public String endAccount() {
         String period = endProductMapper.selectPeriod(BaseContextHolder.getCompanyId());
@@ -63,14 +65,15 @@ public class EndProductServiceImpl implements EndProductService {
         map.put("yearMonth", period);
         map.put("companyId", BaseContextHolder.getCompanyId());
         map.put("result", null);
-        endProductMapper.endProduct(map);
-        endProductMapper.endFund(map);
+//        endProductMapper.endProduct(map);
+        endProductMapper.end(map);
         endProductMapper.updatePeriodStatus(99L, period, BaseContextHolder.getCompanyId());
         DocBaseDTO docBaseDTO = generateMsgObj(Long.parseLong(period));
         messageLogService.customizeLog(docBaseDTO, Operation.ENDPRODUCT);
         return String.valueOf(map.get("result"));
     }
 
+    @Transactional
     @Override
     public void unEndAccount() {
         int payc = endProductMapper.checkPay(BaseContextHolder.getCompanyId());
@@ -84,6 +87,7 @@ public class EndProductServiceImpl implements EndProductService {
         if (StringUtils.isEmpty(period)){
             throw new BizException(BizExceptionCode.BIZ_UNENDPRODUCT);
         }else{
+            endProductMapper.updateRe(period, BaseContextHolder.getCompanyId());
             endProductMapper.updatePeriodStatus(0L, period, BaseContextHolder.getCompanyId());
             messageLogService.customizeLog(generateMsgObj(Long.parseLong(period)), Operation.UNENDPRODUCT);
         }

+ 6 - 2
applications/commons/commons-server/src/main/resources/mapper/EndProductMapper.xml

@@ -29,14 +29,18 @@
         CALL SP_ENDPRODUCT(?, ?, ?)
     </select>
 
-    <select id="endFund" parameterMap="spParamMap" statementType="CALLABLE">
-        CALL SP_ENDFUND(?, ?, ?)
+    <select id="end" parameterMap="spParamMap" statementType="CALLABLE">
+        CALL SP_END(?, ?, ?)
     </select>
 
     <update id="updatePeriodStatus" >
         update periodsdetail set pd_status=#{status} where pd_detno=#{period} and companyId=#{companyId}
     </update>
 
+    <update id="updateRe" >
+        UPDATE receivablesdetail SET RD_STATUS=0 WHERE date_format(rd_date, '%Y%m')=#{ym} AND companyid=#{companyId};
+    </update>
+
     <select id="checkPay" parameterType="java.lang.Long" resultType="java.lang.Integer">
         select count(1) from vendor where (ve_id,companyid) in (select pb_vendid,companyid from (
         select pbd_ym,pb_vendid,paybalance.companyid from paybalance,paybalancedetail where pb_id=pbd_pbid and pbd_slkind='期初余额'

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/CustomerCheckViewMapper.java

@@ -10,6 +10,6 @@ import java.util.List;
 public interface CustomerCheckViewMapper {
     List<CustomerCheckView> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
     String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
-    VendOrCustAdd selectCustAdd(@Param("sl_custid") Integer sl_vendid, @Param("sl_ym") Integer sl_ym, @Param("companyId") Long companyId);
+    VendOrCustAdd selectCustAdd(@Param("sl_custid") Integer sl_custid, @Param("cons") String cons, @Param("companyId") Long companyId);
     Integer getId(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VendorAcountViewMapper.java

@@ -9,6 +9,6 @@ import java.util.List;
 public interface VendorAcountViewMapper {
     List<VendorAcountView> selectByCondition(@Param("con")String con, @Param("companyId")Long companyId);
     String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
-    VendOrCustAdd selectVendAdd(@Param("sl_vendid") Integer sl_vendid, @Param("sl_ym") Integer sl_ym, @Param("companyId") Long companyId);
+    VendOrCustAdd selectVendAdd(@Param("sl_vendid") Integer sl_vendid, @Param("cons") String cons, @Param("companyId") Long companyId);
     Integer getId(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 11 - 10
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/MoneyReportServiceImpl.java

@@ -91,6 +91,7 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         List list = null;
         Long companyId = BaseContextHolder.getCompanyId();
         String con = req.getFinalCondition();
+        String cons = this.getDate(con);
         String calculateFieldsSql = req.getCalculateFieldsSql();
         JSONArray arr = null;
         if (null == con) {
@@ -103,14 +104,12 @@ public class MoneyReportServiceImpl implements MoneyReportService {
             list = vendorAcountViewMapper.selectByCondition(con, companyId);
             if (list.size() >0) {
                 VendorAcountView vendorAcountView = (VendorAcountView) list.get(0);
+                //取时间
+
                 Integer vid = new Integer(0);
                 vid = vendorAcountViewMapper.getId(vendorAcountView.getPi_vendcode(), Long.valueOf(vendorAcountView.getCompanyId()));
-                Integer ym = Integer.valueOf(req.getYm());
-                VendOrCustAdd vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, ym, Long.valueOf(vendorAcountView.getCompanyId()));
+                VendOrCustAdd vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, cons, Long.valueOf(vendorAcountView.getCompanyId()));
                 if (vendOrCustAdd != null) {
-                    vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                            + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                            - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
                     //封装成list
                     Map<String, Double> map1 = new HashMap<>();
                     map1.put("beginamount", vendOrCustAdd.getBeginamount());
@@ -154,12 +153,8 @@ public class MoneyReportServiceImpl implements MoneyReportService {
                 Integer vid = new Integer(0);
 
                 vid = customerCheckViewMapper.getId(customerCheckView.getPi_custcode(), Long.valueOf(customerCheckView.getCompanyId()));
-                Integer ym = Integer.valueOf(req.getYm());
-                VendOrCustAdd vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, ym, Long.valueOf(customerCheckView.getCompanyId()));
+                VendOrCustAdd vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, cons, Long.valueOf(customerCheckView.getCompanyId()));
                 if (vendOrCustAdd != null) {
-                    vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                            + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                            - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
                     //封装成list
                     Map<String, Double> map1 = new HashMap<>();
                     map1.put("beginamount", vendOrCustAdd.getBeginamount());
@@ -200,4 +195,10 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         }
         return map;
     }
+
+    public String getDate(String cons){
+        String date = cons.substring(8, 64);
+        System.out.println("date:" + date);
+        return date;
+    }
 }

+ 6 - 7
applications/money/money-server/src/main/resources/mapper/CustomerCheckViewMapper.xml

@@ -52,13 +52,12 @@
         <result column="nowpay" property="beginamount" jdbcType="DOUBLE" />
     </resultMap>
     <select id="selectCustAdd" resultMap="BaseAddMap">
-    select distinct a.sl_orderamount as beginamount, b.sl_orderamount as nowamount, c.sl_orderamount as nowpay FROM
-(select sl_orderamount,sl_custid,sl_ym, companyid from subledger where sl_kind = '期初余额') a
-left join (select sum(sl_orderamount) sl_orderamount,sl_custid,sl_ym from subledger where sl_kind = '出货单' or sl_kind = '销售退货单'
-group by sl_custid,sl_ym) b on a.sl_custid=b.sl_custid
-left join (select sum(sl_orderamount) sl_orderamount,sl_custid,sl_ym from subledger where sl_kind = '收款单' or sl_kind = '其他收入单'
-group by sl_custid,sl_ym) c on a.sl_custid=c.sl_custid
- where a.sl_custid=#{sl_custid,jdbcType=INTEGER} and a.sl_ym=#{sl_ym, jdbcType=INTEGER} and a.companyid = #{companyId}
+    select a.sl_orderamount as beginamount, b.nowamount, b.nowpay,(a.sl_orderamount +b.nowamount-b.nowpay) as nowbalance FROM
+    (select sl_orderamount,sl_custid,sl_date, companyid from subledger where sl_kind = '期初余额') a
+    left join (select sum(sl_amount) as nowamount,sum(sl_preamount) as nowpay,sl_custid,sl_date from subledger where sl_kind !='期初余额'
+    group by sl_custid,sl_date) b
+    on a.sl_custid=b.sl_custid
+    where a.sl_custid=#{sl_custid} and a.sl_date ${cons} and a.companyid = #{companyId} limit 1
   </select>
 
     <select id="getId" resultType="java.lang.Integer">

+ 6 - 7
applications/money/money-server/src/main/resources/mapper/VendorAcountViewMapper.xml

@@ -55,13 +55,12 @@
     <result column="nowpay" property="beginamount" jdbcType="DOUBLE" />
   </resultMap>
   <select id="selectVendAdd" resultMap="BaseAddMap">
-    select distinct a.sl_orderamount as beginamount, b.sl_orderamount as nowamount, c.sl_orderamount as nowpay FROM
-(select sl_orderamount,sl_vendid,sl_ym, companyid from subledger where sl_kind = '期初余额') a
-left join (select sum(sl_orderamount) sl_orderamount,sl_vendid,sl_ym from subledger where sl_kind = '采购验收单' or sl_kind = '采购验退单'
-group by sl_vendid,sl_ym) b on a.sl_vendid=b.sl_vendid
-left join (select sum(sl_orderamount) sl_orderamount,sl_vendid,sl_ym from subledger where sl_kind = '付款单' or sl_kind = '其他支出单'
-group by sl_vendid,sl_ym) c on a.sl_vendid=c.sl_vendid
- where a.sl_vendid=#{sl_vendid,jdbcType=INTEGER} and a.sl_ym=#{sl_ym, jdbcType=INTEGER} and a.companyid = #{companyId}
+    select a.sl_orderamount as beginamount, b.nowamount, b.nowpay,(a.sl_orderamount +b.nowamount-b.nowpay) as nowbalance FROM
+    (select sl_orderamount,sl_vendid,sl_date, companyid from subledger where sl_kind = '期初余额') a
+    left join (select sum(sl_amount) as nowamount,sum(sl_preamount) as nowpay,sl_vendid,sl_date from subledger where sl_kind !='期初余额'
+    group by sl_vendid,sl_date) b
+    on a.sl_vendid=b.sl_vendid
+    where a.sl_vendid=#{sl_vendid} and a.sl_date ${cons} and a.companyid = #{companyId} limit 1
   </select>
 
   <select id="getId" resultType="java.lang.Integer">