Browse Source

1.修改二次保存报错

heqinwei 7 years ago
parent
commit
5a77ba3889

+ 8 - 22
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -292,31 +292,17 @@
       bk_remark = #{bkRemark,jdbcType=LONGVARCHAR}
     where bk_id = #{bkId,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
+  <update id="updateBankcode">
     update bankinformation
-    set bk_bankcode = #{bkBankcode,jdbcType=VARCHAR},
-      bk_bankname = #{bkBankname,jdbcType=VARCHAR},
-      bk_date = #{bkDate,jdbcType=TIMESTAMP},
-      bk_type = #{bkType,jdbcType=VARCHAR},
-      bk_beginamount = #{bkBeginamount,jdbcType=DOUBLE},
-      bk_thisamount = #{bkThisamount,jdbcType=DOUBLE},
-      bk_status = #{bkStatus,jdbcType=VARCHAR},
-      bk_statuscode = #{bkStatuscode,jdbcType=VARCHAR},
-      bk_recorderid = #{bkRecorderid,jdbcType=INTEGER},
-      bk_recorder = #{bkRecorder,jdbcType=VARCHAR},
-      bk_recorddate = #{bkRecorddate,jdbcType=TIMESTAMP},
-      bk_ym = #{bkYm,jdbcType=INTEGER},
-      companyid = #{companyId,jdbcType=INTEGER},
-      updaterId = #{updaterId,jdbcType=INTEGER},
-      updateTime = #{updateTime,jdbcType=TIMESTAMP},
-      bk_text1 = #{bkText1,jdbcType=VARCHAR},
-      bk_text2 = #{bkText2,jdbcType=VARCHAR},
-      bk_text3 = #{bkText3,jdbcType=VARCHAR},
-      bk_text4 = #{bkText4,jdbcType=VARCHAR},
-      bk_text5 = #{bkText5,jdbcType=VARCHAR}
-    where bk_id = #{bk_id,jdbcType=INTEGER}
+    set bk_thisamount = nvl(#{bk_thisamount,jdbcType=DOUBLE},0) ${symbol} #{nowbalance}
+    where bk_bankcode = #{bankcode,jdbcType=VARCHAR}
   </update>
 
+  <select id="selectThisamount" resultMap="java.lang.Double" parameterType="com.usoftchina.saas.document.entities.Bankinformation">
+   select bk_thisamount from bankinformation
+    where bk_bankcode = #{bankcode,jdbcType=VARCHAR}
+  </select>
+
   <select id="selectAll" resultMap="BaseResultMap">
     SELECT * FROM bankinformation
   </select>

+ 27 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java

@@ -10,6 +10,7 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.mapper.BankinformationMapper;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.money.mapper.OthreceiptsMapper;
@@ -39,6 +40,8 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
 
     @Override
     public DocBaseDTO insert(Othte othte) {
@@ -72,7 +75,7 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
             othreceiptsdetail1.setOrd_orid(Math.toIntExact(id));
             othreceiptsdetail1.setCompanyId(BaseContextHolder.getCompanyId());
             if (othreceiptsdetail1.getId() > 0 ){
-                othreceiptsdetailMapper.updateByPrimaryKey(othreceiptsdetail1);
+                othreceiptsdetailMapper.updateByPrimaryKeySelective(othreceiptsdetail1);
             }else {
                 othreceiptsdetailMapper.insertSelective(othreceiptsdetail1);
             }
@@ -94,6 +97,16 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
         }else {
             othreceiptsMapper.updateByPrimaryKeySelective(othreceipts);
         }
+
+        Double amount = bankinformationMapper.selectThisamount(othreceipts.getOr_bankcode());
+        //取从表金额
+        List<Othreceiptsdetail> othreceiptsdetailList = othte.getItems();
+        Iterator isList = othreceiptsdetailList.iterator();
+        while (isList.hasNext()){
+            Othreceiptsdetail othreceiptsdetail = (Othreceiptsdetail) isList.next();
+            bankinformationMapper.updateBankcode(amount, othreceiptsdetail.getOrd_nowbalance(),
+                    othreceipts.getOr_bankcode(), "+");
+        }
     }
 
     @Override
@@ -107,6 +120,17 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
         //删除中间表
         othreceipts = othreceiptsMapper.selectByPrimaryKey(id);
         banksubledgerMapper.deleteByPrimaryKey(othreceipts.getOr_code(), "其他收入单");
+
+        //更新资金
+        Double amount = bankinformationMapper.selectThisamount(othreceipts.getOr_bankcode());
+        List<Othreceiptsdetail> othreceiptsdetailList = othreceiptsdetailMapper.selectByPrimaryKey(id);
+        Iterator isList = othreceiptsdetailList.iterator();
+        while (isList.hasNext()){
+            Othreceiptsdetail othreceiptsdetail = (Othreceiptsdetail) isList.next();
+            bankinformationMapper.updateBankcode(amount, othreceiptsdetail.getOrd_nowbalance(),
+                    othreceipts.getOr_bankcode(), "-");
+        }
+
     }
 
 
@@ -163,7 +187,8 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
             othreceipts.setOr_statuscode(Status.AUDITED.name());
             Othte othte = this.select(Math.toIntExact(othreceipts.getId()));
             this.changBankUntil(othte);
-            othreceiptsMapper.updateByPrimaryKeySelective(othreceipts);
+            this.insert(othte);
+//            othreceiptsMapper.updateByPrimaryKeySelective(othreceipts);
         }
     }