Просмотр исходного кода

新增报销
报销选择订单待开发

anderx лет назад: 2
Родитель
Сommit
5ddc56544c

+ 21 - 0
src/main/java/com/goafanti/common/dao/ExpenseAccountDetailsMapper.java

@@ -0,0 +1,21 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.ExpenseAccountDetails;
+
+import java.math.BigDecimal;
+
+public interface ExpenseAccountDetailsMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(ExpenseAccountDetails record);
+
+    int insertSelective(ExpenseAccountDetails record);
+
+    ExpenseAccountDetails selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(ExpenseAccountDetails record);
+
+    int updateByPrimaryKey(ExpenseAccountDetails record);
+
+    BigDecimal selectAmountCountByEAid(Integer id);
+}

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

@@ -1,6 +1,7 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.ExpenseAccount;
+import com.goafanti.expenseAccount.bo.OutExpenseAccount;
 
 public interface ExpenseAccountMapper {
     int deleteByPrimaryKey(Integer id);
@@ -14,4 +15,6 @@ public interface ExpenseAccountMapper {
     int updateByPrimaryKeySelective(ExpenseAccount record);
 
     int updateByPrimaryKey(ExpenseAccount record);
-}
+
+    OutExpenseAccount selectByid(Integer id);
+}

+ 127 - 0
src/main/java/com/goafanti/common/mapper/ExpenseAccountDetailsMapper.xml

@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.ExpenseAccountDetailsMapper">
+  <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="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="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, eaid, start_time, end_time, amount, vehicle, vehicle_other, create_time
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from expense_account_details
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+
+    <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>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountDetails" useGeneratedKeys="true">
+    insert into expense_account_details
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="eaid != null">
+        eaid,
+      </if>
+      <if test="startTime != null">
+        start_time,
+      </if>
+      <if test="endTime != null">
+        end_time,
+      </if>
+      <if test="amount != null">
+        amount,
+      </if>
+      <if test="vehicle != null">
+        vehicle,
+      </if>
+      <if test="vehicleOther != null">
+        vehicle_other,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="eaid != null">
+        #{eaid,jdbcType=INTEGER},
+      </if>
+      <if test="startTime != null">
+        #{startTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="endTime != null">
+        #{endTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="amount != null">
+        #{amount,jdbcType=DECIMAL},
+      </if>
+      <if test="vehicle != null">
+        #{vehicle,jdbcType=INTEGER},
+      </if>
+      <if test="vehicleOther != null">
+        #{vehicleOther,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccountDetails">
+    update expense_account_details
+    <set>
+      <if test="eaid != null">
+        eaid = #{eaid,jdbcType=INTEGER},
+      </if>
+      <if test="startTime != null">
+        start_time = #{startTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="endTime != null">
+        end_time = #{endTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="amount != null">
+        amount = #{amount,jdbcType=DECIMAL},
+      </if>
+      <if test="vehicle != null">
+        vehicle = #{vehicle,jdbcType=INTEGER},
+      </if>
+      <if test="vehicleOther != null">
+        vehicle_other = #{vehicleOther,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccountDetails">
+    update expense_account_details
+    set eaid = #{eaid,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},
+      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}
+  </select>
+</mapper>

+ 26 - 16
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -24,34 +24,35 @@
     <result column="duration" jdbcType="DOUBLE" property="duration" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount, 
-    attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names, 
+    id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
+    attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
     release_start, release_end, duration
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
-    select 
+    select
     <include refid="Base_Column_List" />
     from expense_account
     where id = #{id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from expense_account
     where id = #{id,jdbcType=INTEGER}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
