|
|
|
@ -33,8 +33,12 @@ import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
|
import org.jeecg.modules.tablex.service.ITablexService; |
|
|
|
|
import org.jeecg.modules.tablex.ws.WebSocketUtils; |
|
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
|
import org.jeecgframework.poi.excel.def.TemplateExcelConstants; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.TemplateExportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
@ -42,6 +46,8 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
@ -82,6 +88,8 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
@Autowired |
|
|
|
|
private WebSocketUtils webSocketUtils; |
|
|
|
|
|
|
|
|
|
@Value("${jeecg.wordPath}") |
|
|
|
|
private String wordPath; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
@ -244,8 +252,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
|
} |
|
|
|
|
//校验时间
|
|
|
|
@ -263,8 +270,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
List<RuleVo> list = ExcelImportUtil.importExcel(file.getInputStream(), RuleVo.class, params); |
|
|
|
|
if (list == null || list.size() <= 0) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败:模板中暂无数据"); |
|
|
|
|
} |
|
|
|
|
int num = 0; |
|
|
|
@ -294,8 +300,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
} |
|
|
|
|
num++; |
|
|
|
|
if (num == 0) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败:导入模板不匹配"); |
|
|
|
|
// } else if (num!=list.size()) {
|
|
|
|
|
// return Result.error("文件导入失败:请检查填写文字");
|
|
|
|
@ -308,12 +313,10 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
log.error(msg, e); |
|
|
|
|
//if(msg!=null && msg.contains("Duplicate entry"))
|
|
|
|
|
if (msg != null && msg.indexOf("Duplicate entry") >= 0) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败:有重复数据!"); |
|
|
|
|
} else { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
|
|
|
|
@ -327,8 +330,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
|
|
|
|
|
List<RuleVo> ruleVoList = iRuleVoService.list(); |
|
|
|
|
if (ruleVoList.size() <= 0 || ruleVoList == null) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("文件导入失败,模板不匹配有空值"); |
|
|
|
|
} |
|
|
|
|
// 将总的记录数传递给前端
|
|
|
|
@ -345,8 +347,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
Fieldx byId = iFieldxService.getOne(rulexLambdaQueryWrapper); |
|
|
|
|
if (byId == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("字段输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFieldId(byId.getId()); |
|
|
|
@ -357,8 +358,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
Functionx byId1 = functionxService.getOne(functionxLambdaQueryWrapper); |
|
|
|
|
if (byId1 == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("功能输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setFunctionId(byId1.getId()); |
|
|
|
@ -368,8 +368,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
modulexLambdaQueryWrapper.eq(Modulex::getModuleName, moduleName); |
|
|
|
|
Modulex byId2 = iModulexService.getOne(modulexLambdaQueryWrapper); |
|
|
|
|
if (byId2 == null) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
|
|
|
|
|
return Result.error("模块输入错误,请核对"); |
|
|
|
@ -381,8 +380,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
tableLambdaQueryWrapper.eq(Tablex::getTableName, tableId); |
|
|
|
|
Tablex byId3 = iTablexService.getOne(tableLambdaQueryWrapper); |
|
|
|
|
if (byId3 == null) { |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
|
|
|
|
|
return Result.error("实体输入错误,请核对"); |
|
|
|
@ -395,8 +393,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
rulex.setDuration(aDouble); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("任务时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -405,8 +402,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
d = Double.valueOf(ruleVo.getRealDuration()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("实际时长输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setRealDuration(d); |
|
|
|
@ -415,8 +411,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
integer = Integer.valueOf(ruleVo.getWorkLevel()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("任务等级输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setWorkLevel(integer); |
|
|
|
@ -439,8 +434,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
rulex.setWorkStatus(9); |
|
|
|
|
else { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("任务状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String status = ruleVo.getStatus(); |
|
|
|
@ -455,8 +449,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
rulex.setStatus(9); |
|
|
|
|
else { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("规则状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
String verisonStatus = ruleVo.getVerisonStatus(); |
|
|
|
@ -465,8 +458,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
SysDictItem sysDictItem3 = sysDictItemMapper.selectOne(sysDictItemLambdaQueryWrapper3); |
|
|
|
|
if (sysDictItem3 == null) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("版本状态输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -480,8 +472,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
if (startTime != null) |
|
|
|
|
if (!validator.isValid(startTime)) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("开始时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date = simpleDateFormat.parse(startTime); |
|
|
|
@ -491,8 +482,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
if (submitTime != null) |
|
|
|
|
if (!validator.isValid(submitTime)) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("提交时间输入错误"); |
|
|
|
|
} else { |
|
|
|
|
Date date1 = simpleDateFormat.parse(submitTime); |
|
|
|
@ -507,8 +497,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
List<String> list = rulexMapper.checkRuleNo(byId1.getId()); |
|
|
|
|
if (list.contains(ruleNo)) { |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("规则序号已存在"); |
|
|
|
|
} |
|
|
|
|
rulex.setRuleNo(ruleNo); |
|
|
|
@ -533,8 +522,7 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
integer1 = Integer.valueOf(ruleVo.getVerison()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //手动回滚,这样上层就无需去处理异常了
|
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.error("版本号输入错误,请核对"); |
|
|
|
|
} |
|
|
|
|
rulex.setVerison(String.valueOf(integer1)); |
|
|
|
@ -546,10 +534,11 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
//存入真实表
|
|
|
|
|
rulexService.saveRule(rulex, loginUser, message, i + 1); |
|
|
|
|
message.put("status", "导入成功"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
iRuleVoService.remove(null); |
|
|
|
|
} |
|
|
|
|
message.put("isVisible", "false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -558,4 +547,31 @@ public class RulexController extends JeecgController<Rulex, IRulexService> { |
|
|
|
|
return rulexService.sort(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//导出实体标准模板
|
|
|
|
|
@RequestMapping(value = "/downExcel") |
|
|
|
|
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
|
//设置导出文件名称
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
Date date = new Date(System.currentTimeMillis()); |
|
|
|
|
String currTime = formatter.format(date); |
|
|
|
|
String fileName = currTime + "-" + "模板.xlsx"; |
|
|
|
|
try { |
|
|
|
|
String url = getClass().getClassLoader().getResource("static").getPath(); |
|
|
|
|
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
|
|
|
|
|
String templateUrl = wordPath + File.separator + "规则表模板.xls"; |
|
|
|
|
TemplateExportParams params = new TemplateExportParams( |
|
|
|
|
templateUrl); |
|
|
|
|
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); |
|
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); |
|
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, params); |
|
|
|
|
// 添加模板参数
|
|
|
|
|
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
|
|
|
|
|
return mv; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("下载模板异常--》{}", e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|