|
|
@@ -81,6 +81,7 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -1016,6 +1017,7 @@ public class ExcelTabController extends BladeController {
|
|
|
keyNames.attr("placeholder", textdictInfoVO.getSigRoleName());
|
|
|
}
|
|
|
}
|
|
|
+ setTableTips(wbsTreeContract, table);
|
|
|
fileInputStream.close();
|
|
|
return R.data(table + "");
|
|
|
} catch (Exception e) {
|
|
|
@@ -1023,6 +1025,197 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setTableTips(WbsTreeContract tableNode, Element tableHtml) {
|
|
|
+ if (tableNode == null || tableHtml == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AtomicInteger status = new AtomicInteger(1);
|
|
|
+ String tableName = tableNode.getInitTableName();
|
|
|
+ List<Map<String, Object>> valueMapList = jdbcTemplate.queryForList("select * from " + tableName + " where p_key_id = " + tableNode.getPKeyId());
|
|
|
+ Map<String, Object> map;
|
|
|
+ if (CollectionUtil.isEmpty(valueMapList) || CollectionUtil.isEmpty(valueMapList.get(0))) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ } else {
|
|
|
+ map = valueMapList.get(0);
|
|
|
+ DataStructureFormatUtils.parseDataByKey( map);
|
|
|
+ }
|
|
|
+ List<WbsFormElement> wbsFormElementList = jdbcTemplate.query("select * from m_wbs_form_element where f_id = ( select id from m_table_info where tab_en_name in ( '" + tableName + "' ) and is_deleted = 0) and is_deleted = 0 and (required = 1 or node_ignore is not null)",
|
|
|
+ new BeanPropertyRowMapper<>(WbsFormElement.class));
|
|
|
+ if (CollectionUtil.isEmpty(wbsFormElementList)) {
|
|
|
+ Elements elements = tableHtml.select("el-date-picker");
|
|
|
+ elements.forEach(element -> {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ String key = keyname.split("__")[0];
|
|
|
+ if (map.get(key)!= null) {
|
|
|
+ String value = map.get(key).toString();
|
|
|
+ if (value.contains("_^_")) {
|
|
|
+ String[] split = value.split("☆");
|
|
|
+ for (String s : split) {
|
|
|
+ if (StringUtil.hasText(s.split("_\\^_")[0])) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ status.set(2);
|
|
|
+ Elements parents = element.parents();
|
|
|
+ for (Element parent : parents) {
|
|
|
+ if (parent.tagName().equals("td")) {
|
|
|
+ if (parent.hasAttr("style")) {
|
|
|
+ parent.attr("style", parent.attr("style") + "position: relative;");
|
|
|
+ } else {
|
|
|
+ parent.attr("style", "position: relative;");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ element.before("<hc-tooltip :tipsStatus=\"" + true + "\" text=\"缺少日期\" keyname=\""+keyname +"\" @leftClick=\"changeTipsStatus\" typeKey=\"" + key + "\"/>");
|
|
|
+ });
|
|
|
+ updateCheckData(tableNode,status.get());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, WbsFormElement> keyMap = wbsFormElementList.stream().collect(Collectors.toMap(WbsFormElement::getEKey, item -> item, (v1, v2) -> v1));
|
|
|
+ Map<Long, WbsFormElement> hasMap = new HashMap<>();
|
|
|
+ Elements elements = tableHtml.select("el-date-picker");
|
|
|
+ elements.forEach(element -> {
|
|
|
+ String keyname = element.attr("keyname");
|
|
|
+ String key = keyname.split("__")[0];
|
|
|
+ if (map.get(key)!= null) {
|
|
|
+ String value = map.get(key).toString();
|
|
|
+ if (value.contains("_^_")) {
|
|
|
+ String[] split = value.split("☆");
|
|
|
+ for (String s : split) {
|
|
|
+ if (StringUtil.hasText(s.split("_\\^_")[0])) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean flag = true;
|
|
|
+ if (keyMap.containsKey(key)) {
|
|
|
+ WbsFormElement wbsFormElement = keyMap.get(key);
|
|
|
+ if (wbsFormElement != null && wbsFormElement.getNodeIgnore() != null && wbsFormElement.getNodeIgnore().contains(tableNode.getPId() + "")) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ if (wbsFormElement != null) {
|
|
|
+ hasMap.put(wbsFormElement.getId(), wbsFormElement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Elements parents = element.parents();
|
|
|
+ for (Element parent : parents) {
|
|
|
+ if (parent.tagName().equals("td")) {
|
|
|
+ if (parent.hasAttr("style")) {
|
|
|
+ parent.attr("style", parent.attr("style") + "position: relative;");
|
|
|
+ } else {
|
|
|
+ parent.attr("style", "position: relative;");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ element.before("<hc-tooltip :tipsStatus=\"" + flag + "\" text=\"缺少日期\" keyname=\""+keyname +"\" @leftClick=\"changeTipsStatus\" typeKey=\"" + key + "\"/>");
|
|
|
+ if (flag) {
|
|
|
+ status.set(2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ for (WbsFormElement wbsFormElement : wbsFormElementList) {
|
|
|
+ if (hasMap.containsKey(wbsFormElement.getId()) || wbsFormElement.getRequired() == null || wbsFormElement.getRequired() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Object obj = map.get(wbsFormElement.getEKey());
|
|
|
+ if (obj!= null) {
|
|
|
+ String value = obj.toString();
|
|
|
+ if (value.contains("_^_")) {
|
|
|
+ String[] split = value.split("☆");
|
|
|
+ boolean hasText = false;
|
|
|
+ for (String s : split) {
|
|
|
+ if (StringUtil.hasText(s.split("_\\^_")[0])) {
|
|
|
+ hasText = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasText) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查找html中标签属性 keyname中包含 wbsFormElement.getEKey()的标签
|
|
|
+ Elements keyNames = tableHtml.getElementsByAttributeValueContaining("keyname", wbsFormElement.getEKey() + "__");
|
|
|
+ if (!keyNames.isEmpty()) {
|
|
|
+ keyNames.forEach(element -> {
|
|
|
+ if ("el-date-picker".equals(element.tagName()) || "td".equals(element.tagName()) || "hc-tooltip".equals(element.tagName())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ boolean flag = true;
|
|
|
+ if (wbsFormElement.getNodeIgnore() != null && wbsFormElement.getNodeIgnore().contains(tableNode.getPId() + "")) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ Elements parents = element.parents();
|
|
|
+ for (Element parent : parents) {
|
|
|
+ if (parent.tagName().equals("td")) {
|
|
|
+ if (parent.hasAttr("style")) {
|
|
|
+ parent.attr("style", parent.attr("style") + "position: relative;");
|
|
|
+ } else {
|
|
|
+ parent.attr("style", "position: relative;");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String keynameAttr = element.attr("keyname");
|
|
|
+ element.before("<hc-tooltip :tipsStatus=\"" + flag + "\" text=\"此项为必填项\" keyname=\""+keynameAttr +"\" @leftClick=\"changeTipsStatus\" typeKey=\"" + wbsFormElement.getEKey() + "\"/>");
|
|
|
+ if (flag) {
|
|
|
+ if (status.get() == 2) {
|
|
|
+ status.set(4);
|
|
|
+ } else if (status.get() == 1) {
|
|
|
+ status.set(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateCheckData(tableNode,status.get());
|
|
|
+ }
|
|
|
+ @Async
|
|
|
+ public void updateCheckData(WbsTreeContract tableNode, Integer status) {
|
|
|
+ if (status >= 1) {
|
|
|
+ wbsTreeContractService.update(Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getDateIsComplete, status).eq(WbsTreeContract::getPKeyId, tableNode.getPKeyId()));
|
|
|
+ WbsTreeContract parentNode = wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableNode.getPId()));
|
|
|
+ wbsTreeContractService.checkNodeAllDate(parentNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Async
|
|
|
+ public void checkTableAllData(WbsTreeContract node) {
|
|
|
+ List<WbsTreeContract> list = wbsTreeContractService.list(new LambdaQueryWrapper<>(WbsTreeContract.class).eq(WbsTreeContract::getPId, node.getPKeyId()).apply(" (is_buss_show <> 2 or is_buss_show is null)"));
|
|
|
+ list.forEach(table -> {
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, table.getPKeyId()));
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String fileUrl = wbsTreeContract.getHtmlUrl();
|
|
|
+ //如果有历史html就使用历史html
|
|
|
+ WbsTreeContractOldHtml one = wbsTreeContractOldHtmlService.getOne(Wrappers.<WbsTreeContractOldHtml>lambdaQuery()
|
|
|
+ .eq(WbsTreeContractOldHtml::getContractFormId, table.getPKeyId())
|
|
|
+ .eq(WbsTreeContractOldHtml::getIsDeleted, 0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if(one != null && StringUtils.isNotEmpty(one.getOldHtmlUrl())){
|
|
|
+ fileUrl = one.getOldHtmlUrl();
|
|
|
+ }
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element tableElement = doc.select("table").first();
|
|
|
+ setTableTips(wbsTreeContract, tableElement);
|
|
|
+ fileInputStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 后管清表生成html
|
|
|
*/
|
|
|
@@ -2472,7 +2665,8 @@ public class ExcelTabController extends BladeController {
|
|
|
//检查当前节点下所有的未隐藏的表单日期是否填写完整
|
|
|
WbsTreeContract contract = wbsTreeContractService.getById(Long.parseLong(nodeId));
|
|
|
if(contract!=null){
|
|
|
- wbsTreeContractService.checkNodeAllDate(contract);
|
|
|
+// wbsTreeContractService.checkNodeAllDate(contract);
|
|
|
+ checkTableAllData(contract);
|
|
|
}
|
|
|
executionTime.info("----数据保存完毕 ----");
|
|
|
//发生异常后直接返回,不进行合并
|
|
|
@@ -5362,4 +5556,46 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.data(excelTabService.getWbsTreeExcelTab(id,nodeId));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping("/ignoreTips")
|
|
|
+ @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperation(value = "忽略必填提示", notes = "忽略必填提示")
|
|
|
+ public R<Boolean> ignoreTips(@RequestParam Long pkeyId, @RequestParam String key) {
|
|
|
+ if (key == null) {
|
|
|
+ throw new ServiceException("参数错误");
|
|
|
+ }
|
|
|
+ WbsTreeContract table = wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ if (table == null) {
|
|
|
+ throw new ServiceException("没有找到表单");
|
|
|
+ }
|
|
|
+ List<org.springblade.manager.entity.TableInfo> tableInfos = tableInfoService.list(Wrappers.<org.springblade.manager.entity.TableInfo>lambdaQuery().eq(org.springblade.manager.entity.TableInfo::getTabEnName, table.getInitTableName()));
|
|
|
+ if (tableInfos == null || tableInfos.isEmpty()) {
|
|
|
+ return R.fail("没有找到关联元素");
|
|
|
+ }
|
|
|
+ org.springblade.manager.entity.TableInfo tableInfo = tableInfos.get(0);
|
|
|
+ if (key.contains("__")) {
|
|
|
+ key = key.split("__")[0];
|
|
|
+ }
|
|
|
+ List<WbsFormElement> list = wbsFormElementService.list(Wrappers.<WbsFormElement>lambdaQuery().eq(WbsFormElement::getFId, tableInfo.getId()).eq(WbsFormElement::getEKey, key));
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return R.fail("没有找到关联元素");
|
|
|
+ }
|
|
|
+ WbsFormElement element = list.get(0);
|
|
|
+ String sql= "";
|
|
|
+ if (element.getNodeIgnore() == null || !element.getNodeIgnore().contains(table.getPId() + "")) {
|
|
|
+ element.setNodeIgnore(element.getNodeIgnore() == null ? table.getPId() + "" : element.getNodeIgnore() + "," + table.getPId());
|
|
|
+ sql = " node_ignore = CONCAT(if(node_ignore is null,'',node_ignore), " + "'," + table.getPId() + "')";
|
|
|
+ } else {
|
|
|
+ element.setNodeIgnore(element.getNodeIgnore().replace(table.getPId() + "", ""));
|
|
|
+ sql = " node_ignore = REPLACE(node_ignore, " + "'," + table.getPId() + "', '')";
|
|
|
+ }
|
|
|
+ wbsFormElementService.update(Wrappers.<WbsFormElement>lambdaUpdate().eq(WbsFormElement::getId, element.getId()).setSql( sql));
|
|
|
+ asyncUpdateCheckStatus(pkeyId);
|
|
|
+ return R.data(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void asyncUpdateCheckStatus(Long pkeyId) {
|
|
|
+ this.getExcelHtmlByBuss(pkeyId);
|
|
|
+ }
|
|
|
}
|