zouxuan hace 4 años
padre
commit
c3f886711c

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/FinancialExpenditureDao.java

@@ -0,0 +1,12 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpenditure> {
+
+    void batchInsert(@Param("financialExpenditures") List<FinancialExpenditure> financialExpenditures);
+}

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsCategoryDao.java

@@ -18,15 +18,4 @@ public interface GoodsCategoryDao extends BaseDAO<Integer, GoodsCategory> {
      * @return
      */
     List<GoodsCategory> findByParentId(@Param("parentId") Integer parentId, @Param("delFlag") YesOrNoEnum yesOrNoEnum);
-
-    /**
-     * @describe 获取商品分类
-     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
-     * @author zouxuan
-     * @date 2020/9/4
-     * @time 14:05
-     * @param :
-     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.String>>
-     */
-    List<Map<String, Integer>> queryCategotyMap();
 }

+ 162 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/FinancialExpenditure.java

@@ -0,0 +1,162 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 对应数据库表(financial_expenditure):
+ */
+public class FinancialExpenditure {
+
+	private Integer id;
+	/**  */
+	@ApiModelProperty(value = "批次号",required = false)
+	private String batchNo;
+	/**  */
+	@ApiModelProperty(value = "财务流程编号",required = false)
+	private String financialProcessNo;
+	/**  */
+	@ApiModelProperty(value = "钉钉流程编号",required = false)
+	private String dingtalkProcessNo;
+	/**  */
+	@ApiModelProperty(value = "分部",required = false)
+	private Integer organId;
+	/**  */
+	@ApiModelProperty(value = "学校/合作单位",required = false)
+	private Integer cooperationOrganId;
+	/**  */
+	@ApiModelProperty(value = "申请人编号",required = false)
+	private Integer applyUserId;
+	/**  */
+	@ApiModelProperty(value = "费用",required = false)
+	private BigDecimal amount;
+	/**  */
+	@ApiModelProperty(value = "费用明细",required = false)
+	private String itemDetail;
+	/**  */
+	@ApiModelProperty(value = "支付时间",required = false)
+	private Date paymentTime;
+	/**  */
+	@ApiModelProperty(value = "事由",required = false)
+	private String cause;
+	/**  */
+	private Date createTime;
+	/**  */
+	private Date updateTime;
+	/**  */
+	private Integer delFlag;
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
+	public String getFinancialProcessNo() {
+		return financialProcessNo;
+	}
+
+	public void setFinancialProcessNo(String financialProcessNo) {
+		this.financialProcessNo = financialProcessNo;
+	}
+
+	public String getDingtalkProcessNo() {
+		return dingtalkProcessNo;
+	}
+
+	public void setDingtalkProcessNo(String dingtalkProcessNo) {
+		this.dingtalkProcessNo = dingtalkProcessNo;
+	}
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public Integer getCooperationOrganId() {
+		return cooperationOrganId;
+	}
+
+	public void setCooperationOrganId(Integer cooperationOrganId) {
+		this.cooperationOrganId = cooperationOrganId;
+	}
+
+	public Integer getApplyUserId() {
+		return applyUserId;
+	}
+
+	public void setApplyUserId(Integer applyUserId) {
+		this.applyUserId = applyUserId;
+	}
+
+	public BigDecimal getAmount() {
+		return amount;
+	}
+
+	public void setAmount(BigDecimal amount) {
+		this.amount = amount;
+	}
+
+	public String getItemDetail() {
+		return itemDetail;
+	}
+
+	public void setItemDetail(String itemDetail) {
+		this.itemDetail = itemDetail;
+	}
+
+	public Date getPaymentTime() {
+		return paymentTime;
+	}
+
+	public void setPaymentTime(Date paymentTime) {
+		this.paymentTime = paymentTime;
+	}
+
+	public String getCause() {
+		return cause;
+	}
+
+	public void setCause(String cause) {
+		this.cause = cause;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Integer getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(Integer delFlag) {
+		this.delFlag = delFlag;
+	}
+}

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/FinancialExpenditureService.java

@@ -0,0 +1,21 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
+import com.ym.mec.common.service.BaseService;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface FinancialExpenditureService extends BaseService<Long, FinancialExpenditure> {
+    /**
+     * @describe 导入财务支出
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/7
+     * @time 18:31
+     * @param file:
+     * @return java.lang.Object
+     */
+    List<FinancialExpenditure> importFinancialExpenditure(MultipartFile file) throws IOException;
+}

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -70,9 +70,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	public List<Goods> importGoods(MultipartFile file) throws Exception {
 		Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(file.getInputStream(), 2, file.getOriginalFilename());
 		InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
-		Map<String,String> columns = IniFileUtil.readIniFile(inputStream);
+		String fileName = file.getOriginalFilename().split(".")[0];
+		Map<String,String> columns = IniFileUtil.readIniFile(inputStream,fileName);
 		List<Goods> goodsList = new ArrayList<>();
-		Map<String, Integer> map = MapUtil.convertIntegerMap(goodsCategoryDao.queryCategotyMap());
+//		Map<String, Integer> map = MapUtil.convertIntegerMap(goodsCategoryDao.queryCategotyMap());
+		Map<String, Integer> map = getMap("goods_category","name_","id_",true,String.class,Integer.class);
 		for (String e : sheetsListMap.keySet()) {
 			List<Map<String, Object>> sheet = sheetsListMap.get(e);
 			valueIsNull: for (Map<String, Object> row : sheet) {

+ 112 - 0
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -0,0 +1,112 @@
+<?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.ym.mec.biz.dal.dao.FinancialExpenditureDao">
+
+    <resultMap type="com.ym.mec.biz.dal.entity.FinancialExpenditure" id="FinancialExpenditure">
+        <result column="id_" property="id"/>
+        <result column="batch_no_" property="batchNo"/>
+        <result column="financial_process_no_" property="financialProcessNo"/>
+        <result column="dingtalk_process_no_" property="dingtalkProcessNo"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="cooperation_organ_id_" property="cooperationOrganId"/>
+        <result column="apply_user_id_" property="applyUserId"/>
+        <result column="amount_" property="amount"/>
+        <result column="item_detail_" property="itemDetail"/>
+        <result column="payment_time_" property="paymentTime"/>
+        <result column="del_flag_" property="delFlag"/>
+        <result column="cause_" property="cause"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="FinancialExpenditure">
+		SELECT * FROM financial_expenditure WHERE id_ = #{id}
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="FinancialExpenditure">
+		SELECT * FROM financial_expenditure WHERE del_flag_ = 0 ORDER BY id_
+	</select>
+
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
+        organ_id_,cooperation_organ_id_,apply_user_id_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_)
+        VALUES(#{batchNo},#{financialProcessNo},#{dingtalkProcessNo},#{organId},#{cooperationOrganId},#{applyUserId},#{amount},
+        #{itemDetail},#{paymentTime},#{cause},now(),now())
+    </insert>
+    <insert id="batchInsert">
+        INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
+        organ_id_,cooperation_organ_id_,apply_user_id_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_)
+        VALUES
+        <foreach collection="financialExpenditures" item="item" separator=",">
+            (#{item.batchNo},#{item.financialProcessNo},#{item.dingtalkProcessNo},#{item.organId},#{item.cooperationOrganId},#{item.applyUserId},#{item.amount},
+            #{item.itemDetail},#{item.paymentTime},#{item.cause},now(),now())
+        </foreach>
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure">
+        UPDATE charge_type
+        <set>
+            <if test="delFlag != null">
+                del_flag_ = #{delFlag},
+            </if>
+            <if test="batchNo != null">
+                batch_no_ = #{batchNo},
+            </if>
+            <if test="financialProcessNo != null">
+                financial_process_no_ = #{financialProcessNo},
+            </if>
+            <if test="dingtalkProcessNo != null">
+                dingtalk_process_no_ = #{dingtalkProcessNo},
+            </if>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="cooperationOrganId != null">
+                cooperation_organ_id_ = #{cooperationOrganId},
+            </if>
+            <if test="applyUserId != null">
+                apply_user_id_ = #{applyUserId},
+            </if>
+            <if test="amount != null">
+                amount_ = #{amount},
+            </if>
+            <if test="itemDetail != null">
+                item_detail_ = #{itemDetail},
+            </if>
+            <if test="paymentTime != null">
+                payment_time_ = #{paymentTime},
+            </if>
+            <if test="cause != null">
+                cause_ = #{cause},
+            </if>
+            update_time_ = NOW()
+        </set>
+        WHERE id_ = #{id}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		UPDATE charge_type SET del_flag_ = 1 WHERE id_ = #{id}
+	</delete>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="FinancialExpenditure" parameterType="map">
+        SELECT * FROM financial_expenditure
+        WHERE del_flag_ = 0
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM financial_expenditure WHERE del_flag_ = 0
+	</select>
+</mapper>

+ 0 - 3
mec-biz/src/main/resources/config/mybatis/GoodsCategoryMapper.xml

@@ -105,7 +105,4 @@
     <select id="findByParentId" resultMap="GoodsCategory">
         SELECT * FROM goods_category WHERE parent_id_ = #{parentId} AND del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
-    <select id="queryCategotyMap" resultType="java.util.Map">
-        SELECT id_ 'value',name_ 'key' FROM goods_category WHERE del_flag_ = 0
-    </select>
 </mapper>

+ 10 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/service/BaseService.java

@@ -91,5 +91,15 @@ public interface BaseService<PK extends Serializable, T> {
 	 */
 	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, K ids, Class<Y> keyType, Class<Z> valueType);
 
+	/**
+	 * @describe 获取columnKey-columnValue集合
+	 * @author Joburgess
+	 * @date 2020.06.23
+	 * @param columnKey: key所对应的列名
+	 * @param columnValue: value所对应的列名
+	 * @return java.util.List<java.util.Map>
+	 */
+	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType);
+
 
 }

+ 49 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/service/impl/BaseServiceImpl.java

@@ -164,4 +164,53 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 
 		return result;
 	}
+
+
+	@Override
+	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType){
+		StringBuffer sql=new StringBuffer();
+		Map<Y,Z> result=new HashMap();
+		try {
+			SqlSession sqlSession = sqlSessionFactory.openSession();
+			Connection connection = sqlSession.getConnection();
+			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName);
+			if(hasDelFlag){
+				sql.append(" WHERE del_flag_ = 0");
+			}
+			PreparedStatement ps = connection.prepareStatement(sql.toString());
+			ResultSet resultSet = ps.executeQuery();
+			while (resultSet.next()){
+				Y key;
+				Z value;
+				if(keyType.isAssignableFrom(BigDecimal.class)){
+					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
+				}else if(keyType.isAssignableFrom(String.class)){
+					key = (Y) resultSet.getString(1);
+				}else{
+					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
+				}
+				if(valueType.isAssignableFrom(BigDecimal.class)){
+					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
+				}else if(valueType.isAssignableFrom(String.class)){
+					value = (Z) resultSet.getString(2);
+				}else{
+					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
+				}
+				result.put(key, value);
+			}
+			if(resultSet!=null){
+				resultSet.close();
+			}
+			if(ps!=null){
+				ps.close();
+			}
+			if(sqlSession!=null){
+				sqlSession.close();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return result;
+	}
 }

