Browse Source

财务管理导入

zouxuan 5 years ago
parent
commit
0fabf70849

+ 0 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -353,11 +353,4 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @return
      */
     List<StudentPaymentOrder> getUserOrderByType(@Param("userId") Integer userId, @Param("type") OrderTypeEnum type, @Param("status") DealStatusEnum status);
-
-    /**
-     * 批量新增
-     * @author zouxuan
-     * @param studentPaymentRouteOrders
-     */
-    int batchInsert(@Param("studentPaymentRouteOrders") List<StudentPaymentRouteOrder> studentPaymentRouteOrders);
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentRouteOrderDao.java

@@ -70,5 +70,5 @@ public interface StudentPaymentRouteOrderDao extends BaseDAO<Long, StudentPaymen
      * @param transNos
      * @return
      */
-    List<String> countByTransNo(List<Object> transNos);
+    List<String> countByTransNo(@Param("transNos") List<Object> transNos);
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java

@@ -4,7 +4,7 @@ import com.ym.mec.common.enums.BaseEnum;
 
 public enum TemplateTypeEnum implements BaseEnum<String, TemplateTypeEnum> {
     GOODS("GOODS","商品导入模板"),
-    ROUTE_ORDER("ROUTE_ORDER","财务订单管理导入模板"),
+    ROUTE_ORDER("ROUTE_ORDER","财务管理导入模板"),
     FINANCIAL_EXPENDITURE("FINANCIAL_EXPENDITURE","财务支出导入模板");
 
     private String code;

+ 34 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -384,49 +384,48 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 					}
 					objectMap.put(columnValue, row.get(s));
 				}
