|
@@ -1,5 +1,7 @@
|
|
package com.ssj.sys.controller;
|
|
package com.ssj.sys.controller;
|
|
|
|
|
|
|
|
+import com.ssj.bean.common.framework.core.domain.Response;
|
|
|
|
+import com.ssj.bean.sys.imlibuser.TbClassTeacherTemp;
|
|
import com.ssj.bean.weixin.libmy.domain.LibVip;
|
|
import com.ssj.bean.weixin.libmy.domain.LibVip;
|
|
import com.ssj.bean.weixin.order.domain.Order;
|
|
import com.ssj.bean.weixin.order.domain.Order;
|
|
import com.ssj.bean.weixin.sales.domain.LibOrderDetails;
|
|
import com.ssj.bean.weixin.sales.domain.LibOrderDetails;
|
|
@@ -17,6 +19,9 @@ import com.ssj.service.weixin.sales.service.LibOrderDetailsService;
|
|
import com.ssj.service.weixin.sales.service.LibSalesPriceService;
|
|
import com.ssj.service.weixin.sales.service.LibSalesPriceService;
|
|
import com.ssj.service.weixin.sales.service.LibStaffingService;
|
|
import com.ssj.service.weixin.sales.service.LibStaffingService;
|
|
import com.ssj.service.weixin.sales.service.LibVipServiceService;
|
|
import com.ssj.service.weixin.sales.service.LibVipServiceService;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -25,8 +30,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -395,6 +402,98 @@ public class SysOrderController extends BaseController {
|
|
|
|
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value="/principal/import")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Response principalImput(Model model, @RequestParam("file") MultipartFile file) {
|
|
|
|
+ Response response = new Response();
|
|
|
|
+ try {
|
|
|
|
+ List<Map<String,String>> datas=analysisExFile(file);
|
|
|
|
+ if(datas!=null && datas.size()>0){
|
|
|
|
+ String msg = "";
|
|
|
|
+ int i = 1;
|
|
|
|
+ for (Map<String,String> map : datas) {
|
|
|
|
+ //订单编号 data_0
|
|
|
|
+ //服务到期时间 data_1
|
|
|
|
+ LibOrderDetails orderDetails = libOrderDetailsService.getByOrderNo(map.get("data_0"));
|
|
|
|
+ if(Objects.isNull(orderDetails)){
|
|
|
|
+ msg +="第"+i+"行第一列,";
|
|
|
|
+ i++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(map.containsKey("data_1") && !"".equals(map.get("data_1"))){
|
|
|
|
+ libOrderDetailsService.updateServiceEndTime(orderDetails.getId(),map.get("data_1"));
|
|
|
|
+ }else{
|
|
|
|
+ msg +="第"+i+"行第二列,";
|
|
|
|
+ i++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("异常", e);
|
|
|
|
+ response.failure("导入异常:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * ----------------解析文档相关功能-----------------------
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ public static List<Map<String,String>> analysisExFile(MultipartFile file) throws Exception {
|
|
|
|
+ List<Map<String,String>> datas=new ArrayList<Map<String,String>>();
|
|
|
|
+ Map<String,String> map=null;
|
|
|
|
+
|
|
|
|
+ @SuppressWarnings("resource")
|
|
|
|
+ Workbook wb = new XSSFWorkbook(file.getInputStream());
|
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
|
+ Row row = null;
|
|
|
|
+ Cell cell = null;
|
|
|
|
+ for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
|
|
|
|
+ map=new LinkedHashMap<String, String>();
|
|
|
|
+ row = it.next();
|
|
|
|
+ if (row == null) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if(row.getRowNum()<=0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isEmpty(getValue(row.getCell(0)))){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ for (Iterator<Cell> cit =row.cellIterator(); cit.hasNext();) {
|
|
|
|
+ cell = cit.next();
|
|
|
|
+ if (cell == null) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isEmpty(getValue(cell))){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ map.put("data_"+cell.getColumnIndex(), getValue(cell));
|
|
|
|
+ }
|
|
|
|
+ datas.add(map);
|
|
|
|
+ }
|
|
|
|
+ return datas;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getValue(Cell cell){
|
|
|
|
+ if(cell==null) {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()){
|
|
|
|
+ if(DateUtil.isCellDateFormatted(cell)){
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置转成的时间格式
|
|
|
|
+ Date date = cell.getDateCellValue();//取得的是date类型
|
|
|
|
+ String datestr = sdf.format(date);//这里是转成String类型了,要哪种按个人需求
|
|
|
|
+ return datestr;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cell.setCellType(Cell.CELL_TYPE_STRING);
|
|
|
|
+ String text=cell.getStringCellValue()!=null ? String.valueOf(cell.getStringCellValue()):"";
|
|
|
|
+ return text.trim();
|
|
|
|
+ }
|
|
}
|
|
}
|