-    insert into expense_account (prid, order_no, aid, 
-      aname, `type`, type_other, 
-      `status`, process_status, total_amount, 
-      attachment_url, apply_dep, pay_dep, 
-      eaaid, create_time, district_name, 
-      user_names, release_start, release_end, 
+    insert into expense_account (prid, order_no, aid,
+      aname, `type`, type_other,
+      `status`, process_status, total_amount,
+      attachment_url, apply_dep, pay_dep,
+      eaaid, create_time, district_name,
+      user_names, release_start, release_end,
       duration)
-    values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, 
-      #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR}, 
-      #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL}, 
-      #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR}, 
-      #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR}, 
-      #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP}, 
+    values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
+      #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
+      #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
+      #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
+      #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
+      #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
       #{duration,jdbcType=DOUBLE})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
@@ -261,4 +262,13 @@
       duration = #{duration,jdbcType=DOUBLE}
     where id = #{id,jdbcType=INTEGER}
   </update>
-</mapper>
+
+  <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
+    SELECT a.id, a.prid, a.order_no orderNo, a.aid, a.aname, a.`type`, a.type_other typeOther , a.status, a.process_status processStatus,
+           a.total_amount totalAmount, a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,
+           a.district_name districtName, a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,
+           b.name appDepName,c.name payDepName
+    FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
+    WHERE a.id= #{id}
+  </select>
+</mapper>

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

@@ -0,0 +1,114 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * expense_account_details
+ * @author 
+ */
+public class ExpenseAccountDetails implements Serializable {
+    private Integer id;
+
+    /**
+     * 报销编号
+     */
+    private Integer eaid;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 金额
+     */
+    private BigDecimal amount;
+
+    /**
+     * 交通工具 0=其他,1=飞机,2=火车或高铁,3=地铁,4=公交车
+     */
+    private Integer vehicle;
+
+    /**
+     * 其他交通工具说明
+     */
+    private String vehicleOther;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getEaid() {
+        return eaid;
+    }
+
+    public void setEaid(Integer eaid) {
+        this.eaid = eaid;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    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 Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 1 - 1
src/main/java/com/goafanti/common/utils/DateUtils.java

@@ -463,7 +463,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 		try {
 			 date2=new SimpleDateFormat(format).parse(date);
 		} catch (ParseException e) {
-			throw new BusinessException("转换失败",e);
+			throw new BusinessException("时间转换失败",e);
 		}
 		return date2;
 	}

+ 19 - 0
src/main/java/com/goafanti/expenseAccount/bo/InputExpenseAccount.java

@@ -12,6 +12,25 @@ public class InputExpenseAccount extends ExpenseAccount {
     @Param(name = "类型")
     private Integer type;
 
+    private String startTimeStr;
+    private String endTimeStr;
+
+    public String getStartTimeStr() {
+        return startTimeStr;
+    }
+
+    public void setStartTimeStr(String startTimeStr) {
+        this.startTimeStr = startTimeStr;
+    }
+
+    public String getEndTimeStr() {
+        return endTimeStr;
+    }
+
+    public void setEndTimeStr(String endTimeStr) {
+        this.endTimeStr = endTimeStr;
+    }
+
     @Override
     public Integer getType() {
         return type;

+ 56 - 0
src/main/java/com/goafanti/expenseAccount/bo/OutExpenseAccount.java

@@ -0,0 +1,56 @@
+package com.goafanti.expenseAccount.bo;
+
+import com.goafanti.common.model.ExpenseAccount;
+import com.goafanti.common.utils.Param;
+
+import javax.validation.constraints.NotNull;
+
+
+public class OutExpenseAccount extends ExpenseAccount {
+
+    private String createTimeStr;
+    private String releaseStartStr;
+    private String releaseEndStr;
+    private String appDepName;
+    private String payDepName;
+
+    public String getCreateTimeStr() {
+        return createTimeStr;
+    }
+
+    public void setCreateTimeStr(String createTimeStr) {
+        this.createTimeStr = createTimeStr;
+    }
+
+    public String getReleaseStartStr() {
+        return releaseStartStr;
+    }
+
+    public void setReleaseStartStr(String releaseStartStr) {
+        this.releaseStartStr = releaseStartStr;
+    }
+
+    public String getReleaseEndStr() {
+        return releaseEndStr;
+    }
+
+    public void setReleaseEndStr(String releaseEndStr) {
+        this.releaseEndStr = releaseEndStr;
+    }
+
+    public String getAppDepName() {
+        return appDepName;
+    }
+
+    public void setAppDepName(String appDepName) {
+        this.appDepName = appDepName;
+    }
+
+    public String getPayDepName() {
+        return payDepName;
+    }
+
+    public void setPayDepName(String payDepName) {
+        this.payDepName = payDepName;
+    }
+}

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

@@ -44,6 +44,21 @@ public class ExpenseAccountController extends CertifyApiController {
     }
 
 
+    /**
+     * 新增私有报销帐号
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/update",method = RequestMethod.POST)
+    public Result update( InputExpenseAccount in ){
+        Result res =new Result();
+        in.setAid(TokenManager.getAdminId());
+
+        res.setData(expenseAccountService.update(in));
+        return res;
+    }
+
+
 
 
 }

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

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

+ 58 - 3
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -1,14 +1,69 @@
 package com.goafanti.expenseAccount.service.impl;
 
+import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.dao.ExpenseAccountDetailsMapper;
+import com.goafanti.common.dao.ExpenseAccountMapper;
+import com.goafanti.common.dao.PublicReleaseMapper;
+import com.goafanti.common.error.BusinessException;
+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.OutExpenseAccount;
 import com.goafanti.expenseAccount.service.ExpenseAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+
 @Service
 public class ExpenseAccountServiceImpl implements ExpenseAccountService {
+    @Autowired
+    private  AdminMapper adminMapper;
+    @Autowired
+    private ExpenseAccountMapper expenseAccountMapper;
+    @Autowired
+    private PublicReleaseMapper publicReleaseMapper;
+    @Autowired
+    private ExpenseAccountDetailsMapper expenseAccountDetailsMapper;
+
+
+    @Override
+    public OutExpenseAccount add(InputExpenseAccount in) {
+        if (in.getAid()!=null){
+            Admin admin = adminMapper.selectByPrimaryKey(in.getAid());
+            in.setAname(admin.getName());
+            in.setApplyDep(admin.getDepartmentId());
+            in.setPayDep(admin.getDepartmentId());
+        }
+        if (in.getPrid()!=null){
+            PublicRelease pr = publicReleaseMapper.selectByPrimaryKey(in.getPrid());
+            in.setReleaseStart(pr.getReleaseStart());
+            in.setReleaseEnd(pr.getReleaseEnd());
+            in.setDistrictName(pr.getDistrictName());
+            in.setUserNames(pr.getUserNames());
+        }
+        expenseAccountMapper.insertSelective(in);
+        OutExpenseAccount outExpenseAccount = expenseAccountMapper.selectByid(in.getId());
+        return outExpenseAccount;
+    }
+
     @Override
-    public int add(InputExpenseAccount in) {
-        
-        return 0;
+    public int update(InputExpenseAccount in) {
+        OutExpenseAccount useEA = expenseAccountMapper.selectByid(in.getId());
+        if (useEA.getStatus()!=0&&useEA.getStatus()!=3){
+            throw new BusinessException("不能操作审核中与完成的订单");
+        }
+        if (in.getStartTimeStr()!=null&&in.getEndTimeStr()!=null){
+            in.setReleaseStart(DateUtils.StringToDate(in.getStartTimeStr(), AFTConstants.YYYYMMDDHHMMSS));
+            in.setReleaseEnd(DateUtils.StringToDate(in.getEndTimeStr(), AFTConstants.YYYYMMDDHHMMSS));
+        }
+        in.setStatus(1);
+        //计算总金额
+        BigDecimal bigDecimal = expenseAccountDetailsMapper.selectAmountCountByEAid(in.getId());
+
+
+        return expenseAccountMapper.updateByPrimaryKeySelective(in);
     }
 }