post参数文件设置
Java后台接受并处理请求
/*** 上传表格数据* @param model* @param request* @param response* @return*/@RequestMapping(value = "shangchuan")public synchronized R fileUpload(Model model,HttpServletRequest request,HttpServletResponse response){try {String[] fields = {"lineName", "majorName", "procedureName", "totalQuantity"};List<ConstructionProcedureConfig> map = ExcelImportUtil.getImportData(fields, ConstructionProcedureConfig.class, request);List<ConstructionProcedureConfig> configs=new ArrayList<>();for(int i=0;i<map.size();i++){ConstructionProcedureConfig config = map.get(i);//查询线路EntityWrapper<DqLinename> entityWrapper = new EntityWrapper<DqLinename>();Wrapper<DqLinename> wrapper = entityWrapper.eq("linename", config.getLineName());DqLinename dqLinename = dqLinenameService.selectOne(wrapper);if(dqLinename == null){return R.error("线路数据不存在");}if(!BaseMajorEnum.DQ_QYBDZ.getName().equals(config.getMajorName())){return R.error("专业数据不存在");}BaseConstructionProcedure baseConstruct = baseConstructionProcedureService.getByName(majorId, config.getProcedureName());if(baseConstruct == null){return R.error("工序数据不存在");}//通过线路名称和专业分类名称以及工序名称获取唯一施工配置EntityWrapper<ConstructionProcedureConfig> coEntityWrapper = new EntityWrapper<ConstructionProcedureConfig>();Wrapper<ConstructionProcedureConfig> configwrapper = coEntityWrapper.eq("lineid", dqLinename.getId()).eq("major_name", config.getMajorName()).eq("procedure_name", config.getProcedureName());ConstructionProcedureConfig constructionprocedureconfig = constructionProcedureConfigService.selectOne(configwrapper);if(constructionprocedureconfig == null){constructionprocedureconfig = new ConstructionProcedureConfig();constructionprocedureconfig.setLineid(dqLinename.getId());constructionprocedureconfig.setLineName(dqLinename.getLinename());constructionprocedureconfig.setMajorId(majorId);constructionprocedureconfig.setMajorName(config.getMajorName());constructionprocedureconfig.setProcedureCode(baseConstruct.getCode());constructionprocedureconfig.setProcedureId(baseConstruct.getId());constructionprocedureconfig.setProcedureName(baseConstruct.getName());constructionprocedureconfig.setUnit(baseConstruct.getUnit());constructionprocedureconfig.setSort(baseConstruct.getSort());constructionprocedureconfig.setTotalQuantity(config.getTotalQuantity());}else{constructionprocedureconfig.setTotalQuantity(config.getTotalQuantity());}configs.add(constructionprocedureconfig);}constructionProcedureConfigService.insertOrUpdateBatch(configs);return R.ok();} catch (Exception e) {logger.error("excel上传异常:", e);return R.error("上传失败");}}