Browse Source

新增、删除报销详情

anderx 2 years ago
parent
commit
14fa2b3091

+ 35 - 9
src/main/java/com/goafanti/common/mapper/ExpenseAccountDetailsMapper.xml

@@ -4,15 +4,18 @@
   <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccountDetails">
     <id column="id" jdbcType="INTEGER" property="id" />
     <result column="eaid" jdbcType="INTEGER" property="eaid" />
+    <result column="type" jdbcType="INTEGER" property="type" />
     <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
     <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
     <result column="amount" jdbcType="DECIMAL" property="amount" />
     <result column="vehicle" jdbcType="INTEGER" property="vehicle" />
     <result column="vehicle_other" jdbcType="VARCHAR" property="vehicleOther" />
+    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, eaid, start_time, end_time, amount, vehicle, vehicle_other, create_time
+    id, eaid, `type`, start_time, end_time, amount, vehicle, vehicle_other, remarks,
+    create_time
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -20,18 +23,19 @@
     from expense_account_details
     where id = #{id,jdbcType=INTEGER}
   </select>
-
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from expense_account_details
     where id = #{id,jdbcType=INTEGER}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountDetails" useGeneratedKeys="true">
-    insert into expense_account_details (eaid, start_time, end_time,
-      amount, vehicle, vehicle_other,
-      create_time)
-    values (#{eaid,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
-      #{amount,jdbcType=DECIMAL}, #{vehicle,jdbcType=INTEGER}, #{vehicleOther,jdbcType=VARCHAR},
-      #{createTime,jdbcType=TIMESTAMP})
+    insert into expense_account_details (eaid, `type`, start_time,
+      end_time, amount, vehicle,
+      vehicle_other, remarks, create_time
+      )
+    values (#{eaid,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP},
+      #{endTime,jdbcType=TIMESTAMP}, #{amount,jdbcType=DECIMAL}, #{vehicle,jdbcType=INTEGER},
+      #{vehicleOther,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
+      )
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountDetails" useGeneratedKeys="true">
     insert into expense_account_details
@@ -39,6 +43,9 @@
       <if test="eaid != null">
         eaid,
       </if>
+      <if test="type != null">
+        `type`,
+      </if>
       <if test="startTime != null">
         start_time,
       </if>
@@ -54,6 +61,9 @@
       <if test="vehicleOther != null">
         vehicle_other,
       </if>
+      <if test="remarks != null">
+        remarks,
+      </if>
       <if test="createTime != null">
         create_time,
       </if>
@@ -62,6 +72,9 @@
       <if test="eaid != null">
         #{eaid,jdbcType=INTEGER},
       </if>
+      <if test="type != null">
+        #{type,jdbcType=INTEGER},
+      </if>
       <if test="startTime != null">
         #{startTime,jdbcType=TIMESTAMP},
       </if>
@@ -77,6 +90,9 @@
       <if test="vehicleOther != null">
         #{vehicleOther,jdbcType=VARCHAR},
       </if>
+      <if test="remarks != null">
+        #{remarks,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -88,6 +104,9 @@
       <if test="eaid != null">
         eaid = #{eaid,jdbcType=INTEGER},
       </if>
+      <if test="type != null">
+        `type` = #{type,jdbcType=INTEGER},
+      </if>
       <if test="startTime != null">
         start_time = #{startTime,jdbcType=TIMESTAMP},
       </if>
@@ -103,6 +122,9 @@
       <if test="vehicleOther != null">
         vehicle_other = #{vehicleOther,jdbcType=VARCHAR},
       </if>
+      <if test="remarks != null">
+        remarks = #{remarks,jdbcType=VARCHAR},
+      </if>
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
@@ -112,14 +134,18 @@
   <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccountDetails">
     update expense_account_details
     set eaid = #{eaid,jdbcType=INTEGER},
+      `type` = #{type,jdbcType=INTEGER},
       start_time = #{startTime,jdbcType=TIMESTAMP},
       end_time = #{endTime,jdbcType=TIMESTAMP},
       amount = #{amount,jdbcType=DECIMAL},
       vehicle = #{vehicle,jdbcType=INTEGER},
       vehicle_other = #{vehicleOther,jdbcType=VARCHAR},
+      remarks = #{remarks,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=INTEGER}
   </update>
+
+
   <select id="selectAmountCountByEAid" resultType="java.math.BigDecimal">
     select ifnull(sum(amount),0)amount  from expense_account_details
     where eaid = #{id}

+ 26 - 0
src/main/java/com/goafanti/common/model/ExpenseAccountDetails.java

@@ -17,6 +17,11 @@ public class ExpenseAccountDetails implements Serializable {
     private Integer eaid;
 
     /**
+     * 分类 0=其他,1=交通费,2=住宿费,3=市内车费,4=餐费,5=出差补贴,6=预借支
+     */
+    private Integer type;
+
+    /**
      * 开始时间
      */
     private Date startTime;
@@ -42,6 +47,11 @@ public class ExpenseAccountDetails implements Serializable {
     private String vehicleOther;
 
     /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
      * 创建时间
      */
     private Date createTime;
@@ -64,6 +74,14 @@ public class ExpenseAccountDetails implements Serializable {
         this.eaid = eaid;
     }
 
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
     public Date getStartTime() {
         return startTime;
     }
@@ -104,6 +122,14 @@ public class ExpenseAccountDetails implements Serializable {
         this.vehicleOther = vehicleOther;
     }
 
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }

+ 23 - 0
src/main/java/com/goafanti/expenseAccount/bo/InputExpenseAccountDetails.java

@@ -0,0 +1,23 @@
+package com.goafanti.expenseAccount.bo;
+
+import com.goafanti.common.model.ExpenseAccountDetails;
+import com.goafanti.common.utils.Param;
+
+import javax.validation.constraints.NotNull;
+
+public class InputExpenseAccountDetails  extends ExpenseAccountDetails {
+
+    @NotNull
+    @Param(name = "报销编号")
+    private Integer eaid;
+
+    @Override
+    public Integer getEaid() {
+        return eaid;
+    }
+
+    @Override
+    public void setEaid(Integer eaid) {
+        this.eaid = eaid;
+    }
+}

+ 28 - 0
src/main/java/com/goafanti/expenseAccount/controller/ExpenseAccountController.java

@@ -7,6 +7,7 @@ import com.goafanti.common.model.ExpenseAccountPrivate;
 import com.goafanti.common.utils.ParamUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.expenseAccount.bo.InputExpenseAccount;
+import com.goafanti.expenseAccount.bo.InputExpenseAccountDetails;
 import com.goafanti.expenseAccount.bo.InputExpenseAccountPrivate;
 import com.goafanti.expenseAccount.service.ExpenseAccountPrivateService;
 import com.goafanti.expenseAccount.service.ExpenseAccountService;
@@ -58,7 +59,34 @@ public class ExpenseAccountController extends CertifyApiController {
         return res;
     }
 
+    /**
+     * 新增报销详情
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/details/add",method = RequestMethod.POST)
+    public Result addDetails(@Validated InputExpenseAccountDetails in , BindingResult bindingResult){
+        Result res =new Result();
+        if (bindingResult.hasErrors()) {
+            String param=bindingResult.getFieldError().getField();
+            res.getError().add(buildError(ParamUtils.getParamMsg(in,param),ParamUtils.getParamName(in,param)));
+            return res;
+        }
+        res.setData(expenseAccountService.addDetails(in));
+        return res;
+    }
 
+    /**
+     * 删除报销详情
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "/details/delete",method = RequestMethod.GET)
+    public Result deleteDetails(Integer id){
+        Result res =new Result();
+        res.setData(expenseAccountService.deleteDetails(id));
+        return res;
+    }
 
 
 }

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

@@ -1,10 +1,16 @@
 package com.goafanti.expenseAccount.service;
 
 import com.goafanti.expenseAccount.bo.InputExpenseAccount;
+import com.goafanti.expenseAccount.bo.InputExpenseAccountDetails;
 import com.goafanti.expenseAccount.bo.OutExpenseAccount;
 
 public interface ExpenseAccountService {
+
     OutExpenseAccount add(InputExpenseAccount in);
 
     int update(InputExpenseAccount in);
+
+    int addDetails(InputExpenseAccountDetails in);
+
+    int deleteDetails(Integer id);
 }

+ 12 - 2
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -10,6 +10,7 @@ import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.PublicRelease;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.expenseAccount.bo.InputExpenseAccount;
+import com.goafanti.expenseAccount.bo.InputExpenseAccountDetails;
 import com.goafanti.expenseAccount.bo.OutExpenseAccount;
 import com.goafanti.expenseAccount.service.ExpenseAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,9 +62,18 @@ public class ExpenseAccountServiceImpl implements ExpenseAccountService {
         }
         in.setStatus(1);
         //计算总金额
-        BigDecimal bigDecimal = expenseAccountDetailsMapper.selectAmountCountByEAid(in.getId());
+        in.setTotalAmount(expenseAccountDetailsMapper.selectAmountCountByEAid(in.getId()));
+        return expenseAccountMapper.updateByPrimaryKeySelective(in);
+    }
 
+    @Override
+    public int addDetails(InputExpenseAccountDetails in) {
 
-        return expenseAccountMapper.updateByPrimaryKeySelective(in);
+        return expenseAccountDetailsMapper.insertSelective(in);
+    }
+
+    @Override
+    public int deleteDetails(Integer id) {
+        return expenseAccountDetailsMapper.deleteByPrimaryKey(id);
     }
 }