-				StudentPaymentRouteOrder studentPaymentRouteOrder = null;
-				try {
-					studentPaymentRouteOrder = JSONObject.parseObject(objectMap.toJSONString(),StudentPaymentRouteOrder.class);
-					//是否有销售金额
-					if(studentPaymentRouteOrder.getSaleAmount() != null && studentPaymentRouteOrder.getSaleAmount().longValue() != 0l){
-						String goodsIds = studentPaymentRouteOrder.getGoodsIds();
-						String goodsNums = studentPaymentRouteOrder.getGoodsNums();
-						if(StringUtils.isAllEmpty(goodsIds,goodsNums)){
-							throw new BizException("导入失败:有销售金额时商品编号和数量必填");
-						}
-						List<String> goodsIdList = new ArrayList(Arrays.asList(goodsIds.split(",")));
-						List<String> goodsNumList = new ArrayList(Arrays.asList(goodsNums.split(",")));
-						if(goodsIdList.size() != goodsNumList.size()){
-							throw new BizException("导入失败:商品编号和商品数量不一致");
+				StudentPaymentRouteOrder studentPaymentRouteOrder = JSONObject.parseObject(objectMap.toJSONString(),StudentPaymentRouteOrder.class);
+				//是否有销售金额
+				if(studentPaymentRouteOrder.getSaleAmount() != null && studentPaymentRouteOrder.getSaleAmount().longValue() != 0l){
+					String goodsIds = studentPaymentRouteOrder.getGoodsIds();
+					String goodsNums = studentPaymentRouteOrder.getGoodsNums();
+
+					if(StringUtils.isEmpty(goodsNums)){
+						throw new BizException("导入失败:有销售金额时商品数量必填");
+					}
+					if(StringUtils.isEmpty(goodsIds)){
+						throw new BizException("导入失败:有销售金额时商品编号必填");
+					}
+					List<String> goodsIdList = new ArrayList(Arrays.asList(goodsIds.split(",")));
+					List<String> goodsNumList = new ArrayList(Arrays.asList(goodsNums.split(",")));
+					if(goodsIdList.size() != goodsNumList.size()){
+						throw new BizException("导入失败:商品编号和商品数量不一致");
+					}
+					JSONArray goodsJSON = new JSONArray();
+					for (int i = 0; i < goodsIdList.size(); i++) {
+						if(!goodsDao.findByIdAndStatus(goodsIdList.get(i), 1)){
+							throw new BizException("导入失败:商品编号{}不存在",goodsIdList.get(i));
 						}
-						JSONArray goodsJSON = new JSONArray();
-						for (int i = 0; i < goodsIdList.size(); i++) {
-							if(!goodsDao.findByIdAndStatus(goodsIdList.get(i), 1)){
-								throw new BizException("导入失败:商品编号{}不存在",goodsIdList.get(i));
-							}
-							try {
-								int goodsNum = Integer.parseInt(goodsNumList.get(i));
-								JSONObject jsonObject = new JSONObject();
-								jsonObject.put(goodsIdList.get(i),goodsNum);
-								goodsJSON.add(jsonObject);
-							}catch (Exception e1){
-								throw new BizException("导入失败:商品数量{}填写错误",goodsNumList.get(i));
-							}
+						try {
+							int goodsNum = Integer.parseInt(goodsNumList.get(i));
+							JSONObject jsonObject = new JSONObject();
+							jsonObject.put(goodsIdList.get(i),goodsNum);
+							goodsJSON.add(jsonObject);
+						}catch (Exception e1){
+							throw new BizException("导入失败:商品数量{}填写错误",goodsNumList.get(i));
 						}
-						studentPaymentRouteOrder.setGoodsJson(goodsJSON.toJSONString());
 					}
-					studentPaymentRouteOrders.add(studentPaymentRouteOrder);
-				} catch (Exception ex) {
-					throw new BizException("导入数据出错,请检查Excel表格");
+					studentPaymentRouteOrder.setGoodsJson(goodsJSON.toJSONString());
 				}
+				studentPaymentRouteOrders.add(studentPaymentRouteOrder);
 			}
 		}
-		if(studentPaymentRouteOrders.size() != 0){
-			Map<String, List<StudentPaymentRouteOrder>> stringListMap = studentPaymentRouteOrders.stream().collect(Collectors.groupingBy(StudentPaymentRouteOrder::getOrderNo));
-			if(sheetsListMap.size() != studentPaymentRouteOrders.size()){
+		if(studentPaymentRouteOrders.size() > 0){
+			Map<String, List<StudentPaymentRouteOrder>> stringListMap = studentPaymentRouteOrders.stream().collect(Collectors.groupingBy(StudentPaymentRouteOrder::getTransNo));
+			if(stringListMap.size() != studentPaymentRouteOrders.size()){
 				throw new BizException("导入失败:请勿录入重复的交易流水号");
 			}
-			studentPaymentOrderDao.batchInsert(studentPaymentRouteOrders);
+			studentPaymentRouteOrderDao.batchAdd(studentPaymentRouteOrders);
 		}
 		return studentPaymentRouteOrders;
 	}

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -388,6 +388,6 @@
         </if>
     </select>
     <select id="findByIdAndStatus" resultType="java.lang.Boolean">
-        SELECT COUNT(0) FROM goods WHERE `status` = #{status} AND id_ = #{goodsId}
+        SELECT COUNT(0) FROM goods WHERE status_ = #{status} AND id_ = #{goodsId}
     </select>
 </mapper>

+ 0 - 22
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -101,28 +101,6 @@
                 #{classGroupId}, #{payTime})
     </insert>
 
-    <!-- 向数据库增加一条记录 -->
-    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
-            keyColumn="id" keyProperty="id">
-        INSERT INTO student_payment_order
-        (group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
-         per_amount_,
-         balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
-         status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
-         payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_)
-         VALUES
-         <foreach collection="studentPaymentRouteOrders" separator="," item="item">
-             (#{item.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-             #{item.userId}, #{item.organId}, #{item.routingOrganId},
-             #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-             #{item.expectAmount}, #{item.actualAmount}, #{item.comAmount}, #{item.perAmount}, #{item.balancePaymentAmount},
-             #{item.remitFee}, #{item.courseRemitFee}, #{item.transNo},
-             #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{item.memo}, now(), now(),
-             #{item.paymentChannel}, #{item.paymentBusinessChannel}, #{item.paymentAccountNo}, #{item.merNos}, #{item.orderNo},
-             #{item.musicGroupId},
-             #{item.classGroupId}, #{item.payTime})
-         </foreach>
-    </insert>
 
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">

+ 10 - 3
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -133,10 +133,17 @@
     <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         INSERT INTO student_payment_route_order
-        (order_no_,route_organ_id_, route_amount_,route_balance_amount_, mer_no_,fee_flag_,usre_id_,school_id_,trans_no_,pay_time_,sale_amount_,service_amount_,memo_,goods_json_,audit_status_,audit_comment_,create_time_,update_time_,create_by_,update_by_)
+        (order_no_,route_organ_id_, route_amount_,route_balance_amount_, mer_no_,fee_flag_,user_id_,
+        school_id_,trans_no_,pay_time_,sale_amount_,service_amount_,memo_,goods_json_,audit_status_,
+        audit_comment_,create_time_,update_time_,create_by_,update_by_)
         VALUE
         <foreach collection="routeOrders" item="routeOrder" separator=",">
-            (#{routeOrder.orderNo},#{routeOrder.routeOrganId},#{routeOrder.routeAmount},#{routeOrder.routeBalanceAmount},#{routeOrder.merNo},#{routeOrder.feeFlag},#{routeOrder.userId},#{routeOrder.schoolId},#{routeOrder.transNo},#{routeOrder.payTime},#{routeOrder.saleAmount},#{routeOrder.serviceAmount},#{routeOrder.memo},#{routeOrder.goodsJson},#{routeOrder.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{routeOrder.auditComment},#{routeOrder.createTime},#{routeOrder.updateTime},#{routeOrder.createBy},#{routeOrder.updateBy})
+            (#{routeOrder.orderNo},#{routeOrder.routeOrganId},#{routeOrder.routeAmount},
+            #{routeOrder.routeBalanceAmount},#{routeOrder.merNo},#{routeOrder.feeFlag},
+            #{routeOrder.userId},#{routeOrder.schoolId},#{routeOrder.transNo},#{routeOrder.payTime},
+            #{routeOrder.saleAmount},#{routeOrder.serviceAmount},#{routeOrder.memo},#{routeOrder.goodsJson},
+            #{routeOrder.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{routeOrder.auditComment},
+            #{routeOrder.createTime},#{routeOrder.updateTime},NOW(),NOW())
         </foreach>
     </insert>
 
@@ -278,7 +285,7 @@
     </select>
     <select id="countByTransNo" resultType="java.lang.String">
         SELECT order_no_ FROM student_payment_route_order WHERE trans_no_ IN
-        <foreach collection="transNos" open="(" close=")" item="orderNo" separator=",">
+        <foreach collection="transNos" open="(" close=")" item="item" separator=",">
             #{item}
         </foreach>
     </select>

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

@@ -71,7 +71,7 @@ public class ImportController extends BaseController {
     @GetMapping(value = "downloadTemplate")
     @PreAuthorize("@pcs.hasPermissions('import/downloadTemplate')")
     public void getGoodsTemplate(HttpServletResponse response, TemplateTypeEnum templateType) throws IOException {
-        InputStream inputStream = new ClassPathResource("excelTemplate/" + templateType.getMsg() + ".xls").getInputStream();
+        InputStream inputStream = new ClassPathResource("excelTemplate/" + templateType.getMsg() + ".xlsx").getInputStream();
         OutputStream outputStream = response.getOutputStream();
         try {
             response.setContentType("application/octet-stream");

+ 2 - 2
mec-web/src/main/resources/columnMapper.ini

@@ -41,8 +41,8 @@
 交易流水号 = transNo
 收款账户 = merNo
 交易日期 = payTime
-销售金额 = goodsAmount
+销售金额 = saleAmount
 服务金额 = serviceAmount
-商品名称 = goodsIds
+商品编号 = goodsIds
 商品数量 = goodsNums
 备注 = memo

BIN
mec-web/src/main/resources/excelTemplate/财务管理导入模板.xlsx