Browse Source

报销开发

anderx 2 years ago
parent
commit
d07ab4833f

+ 2 - 0
src/main/java/com/goafanti/common/dao/ExpenseAccountMapper.java

@@ -50,4 +50,6 @@ public interface ExpenseAccountMapper {
     MainExpenseAccount selectByMainId(Integer id);
 
     void updateByMainId(@Param("id") Integer id, @Param("status") Integer status);
+
+    List<ExpenseAccount> selectListByMainId(Integer id);
 }

+ 9 - 6
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -368,22 +368,19 @@
            date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
             date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
             date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
+        FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
+    left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
+    left join t_order_mid tm on a.order_no =tm.order_no
   </sql>
   <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
     SELECT
     <include refid="selectDtailsSql"/>
-    FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
-    left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
-    left join t_order_mid tm on a.order_no =tm.order_no
     WHERE a.id= #{id}
   </select>
 
   <select id="selectByCheckNo" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
     SELECT
     <include refid="selectDtailsSql"/>
-    FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
-    left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
-    left join t_order_mid tm on a.order_no =tm.order_no
     WHERE a.check_no= #{checkNo}
   </select>
 
@@ -672,6 +669,12 @@
     where a.id= #{id}
   </select>
 
+  <select id="selectListByMainId" resultMap="BaseResultMap">
+    select b.*
+    from expense_relationship a left join expense_account b  on a.ea_id =b.id
+    where a.id =#{id}
+  </select>
+
   <resultMap id="MainMap" type="com.goafanti.expenseAccount.bo.MainExpenseAccount">
     <id column="id" jdbcType="INTEGER" property="id" />
     <result column="check_no" jdbcType="VARCHAR" property="checkNo" />

+ 24 - 56
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -369,30 +369,34 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         //完成申请
         if (newEa.getStatus()==2){
             //如果是借支则订单新增
-            if (useEa.getType()!=4){
-                //不然就看是否挂载借支订单进行抵扣
-                if (useEa.getDebitId()!=null){
-                    ExpenseAccount useDebit=expenseAccountMapper.selectByPrimaryKey(useEa.getDebitId());
-                    if (useDebit.getLiquidationStatus()==2){
-                        List<ExpenseAccount> expenseAccounts = expenseAccountMapper.selectByDebitId(useEa.getDebitId());
-                        boolean flag=true;
-                        for (ExpenseAccount expenseAccount : expenseAccounts) {
-                            if(!expenseAccount.getId().equals(in.getId())&&expenseAccount.getStatus()!=2){
-                                flag=false;
-                                break;
+            List<ExpenseAccount> expenseAccounts1 = expenseAccountMapper.selectListByMainId(in.getId());
+            for (ExpenseAccount e : expenseAccounts1) {
+                if (e.getType()!=4){
+                    //不然就看是否挂载借支订单进行抵扣
+                    if (e.getDebitId()!=null){
+                        ExpenseAccount useDebit=expenseAccountMapper.selectByPrimaryKey(e.getDebitId());
+                        if (useDebit.getLiquidationStatus()==2){
+                            List<ExpenseAccount> expenseAccounts = expenseAccountMapper.selectByDebitId(e.getDebitId());
+                            boolean flag=true;
+                            for (ExpenseAccount expenseAccount : expenseAccounts) {
+                                if(!expenseAccount.getId().equals(in.getId())&&expenseAccount.getStatus()!=2){
+                                    flag=false;
+                                    break;
+                                }
+                            }
+                            if (flag){
+                                ExpenseAccount debit=new ExpenseAccount();
+                                debit.setId(e.getDebitId());
+                                debit.setLiquidationStatus(3);
+                                expenseAccountMapper.updateByPrimaryKeySelective(debit);
                             }
-                        }
-                        if (flag){
-                            ExpenseAccount debit=new ExpenseAccount();
-                            debit.setId(useEa.getDebitId());
-                            debit.setLiquidationStatus(3);
-                            expenseAccountMapper.updateByPrimaryKeySelective(debit);
-                        }
 
+                        }
                     }
                 }
             }
 
+
         }
         if (newEa.getStatus()==1){
             if (newEa.getProcessStatus()==EAProcessStatus.CWSH.getCode()){
@@ -408,49 +412,13 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             }
         }
 
-            //审核处理审核表
-            pushExpenseAccountExamine(in);
+        //审核处理审核表
+        pushExpenseAccountExamine(in);
         expenseAccountMapper.updateByPrimaryKeySelective(newEa);
         return 1;
     }
 
-    private void pushExpenseFinaceCount(ExpenseAccount useEa, ExpenseAccount newEa) {
-        String startTime=DateUtils.formatDate(useEa.getCreateTime(),AFTConstants.YYYYMMDD);
-        AdminListBo admin = adminMapper.getDeptNameByAid(useEa.getAid());
-        FinanceCount financeCount = financeCountMapper.selectByAidAndDates(admin.getDepFinance(), startTime);
-        //通过
-        if (newEa.getStatus()==1){
-            //下一步是财务审核就要加财务统计
-            if (newEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()||
-                    useEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
-                if (newEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
-                    addFinanceCount(admin.getDepFinance(), startTime);
-                    //如果当前是财务审核通过就要减去未审核
-                }else if (useEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
-                    FinanceCount newFinanceCount =new FinanceCount();
-                    newFinanceCount.setId(financeCount.getId());
-                    newFinanceCount.setExpenseUnauditedCount(financeCount.getExpenseUnauditedCount()-1);
-                    financeCountMapper.updateByPrimaryKeySelective(newFinanceCount);
-                }
-            }
-         //驳回
-        }else if (newEa.getStatus()==3){
-            if (financeCount!=null) {
-                FinanceCount newFinanceCount = new FinanceCount();
-                newFinanceCount.setId(financeCount.getId());
-                //财务审核时减去未审核与
-                if (useEa.getProcessStatus() == EAProcessStatus.CWSH.getCode()) {
-                    newFinanceCount.setExpenseCount(financeCount.getExpenseCount() - 1);
-                    newFinanceCount.setExpenseUnauditedCount(financeCount.getExpenseUnauditedCount() - 1);
-
-                } else if (useEa.getProcessStatus() > EAProcessStatus.CWSH.getCode()) {
-                    newFinanceCount.setExpenseCount(financeCount.getExpenseCount() - 1);
-                }
-                financeCountMapper.updateByPrimaryKeySelective(newFinanceCount);
-            }
-        }
 
-    }
     private void addFinanceCount(String aid,Date startTime ) {
         String forDate=DateUtils.formatDate(startTime,AFTConstants.YYYYMMDD);
         addFinanceCount(aid,forDate);