|
|
@@ -12,6 +12,7 @@ import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.common.utils.SystemUtils;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
@@ -33,9 +34,11 @@ import org.springblade.manager.vo.WbsFormElementVO;
|
|
|
import org.springblade.manager.vo.WbsFormElementVO2;
|
|
|
import org.springblade.manager.vo.WbsNodeTableVO;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.ResultSetExtractor;
|
|
|
import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -416,6 +419,71 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 刷新html中元素对应的标签值
|
|
|
+ * 需要m_wbs_form_element_rebrush表
|
|
|
+ */
|
|
|
+ @Scheduled(fixedDelay = 60000)
|
|
|
+ public void test(){
|
|
|
+ if (SystemUtils.isWindows() || SystemUtils.isMacOs()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //查询需要重刷的数据
|
|
|
+ String sql="select * from m_wbs_form_element_rebrush where is_brush=0 limit 200";
|
|
|
+ List<Map<String,Object>> rebushList = null;
|
|
|
+ try {
|
|
|
+ rebushList = jdbcTemplate.queryForList(sql);
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isEmpty(rebushList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ rebushList.forEach(f->{
|
|
|
+ //当前元素表下所有元素信息
|
|
|
+ List<WbsFormElement> wbsFormElements = baseMapper.selectList(Wrappers.<WbsFormElement>query().lambda().eq(WbsFormElement::getFId, f.get("init_table_id")));
|
|
|
+ if(CollectionUtil.isNotEmpty(wbsFormElements)){
|
|
|
+ String sqlHtml="select DISTINCT html_url from m_wbs_tree_private where init_table_name='"+f.get("init_table_name")+"' and is_deleted=0 and html_url is not null";
|
|
|
+ List<String> htmlurls = jdbcTemplate.query(sqlHtml, new SingleColumnRowMapper<>(String.class));
|
|
|
+ if(!htmlurls.isEmpty()){
|
|
|
+ for (String htmlurl : htmlurls) {
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = FileUtils.getInputStreamByUrl(htmlurl);
|
|
|
+ } catch (Exception e) {}
|
|
|
+ if(inputStream==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String htmlString = IoUtil.readToString(inputStream);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ for (WbsFormElement wbsFormElement : wbsFormElements) {
|
|
|
+ Elements elements = doc.select("[keyname^=" + wbsFormElement.getEKey() + "__]");;
|
|
|
+ for (Element element : elements) {
|
|
|
+ String attr = element.attr("placeholder");
|
|
|
+ if(!wbsFormElement.getEName().equals(attr)){
|
|
|
+ element.attr("placeholder", wbsFormElement.getEName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ File writefile = new File(htmlurl);
|
|
|
+ FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println("修改html文件异常:"+ htmlurl);
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {}
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jdbcTemplate.execute("update m_wbs_form_element_rebrush set is_brush = 1 where init_table_id = " + f.get("init_table_id"));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<WbsFormElementDTO2> findWbsTreeTableSameLevel(String parentId) {
|
|
|
return baseMapper.selectWbsTreeTableListByParentId(parentId);
|