Browse Source

报销开发

anderx 2 years ago
parent
commit
eb8b6771ee

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

@@ -41,4 +41,8 @@ public interface ExpenseAccountMapper {
 
 
     List<FinanceCount> selectCountByFinance(String id);
+
+    List<ExpenseAccount> selectByIds(List<String> split);
+
+    void updateByIds(@Param("list") List<String> list, @Param("status") Integer status);
 }

+ 17 - 0
src/main/java/com/goafanti/common/dao/ExpenseRelationshipMapper.java

@@ -0,0 +1,17 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.ExpenseRelationship;
+
+public interface ExpenseRelationshipMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(ExpenseRelationship record);
+
+    int insertSelective(ExpenseRelationship record);
+
+    ExpenseRelationship selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(ExpenseRelationship record);
+
+    int updateByPrimaryKey(ExpenseRelationship record);
+}

+ 19 - 0
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -344,6 +344,7 @@
     where id = #{id,jdbcType=INTEGER}
   </update>
 
+
   <sql id="selectDtailsSql">
     a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
         a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
@@ -623,5 +624,23 @@
             where a.status in (1, 2) and a.process_status >0 and c.finance_id = #{aid})x
       group by x.aid, x.dates;
     </select>
+  <select id="selectByIds" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from expense_account
+    where id in
+    <foreach collection="list" open="(" close=")" separator="," item="id">
+      #{id}
+    </foreach>
+  </select>
+
+  <update id="updateByIds" >
+    update expense_account
+    set status= #{status}
+    where id in
+    <foreach collection="list" open="(" close=")" separator="," item="id">
+      #{id}
+    </foreach>
+  </update>
 
 </mapper>

+ 63 - 0
src/main/java/com/goafanti/common/mapper/ExpenseRelationshipMapper.xml

@@ -0,0 +1,63 @@
+<?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.ExpenseRelationshipMapper">
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseRelationship">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="ea_id" jdbcType="INTEGER" property="eaId" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, ea_id, create_time
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from expense_relationship
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from expense_relationship
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseRelationship" useGeneratedKeys="true">
+    insert into expense_relationship (ea_id, create_time)
+    values (#{eaId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseRelationship" useGeneratedKeys="true">
+    insert into expense_relationship
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="eaId != null">
+        ea_id,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="eaId != null">
+        #{eaId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseRelationship">
+    update expense_relationship
+    <set>
+      <if test="eaId != null">
+        ea_id = #{eaId,jdbcType=INTEGER},
+      </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.ExpenseRelationship">
+    update expense_relationship
+    set ea_id = #{eaId,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 51 - 0
src/main/java/com/goafanti/common/model/ExpenseRelationship.java

@@ -0,0 +1,51 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * expense_relationship
+ * @author 
+ */
+public class ExpenseRelationship implements Serializable {
+    /**
+     * 主编号
+     */
+    private Integer id;
+
+    /**
+     * 子管理员编号
+     */
+    private Integer eaId;
+
+    /**
+     * 创建时间
+     */
+    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 getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

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

@@ -71,12 +71,13 @@ public class ExpenseAccountController extends CertifyApiController {
                     return res;
                 }
                 //不是第三方付款和抵扣的时候必须选择报销帐号
-            }else if (in.getType()!=3&&in.getType()!=5){
-                if (in.getEaaid()==null){
-                    res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"报销帐号"));
-                    return res;
-                }
             }
+//            else if (in.getType()!=3&&in.getType()!=5){
+//                if (in.getEaaid()==null){
+//                    res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"报销帐号"));
+//                    return res;
+//                }
+//            }
             res.setData(expenseAccountService.update(in));
         }
         return res;
@@ -250,6 +251,14 @@ public class ExpenseAccountController extends CertifyApiController {
         return newExcelUtil.exportExcel(list,"报销统计",uploadPath);
     }
 
-
+    @RequestMapping(value = "/merge",method = RequestMethod.GET)
+    public Result merge(String ids){
+        Result res =new Result();
+        if (ids==null){
+            res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"合并编号"));
+            return  res;
+        }
+        return res.data(expenseAccountService.merge(ids));
+    }
 
 }

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

@@ -39,4 +39,6 @@ public interface ExpenseAccountService {
     Object pushSupplementCheckNo();
 
     Object selectByCheckNo(String checkNo);
+
+    Object merge(String ids);
 }

+ 39 - 11
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -53,6 +53,8 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
     private JDBCIdGenerator idGenerator;
     @Autowired
     private FinanceCountMapper financeCountMapper;
+    @Autowired
+    private ExpenseRelationshipMapper expenseRelationshipMapper;
 
 
 
@@ -60,14 +62,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
 
     @Override
     public Integer add(InputExpenseAccount in) {
-        //设置付款部门和支付部门
-        in.setCheckNo(idGenerator.getNOgenerateId());
-        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());
@@ -77,8 +72,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             in.setUserNames(pr.getUserNames());
             in.setDuration(pr.getDuration());
         }
-        Integer eaaid = expenseAccountPrivateMapper.selectByaidDefault(in.getAid());
-        in.setEaaid(eaaid);
+
         //判断报销类型,0=固定费用,1=报销到订单
         if (in.getOrderNo()==null){
             in.setTargetType(0);
@@ -86,7 +80,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             in.setTargetType(1);
         }
         expenseAccountMapper.insertSelective(in);
-        addExpenseAccountExamine(in.getId());
+
         return in.getId();
     }
 
@@ -688,6 +682,40 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         return useEa;
     }
 
+    @Override
+    public Object merge(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()));
+            }
+        });
+        InputExpenseAccount in =new InputExpenseAccount();
+        //设置付款部门和支付部门
+        in.setCheckNo(idGenerator.getNOgenerateId());
+        if (in.getAid()!=null){
+            Admin admin = adminMapper.selectByPrimaryKey(in.getAid());
+            in.setAname(admin.getName());
+            in.setApplyDep(admin.getDepartmentId());
+            in.setPayDep(admin.getDepartmentId());
+        }
+        Integer eaaid = expenseAccountPrivateMapper.selectByaidDefault(in.getAid());
+        in.setEaaid(eaaid);
+        expenseAccountMapper.insertSelective(in);
+        expenseAccounts.stream().forEach(e -> {
+            ExpenseRelationship er=new ExpenseRelationship();
+            er.setId(in.getId());
+            er.setEaId(e.getId());
+            expenseRelationshipMapper.insert(er);
+        });
+        expenseAccountMapper.updateByIds(list,1);
+        addExpenseAccountExamine(in.getId());
+
+        return null;
+    }
+
     /**
      * 计算当前报销显示抵扣金额
      * @param useEa

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20221026?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-#jdbc.username=root
-#jdbc.password=123456
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
-jdbc.password=aftdev
+jdbc.password=123456
+#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.username=root
+#jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20