+ 10 - 9
mec-util/src/main/java/com/ym/mec/util/excel/IniFileUtil.java

@@ -60,7 +60,7 @@ public class IniFileUtil {
      * @throws InvalidFileFormatException
      * @throws IOException
      */
-    public static Map<String,String> readIniFile(InputStream inputStream) throws InvalidFileFormatException, IOException {
+    public static Map<String,String> readIniFile(InputStream inputStream,String fileName) throws InvalidFileFormatException, IOException {
         Ini ini = new Ini();
         try {
             ini.load(inputStream);
@@ -70,14 +70,15 @@ public class IniFileUtil {
             inputStream.close();
         }
 
-        Collection<Section> sections = ini.values();
-        for (Section section : sections) {
-            Map<String,String> map = new HashMap<>(section.entrySet().size());
-            for (Entry<String, String> entry : section.entrySet()) {
-                map.put(entry.getKey(),entry.getValue());
-            }
-            return map;
+//        Collection<Section> sections = ini.values();
+        Section section = ini.get(fileName);
+//        for (Section section : sections) {
+        Map<String,String> map = new HashMap<>(section.entrySet().size());
+        for (Entry<String, String> entry : section.entrySet()) {
+            map.put(entry.getKey(),entry.getValue());
         }
-        return new HashMap<>();
+        return map;
+//        }
+//        return new HashMap<>();
     }
 }

+ 29 - 7
mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java

@@ -1,6 +1,8 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.service.FinancialExpenditureService;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -28,23 +30,43 @@ public class ImportController extends BaseController {
 
     @Autowired
     private GoodsService goodsService;
+    @Autowired
+    private FinancialExpenditureService financialExpenditureService;
 
     @ApiOperation(value = "导入商品")
     @PostMapping(value = "goods")
     @PreAuthorize("@pcs.hasPermissions('import/goods')")
-    public HttpResponseResult<List<Goods>> importExamSong(@RequestParam("file") MultipartFile file) throws Exception {
+    public HttpResponseResult<List<Goods>> importGoods(@RequestParam("file") MultipartFile file) throws Exception {
         return succeed(goodsService.importGoods(file));
     }
 
-    @ApiOperation(value = "获取商品导入模板")
-    @GetMapping(value = "getGoodsTemplate")
-    @PreAuthorize("@pcs.hasPermissions('import/getGoodsTemplate')")
-    public void getGoodsTemplate(HttpServletResponse response) throws IOException {
-        InputStream inputStream = new ClassPathResource("excelTemplate/goods.xls").getInputStream();
+    @ApiOperation(value = "导入财务支出")
+    @PostMapping(value = "financialExpenditure")
+    @PreAuthorize("@pcs.hasPermissions('import/financialExpenditure')")
+    public HttpResponseResult<List<FinancialExpenditure>> importFinancialExpenditure(@RequestParam("file") MultipartFile file) throws Exception {
+        return succeed(financialExpenditureService.importFinancialExpenditure(file));
+    }
+
+    @ApiOperation(value = "下载导入模板")
+    @GetMapping(value = "downloadTemplate")
+    @PreAuthorize("@pcs.hasPermissions('import/downloadTemplate')")
+    public void getGoodsTemplate(HttpServletResponse response,String templateType) throws IOException {
+        String templateName = null;
+        switch (templateType){
+            case "goods":
+                templateName = "商品导入模板";
+                break;
+            case "financialExpenditure":
+                templateName = "财务支出导入模板";
+                break;
+            default:
+                templateName = "商品导入模板";
+        }
+        InputStream inputStream = new ClassPathResource("excelTemplate/" + templateName + ".xls").getInputStream();
         OutputStream outputStream = response.getOutputStream();
         try {
             response.setContentType("application/octet-stream");
-            response.setHeader("Content-Disposition", "attachment;filename=goods-" + DateUtil.getDate(new Date()) + ".xls");
+            response.setHeader("Content-Disposition", "attachment;filename=" + templateName + "-" + DateUtil.getDate(new Date()) + ".xls");
             response.flushBuffer();
             outputStream = response.getOutputStream();
             IOUtils.copy(inputStream, outputStream);

BIN
mec-web/src/main/resources/excelTemplate/财务支出导入模板.xls