Browse Source

批量回款导入开发

anderx 6 years ago
parent
commit
ddefe268fb

+ 2 - 0
src/main/java/com/goafanti/admin/service/AttachmentService.java

@@ -8,4 +8,6 @@ public interface AttachmentService {
 
 	Attachment selectAftFileBySign(String sign);
 
+	Attachment selectByReceivbles(String sign);
+
 }

+ 11 - 0
src/main/java/com/goafanti/admin/service/impl/AttachmentServiceImpl.java

@@ -19,4 +19,15 @@ public class AttachmentServiceImpl implements AttachmentService {
 //		return aftFileMapper.selectAftFileBySign(sign);
 		return null;
 	}
+
+	@Override
+	public Attachment selectByReceivbles(String sign) {
+		if (sign.equals("receivbles_template")) {
+			Attachment a=new Attachment();
+			a.setFileName("模板.xls");
+			a.setFilePath("/tmp/receivbles_template.xls");
+			return a;
+		}
+		return null;
+	}
 }

+ 1 - 0
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;

+ 1 - 0
src/main/java/com/goafanti/common/enums/AttachmentType.java

@@ -40,6 +40,7 @@ public enum AttachmentType {
 	ACHIEVEMENT_COVER_PICTURE("achievement_cover_picture","科技成果封面图"),
 	DEMAND_TEMPLATE("demand_template", "科技需求批量导入模板"),
 	ACHIEVEMENT_TEMPLATE("achievement_template", "科技成果批量导入模板"),
+	RECEIVABLES_TEMPLATE("receivbles_template", "收款批量导入模板"),
 	DEMAND_ORDER_FILE("demand_order_file", "科技需求意向单/交易单附件"),
 	DEMAND_COVER_PICTURE("demand_cover_picture","科技需求封面图"),
 	BANNERS_PIC("banners", "广告图片"),

+ 33 - 0
src/main/java/com/goafanti/order/controller/AdminOrderReceivablesApiController.java

@@ -5,15 +5,19 @@ package com.goafanti.order.controller;
 
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.goafanti.admin.service.AttachmentService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.enums.AttachmentType;
+import com.goafanti.common.model.Attachment;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.order.bo.TemporaryReceivablesBo;
 import com.goafanti.order.service.OrderReceivablesService;
@@ -24,6 +28,8 @@ public class AdminOrderReceivablesApiController extends CertifyApiController {
 	
 	@Resource
 	private OrderReceivablesService orderReceivablesService;
+	@Resource
+	private AttachmentService	attachmentService;
 	/**
 	 * 	新增预计回款信息
 	 * @param t
@@ -109,4 +115,31 @@ public class AdminOrderReceivablesApiController extends CertifyApiController {
 		res.data(orderReceivablesService.batchImport());
 		return res;
 	}
+	
+	 /**
+     * 下载回款批量导入Excel模板
+     * 
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
+    public Result downloadTemplateFile(HttpServletResponse response, String sign) {
+        Result res = new Result();
+        AttachmentType attachmentType = AttachmentType.getField(sign);
+        if (attachmentType == AttachmentType.RECEIVABLES_TEMPLATE) {
+            String fileName = "";
+            Attachment af = attachmentService.selectByReceivbles(sign);
+            if (null == af) {
+                res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
+            } else {
+                String path = af.getFilePath();
+                String suffix = path.substring(path.lastIndexOf("."));
+                fileName = AttachmentType.RECEIVABLES_TEMPLATE.getDesc() + suffix;
+                downloadFile(response, fileName, path);
+            }
+        } else {
+            res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
+        }
+        return res;
+    }
 }

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

@@ -60,12 +60,12 @@ template.cacheable=false
 portal.host=//sf.jishutao.com/portal/2.0.6
 avatar.upload.host=//sb.jishutao.com/upload
 #连接开发
-static.host=//sb.jishutao.com/1.1.22
-avatar.host=//sb.jishutao.com
+#static.host=//sb.jishutao.com/1.1.22
+#avatar.host=//sb.jishutao.com
 
 #连测试
-#avatar.host=//static.jishutao.com
-#static.host=//static.jishutao.com/1.1.22
+avatar.host=//static.jishutao.com
+static.host=//static.jishutao.com/1.1.22
 
 upload.path=F:/data/public/upload
 upload.private.path=F:/data/private/upload