|
@@ -13,6 +13,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.geke.userShift.entity.UserShift;
|
|
|
+import org.jeecg.modules.geke.userShift.entity.UserShiftExcel;
|
|
|
import org.jeecg.modules.geke.userShift.entity.UserShiftVo;
|
|
|
import org.jeecg.modules.geke.userShift.service.IUserShiftService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -173,18 +174,54 @@ public class UserShiftController extends JeecgController<UserShift, IUserShiftSe
|
|
|
return super.exportXls(request, userShift, UserShift.class, "员工排班");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- return super.importExcel(request, response, UserShift.class);
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
+ Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
+ for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
+ MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
+ ImportParams params = new ImportParams();
|
|
|
+ params.setTitleRows(2);
|
|
|
+ params.setHeadRows(1);
|
|
|
+ params.setNeedSave(true);
|
|
|
+ try {
|
|
|
+ List<UserShiftExcel> list = ExcelImportUtil.importExcel(file.getInputStream(), UserShiftExcel.class, params);
|
|
|
+ for(UserShiftExcel o:list){
|
|
|
+ System.out.println(o.getWorkNo());
|
|
|
+ System.out.println(o.getName());
|
|
|
+ System.out.println(o.getA1());
|
|
|
+ System.out.println(o.getA2());
|
|
|
+ System.out.println(o.getA3());
|
|
|
+ System.out.println(o.getA4());
|
|
|
+ System.out.println(o.getA5());
|
|
|
+ }
|
|
|
+ //update-begin-author:taoyan date:20190528 for:批量插入数据
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ //400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
|
|
+ //1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
|
|
+ log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
|
|
+ //update-end-author:taoyan date:20190528 for:批量插入数据
|
|
|
+ return Result.ok("文件导入成功!数据行数:" + list.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ return Result.error("文件导入失败:" + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ file.getInputStream().close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.error("文件导入失败!");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/UserShiftType")
|