Browse Source

报销开发子报销列表新增字段

anderx 2 years ago
parent
commit
44c4f3d39a

+ 3 - 1
src/main/java/com/goafanti/common/dao/ExpenseAccountMapper.java

@@ -45,11 +45,13 @@ public interface ExpenseAccountMapper {
 
     List<ExpenseAccount> selectByIds(List<String> split);
 
-    void updateByIds(@Param("list") List<String> list, @Param("status") Integer status);
+    void updateByIds(@Param("list") List<ExpenseAccount> list, @Param("status") Integer status);
 
     MainExpenseAccount selectByMainId(Integer id);
 
     void updateByMainId(@Param("id") Integer id, @Param("status") Integer status);
 
     List<ExpenseAccount> selectListByMainId(Integer id);
+
+    int selectCountByIdsAndType(@Param("list") List<String> list, @Param("type") Integer type);
 }

+ 52 - 11
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -481,8 +481,16 @@
     <if test="type != null">
       and a.type= #{type}
     </if>
-    <if test="checkNo != null or username != null" >
-      and (a.check_no like concat('%',#{checkNo},'%') or tm.buyer_name  like concat('%',#{username},'%'))
+    <if test="checkNo != null " >
+      <if test="expenseMain ==0">
+        and mea.check_no like concat('%',#{checkNo},'%')
+      </if>
+      <if test="expenseMain ==1">
+        and a.check_no like concat('%',#{checkNo},'%')
+      </if>
+    </if>
+    <if test="username != null" >
+      and  tm.buyer_name  like concat('%',#{username},'%')
     </if>
     <if test="startTime !=null and endTime !=null">
       and a.create_time between #{startTime} and #{endTime}
@@ -550,8 +558,11 @@
     <if test="type != null">
       and a.type= #{type}
     </if>
-    <if test="checkNo != null or username != null" >
-      and (a.check_no like concat('%',#{checkNo},'%') or tm.buyer_name  like concat('%',#{username},'%'))
+    <if test="checkNo != null " >
+      and a.check_no like concat('%',#{checkNo},'%')
+    </if>
+    <if test="username != null" >
+      and  tm.buyer_name  like concat('%',#{username},'%')
     </if>
     <if test="startTime !=null and endTime !=null">
       and a.create_time between #{startTime} and #{endTime}
@@ -613,6 +624,12 @@
     <if test="type != null">
       and a.type= #{type}
     </if>
+    <if test="checkNo != null " >
+      and a.check_no like concat('%',#{checkNo},'%')
+    </if>
+    <if test="username != null" >
+      and  tm.buyer_name  like concat('%',#{username},'%')
+    </if>
     <if test="startTime !=null and endTime !=null">
       and a.create_time between #{startTime} and #{endTime}
     </if>
@@ -718,11 +735,13 @@
   </select>
 
   <sql id="mainAllSql">
-    select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,
+    select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,b.real_amount,
+           date_format(b.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
            dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid ,eap.name ,eap.bank ,eap.accounts ,b.status,b.process_status,
            c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,c.user_names ,c.release_start ,c.release_end ,
-           c.district_name districtName,c.user_names userNames,
-           d.id detId,d.`type` detType,d.amount,d.real_amount realAmount ,d.start_district ,d.end_district
+           c.district_name districtName,c.user_names userNames,c.secondary_type ,c.secondary_type_other,c.attachment_url,
+           d.id detId,d.`type` detType,d.amount,d.real_amount realAmount ,d.start_district ,d.end_district,d.vehicle,d.vehicle_other,
+           d.pay_type ,d.invoice_type ,d.invoice_no,d.payer_name ,d.open_bank ,d.bank_accounts ,d.open_bank_address
     from expense_relationship a left join expense_account b on a.id =b.id
      left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
      left join t_order_new o on b.order_no =o.order_no left join expense_account_private eap on b.eaaid =eap.id
@@ -739,6 +758,7 @@
     <id column="id" jdbcType="INTEGER" property="id" />
     <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
     <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
+    <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
     <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
     <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
     <result column="aname" jdbcType="VARCHAR" property="aname" />
@@ -762,6 +782,9 @@
     <result column="sonAmount" jdbcType="DECIMAL" property="totalAmount" />
     <result column="type" jdbcType="INTEGER" property="type" />
     <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
+    <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
+    <result column="secondary_type_other" jdbcType="INTEGER" property="secondaryTypeOther" />
+    <result column="attachment_url" jdbcType="INTEGER" property="attachmentUrl" />
     <result column="user_names" jdbcType="VARCHAR" property="userNames" />
     <result column="release_start" jdbcType="VARCHAR" property="releaseStart" />
     <result column="release_end" jdbcType="VARCHAR" property="releaseEnd" />
@@ -775,14 +798,24 @@
     <result column="amount" jdbcType="DECIMAL" property="amount" />
     <result column="start_district" jdbcType="VARCHAR" property="startDistrict" />
     <result column="end_district" jdbcType="VARCHAR" property="endDistrict" />
+    <result column="vehicle" jdbcType="INTEGER" property="vehicle" />
+    <result column="vehicle_other" jdbcType="VARCHAR" property="vehicleOther" />
+    <result column="pay_type" jdbcType="INTEGER" property="payType" />
+    <result column="invoice_type" jdbcType="INTEGER" property="invoiceType" />
+    <result column="invoice_no" jdbcType="VARCHAR" property="invoiceNo" />
+    <result column="payer_name" jdbcType="VARCHAR" property="payerName" />
+    <result column="open_bank" jdbcType="VARCHAR" property="openBank" />
+    <result column="bank_accounts" jdbcType="VARCHAR" property="bankAccounts" />
+    <result column="open_bank_address" jdbcType="VARCHAR" property="openBankAddress" />
+
   </resultMap>
 
   <update id="updateByIds" >
     update expense_account
     set status= #{status}
     where id in
-    <foreach collection="list" open="(" close=")" separator="," item="id">
-      #{id}
+    <foreach collection="list" open="(" close=")" separator="," item="item">
+      #{item.id}
     </foreach>
   </update>
   <update id="updateByMainId">
@@ -795,13 +828,13 @@
     select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,
     date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.status,b.process_status,
     dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid ,
-    c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,c.user_names ,c.release_start ,c.release_end
+    c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,c.user_names ,c.release_start ,c.release_end,
+    c.attachment_url attachmentUrl
     from expense_relationship a
     left join expense_account b on a.id =b.id
     left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
     left join t_order_new o on b.order_no =o.order_no
     left join expense_account c on a.ea_id =c.id
-
     left join admin ad on b.aid=ad.id
     left join department adDep on ad .department_id=adDep.id
     where 1=1 and b.expense_main =1
@@ -948,5 +981,13 @@
       </foreach>
     </if>
   </select>
+  <select id="selectCountByIdsAndType" resultType="java.lang.Integer">
+    select count(*) from expense_account
+    where type =#{type}
+    and id in
+    <foreach collection="list" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </select>
 
 </mapper>

+ 8 - 0
src/main/java/com/goafanti/expenseAccount/bo/MainExpenseAccount.java

@@ -11,6 +11,7 @@ public class MainExpenseAccount  {
     private Integer processStatus;
     private String checkNo;
     private BigDecimal totalAmount;
+    private BigDecimal realAmount;
     private String orderNo;
     private String contractNo;
     private String aid;
@@ -26,6 +27,13 @@ public class MainExpenseAccount  {
     private String accounts;
     private String createTimeStr;
 
+    public BigDecimal getRealAmount() {
+        return realAmount;
+    }
+
+    public void setRealAmount(BigDecimal realAmount) {
+        this.realAmount = realAmount;
+    }
 
     private List<OutExpenseAccount> sonList;
 

+ 27 - 0
src/main/java/com/goafanti/expenseAccount/bo/SonExpenseAccount.java

@@ -12,8 +12,35 @@ public class SonExpenseAccount {
     private String releaseStart;
     private String releaseEnd;
     private String districtName;
+    private Integer secondaryType;
+    private String secondaryTypeOther;
+    private String attachmentUrl;
     private List<SonExpenseAccountDetails> detList;
 
+    public Integer getSecondaryType() {
+        return secondaryType;
+    }
+
+    public void setSecondaryType(Integer secondaryType) {
+        this.secondaryType = secondaryType;
+    }
+
+    public String getSecondaryTypeOther() {
+        return secondaryTypeOther;
+    }
+
+    public void setSecondaryTypeOther(String secondaryTypeOther) {
+        this.secondaryTypeOther = secondaryTypeOther;
+    }
+
+    public String getAttachmentUrl() {
+        return attachmentUrl;
+    }
+
+    public void setAttachmentUrl(String attachmentUrl) {
+        this.attachmentUrl = attachmentUrl;
+    }
+
     public String getDistrictName() {
         return districtName;
     }

+ 109 - 0
src/main/java/com/goafanti/expenseAccount/bo/SonExpenseAccountDetails.java

@@ -10,7 +10,116 @@ public class SonExpenseAccountDetails {
     private BigDecimal realAmount;
     private String  startDistrict;
     private String  endDistrict;
+    private Integer  vehicle;
+    private String  vehicleOther;
+
+    /**
+     * 付款方式
+     */
+    private Integer payType;
+
+    /**
+     * 发票类型 0普票 1专票
+     */
+    private Integer invoiceType;
+
+    /**
+     * 发票号
+     */
+    private String invoiceNo;
+
+    /**
+     * 付款单位
+     */
+    private String payerName;
+
+    /**
+     * 开户行名称
+     */
+    private String openBank;
+
+    /**
+     * 银行账户
+     */
+    private String bankAccounts;
+
+    /**
+     * 开户行地址
+     */
+    private String openBankAddress;
+
+
+    public Integer getPayType() {
+        return payType;
+    }
+
+    public void setPayType(Integer payType) {
+        this.payType = payType;
+    }
+
+    public Integer getInvoiceType() {
+        return invoiceType;
+    }
+
+    public void setInvoiceType(Integer invoiceType) {
+        this.invoiceType = invoiceType;
+    }
+
+    public String getInvoiceNo() {
+        return invoiceNo;
+    }
+
+    public void setInvoiceNo(String invoiceNo) {
+        this.invoiceNo = invoiceNo;
+    }
+
+    public String getPayerName() {
+        return payerName;
+    }
+
+    public void setPayerName(String payerName) {
+        this.payerName = payerName;
+    }
+
+    public String getOpenBank() {
+        return openBank;
+    }
 
+    public void setOpenBank(String openBank) {
+        this.openBank = openBank;
+    }
+
+    public String getBankAccounts() {
+        return bankAccounts;
+    }
+
+    public void setBankAccounts(String bankAccounts) {
+        this.bankAccounts = bankAccounts;
+    }
+
+    public String getOpenBankAddress() {
+        return openBankAddress;
+    }
+
+    public void setOpenBankAddress(String openBankAddress) {
+        this.openBankAddress = openBankAddress;
+    }
+
+    public Integer getVehicle() {
+        return vehicle;
+    }
+
+    public void setVehicle(Integer vehicle) {
+        this.vehicle = vehicle;
+    }
+
+    public String getVehicleOther() {
+        return vehicleOther;
+    }
+
+    public void setVehicleOther(String vehicleOther) {
+        this.vehicleOther = vehicleOther;
+    }
 
     public BigDecimal getRealAmount() {
         return realAmount;

+ 26 - 1
src/main/java/com/goafanti/expenseAccount/controller/ExpenseAccountController.java

@@ -3,6 +3,7 @@ package com.goafanti.expenseAccount.controller;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.model.ExpenseAccount;
 import com.goafanti.common.utils.ParamUtils;
 import com.goafanti.common.utils.excel.NewExcelUtil;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -16,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.List;
 
 @RestController
@@ -25,6 +28,7 @@ public class ExpenseAccountController extends CertifyApiController {
     @Autowired
     private ExpenseAccountService expenseAccountService;
 
+
     @Value(value = "${upload.path}")
     private final String	uploadPath			= null;
 
@@ -273,7 +277,28 @@ public class ExpenseAccountController extends CertifyApiController {
             res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"合并编号"));
             return  res;
         }
-        return res.data(expenseAccountService.pushMerge(ids));
+        String[] split = ids.split(",");
+        List<String> list = Arrays.asList(split);
+        List<ExpenseAccount> expenseAccounts = expenseAccountService.selectByIds(list);
+
+        for (ExpenseAccount e : expenseAccounts) {
+            if (e.getStatus()!=0){
+                res.getError().add(buildError(String.format("[%s]编号已经发起,不能重复发起。",e.getId())));
+                return res;
+            }else if (e.getTotalAmount().compareTo(new BigDecimal(0))==0){
+                res.getError().add(buildError(String.format("[%s]编号金额为0,请完善修改后发起。",e.getId())));
+                return res;
+            }
+        }
+        //预借支不允许和其他类型发起报销
+        int i = expenseAccountService.selectCountByIdsAndType(list, 5);
+        if (i>0){
+            if (i!=expenseAccounts.size()+1){
+                res.getError().add(buildError("不允许抵扣与其他类型报销合并发起。"));
+                return res;
+            }
+        }
+        return res.data(expenseAccountService.pushMerge(expenseAccounts));
     }
 
     /**

+ 6 - 1
src/main/java/com/goafanti/expenseAccount/service/ExpenseAccountService.java

@@ -1,5 +1,6 @@
 package com.goafanti.expenseAccount.service;
 
+import com.goafanti.common.model.ExpenseAccount;
 import com.goafanti.expenseAccount.bo.*;
 
 import java.util.List;
@@ -40,7 +41,7 @@ public interface ExpenseAccountService {
 
     Object selectByCheckNo(String checkNo);
 
-    Object pushMerge(String ids);
+    Object pushMerge(List<ExpenseAccount> list);
 
     Object mainExpense(Integer id);
 
@@ -49,4 +50,8 @@ public interface ExpenseAccountService {
     Object mainList(ExpenseMainListInput id);
 
     Object detailsList(InputPageListBo in);
+
+    List<ExpenseAccount> selectByIds(List<String> list);
+
+    int selectCountByIdsAndType(List<String> list, Integer i);
 }

+ 18 - 15
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -262,6 +262,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         //计算总金额
         if (in.getTotalAmount()==null){
             in.setTotalAmount(expenseAccountDetailsMapper.selectAmountCountByEAid(in.getId()));
+            in.setRealAmount(in.getTotalAmount());
         }
         in.setProcessStatus(0);
         if (in.getOrderNo()==null){
@@ -337,6 +338,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         if (in.getAgreeTimes()!=null){
             in.setAgreeTime(DateUtils.StringToDate(in.getAgreeTimes(),AFTConstants.YYYYMMDD));
         }
+        in.setRealAmount(in.getAmount());
         return expenseAccountDetailsMapper.insertSelective(in);
     }
 
@@ -689,17 +691,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
     }
 
     @Override
-    public Object pushMerge(String ids) {
-        String[] split = ids.split(",");
-        List<String> list = Arrays.asList(split);
-        List<ExpenseAccount> expenseAccounts = expenseAccountMapper.selectByIds(list);
-        expenseAccounts.stream().forEach(e -> {
-            if (e.getStatus()!=0){
-                throw new BusinessException(String.format("[%s]编号已经发起,不能重复发起。",e.getId()));
-            }else if (e.getTotalAmount().compareTo(new  BigDecimal(0))==0){
-                throw new BusinessException(String.format("[%s]编号金额为0,请完善修改后发起。",e.getId()));
-            }
-        });
+    public Object pushMerge(List<ExpenseAccount> list) {
         //设置付款部门和支付部门
         InputExpenseAccount in =new InputExpenseAccount();
         in.setCheckNo(idGenerator.getNOgenerateId());
@@ -713,13 +705,14 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         Integer eaaid = expenseAccountPrivateMapper.selectByaidDefault(TokenManager.getAdminId());
         in.setEaaid(eaaid);
         AtomicReference<BigDecimal> count = new AtomicReference<>(new BigDecimal(0));
-        expenseAccounts.stream().forEach(e -> {
+        list.stream().forEach(e -> {
             count.set(count.get().add(e.getTotalAmount()));
         });
         in.setTotalAmount(count.get());
+        in.setRealAmount(count.get());
         in.setExpenseMain(1);
         expenseAccountMapper.insertSelective(in);
-        expenseAccounts.stream().forEach(e -> {
+        list.stream().forEach(e -> {
             ExpenseRelationship er=new ExpenseRelationship();
             er.setId(in.getId());
             er.setEaId(e.getId());
@@ -742,6 +735,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             throw new BusinessException("主项目已发起,不可修改!");
         }
         ExpenseAccount update =new ExpenseAccount();
+        if (in.getStatus()==null)in.setStatus(1);
         if (in.getStatus()==1){
             if (in.getOrderNo()!=null)update.setOrderNo(in.getOrderNo());
             if (in.getPayDep()!=null)update.setPayDep(in.getPayDep());
@@ -751,7 +745,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             addExpenseAccountExamine(in.getId(),update);
             update.setProcessStatus(1);
             if (outExpenseAccount.getStatus()==0){
-                outExpenseAccount.setProcessStatus(1);
                 addExpenseAccountLogAndNoticEmail(outExpenseAccount,0,"发起报销审核");
             }else if (outExpenseAccount.getStatus()==3){
                 addExpenseAccountLogAndNoticEmail(outExpenseAccount,4,"修改并发起审核");
@@ -796,6 +789,16 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         return findPage("ExpenseDetailsList","ExpenseDetailsCount",params,in.getPageNo(),in.getPageSize());
     }
 
+    @Override
+    public List<ExpenseAccount> selectByIds(List<String> list) {
+        return expenseAccountMapper.selectByIds(list);
+    }
+
+    @Override
+    public int selectCountByIdsAndType(List<String> list, Integer i) {
+        return expenseAccountMapper.selectCountByIdsAndType(list,i);
+    }
+
 
     /**
      * 计算当前报销显示抵扣金额
@@ -907,7 +910,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         if (in.getPayDep()!=null)param.put("payDep",in.getPayDep());
         if (in.getType()!=null)param.put("type",in.getType());
         if (in.getUsername()!=null)param.put("username",in.getUsername());
-        if (in.getCheckNo()!=null)param.put("checkNo",in.getUsername());
+        if (in.getCheckNo()!=null)param.put("checkNo",in.getCheckNo());
         if (in.getSecondaryType()!=null)param.put("secondaryType",in.getSecondaryType());
         //固定传0查看子列表
         if (in.getExpenseMain()==null)in.setExpenseMain(0);