diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index ec6a589..114d081 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -916,8 +916,15 @@ $(() => { $(() => { let config = { - conditions: {}, - tableName: "", + // 条件 + conditions: { + lx: '', + bxxx: '' + }, + // 表名 + tableName: "uf_hgpxtz", + // 文档字段 + docIdField: 'clwd' } function pxlx() { @@ -925,12 +932,70 @@ $(() => { if (datas && datas.length >= 1) { let obj = datas[0]; let value = obj.lx - console.log(obj) - let url = "/spa/workflow/index_form.jsp#/main/workflow/req?iscreate=1&workflowid=306&field24498=" + value; - window.open(url); + Object.keys(config.conditions).forEach(key => { + config.conditions[key] = obj[key] + }) + api({ + url: "/api/aiyh/exam-btn/control/is-read", + type: "POST", + data: JSON.stringify(config), + contentType: "application/json" + }).then(res => { + if (res && res.code == 200) { + if (res.data) { + let url = "/spa/workflow/index_form.jsp#/main/workflow/req?iscreate=1&workflowid=306&field24498=" + value; + window.open(url); + } else { + ModeList.showMessage("需要查看所有考试相关文档后方可考试,请先查看考试材料!", 1, 2); + } + } else { + ModeList.showMessage("系统错误,请稍后尝试!", 2, 1.5); + } + }) + } } + + window.pxlx = pxlx + + /** + * @author youhong.ai + * @desc 发起请求 + */ + function api(requestOptions = { + url: "", + type: "GET", + data: "", + isAsync: true, + success: () => { + }, + error: () => { + }, + complete: () => { + }, + contentType: 'application/json', + beforeSend: () => { + } + }) { + let options = Object.assign({ + url: "", + type: "GET", + data: "", + isAsync: true, + success: () => { + }, + error: () => { + }, + complete: () => { + }, + contentType: 'application/json', + beforeSend: () => { + } + }, requestOptions) + return $.ajax(options) + } + }) /* ******************* youhong.ai 限制考试按钮点击 end ******************* */ diff --git a/src/main/java/aiyh/utils/recordset/MapperBuilderSql.java b/src/main/java/aiyh/utils/recordset/MapperBuilderSql.java index 6f7eb38..5c42a5f 100644 --- a/src/main/java/aiyh/utils/recordset/MapperBuilderSql.java +++ b/src/main/java/aiyh/utils/recordset/MapperBuilderSql.java @@ -128,7 +128,6 @@ public class MapperBuilderSql { } sb.append(entry.getKey()).append("}").append(" and "); } - sb.deleteCharAt(sb.length() - 5); - return sb.toString(); + return sb.substring(0, sb.length() - 5); } } diff --git a/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java b/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java index 44fc415..cea8eee 100644 --- a/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java +++ b/src/main/java/aiyh/utils/recordset/RsThreadLocalManager.java @@ -159,9 +159,16 @@ public class RsThreadLocalManager { public boolean commit(String className) { RecordSetTrans recordSetTrans = getRecordSetTrans(className); + removeRsOrTrans(); + setRecordSetTrans(className); return recordSetTrans.commit(); } + + public void removeRsOrTrans() { + rsMap.remove(Thread.currentThread().getId()); + } + private RecordSetTrans getRecordSetTrans(String className) { Map map = rsMap.get(Thread.currentThread().getId()); if (Objects.isNull(map)) { @@ -179,6 +186,8 @@ public class RsThreadLocalManager { public boolean rollback(String className) { RecordSetTrans recordSetTrans = getRecordSetTrans(className); + removeRsOrTrans(); + setRecordSetTrans(className); return recordSetTrans.rollback(); } diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java index d96336e..d13221f 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java @@ -10,7 +10,10 @@ import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.util.Map; @@ -32,11 +35,12 @@ public class ExamBtnControlController { @Path("/is-read") @POST @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) public String isReadDoc(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody Map params) { + @RequestBody Map params) { try { User user = HrmUserVarify.getUser(request, response); - return ApiResult.success(service.isReadDoc(user,params)); + return ApiResult.success(service.isReadDoc(user, params)); } catch (Exception e) { log.error("is read doc error!\n" + Util.getErrString(e)); return ApiResult.error("system error!"); diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java index a67a401..5911dd7 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java @@ -5,6 +5,7 @@ import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; import java.util.List; +import java.util.Map; /** *

@@ -28,7 +29,8 @@ public interface ExamBtnControlMapper { @Select("select $t{docIdField} from $t{tableName} $t{whereSql}") List selectDocIds(@ParamMapper("tableName") String tableName, @ParamMapper("docIdField") String docIdField, - @ParamMapper("whereSql") String whereSql); + @ParamMapper("whereSql") String whereSql, + @ParamMapper("where") Map conditions); /** *

查询已读标记

diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java index 65e1dd9..96e2bea 100644 --- a/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java @@ -43,12 +43,12 @@ public class ExamBtnControlService { if (CollectionUtil.isEmpty(conditions)) { return false; } - String where = MapperBuilderSql.builderNoWhereAndEn(conditions, true); + String where = MapperBuilderSql.builderWhereAnd(conditions, "where", true); if (StrUtil.isBlank(where)) { log.error("没有生成where条件!"); return false; } - List docIdList = mapper.selectDocIds(tableName, docIdField, where); + List docIdList = mapper.selectDocIds(tableName, docIdField, where, conditions); if (CollectionUtil.isEmpty(docIdList)) { throw new CustomerException("没有查询到对应的文件ID信息,请检查sql!"); } diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index 760c550..e0f4b9c 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -69,6 +69,7 @@ public class BuilderPackageEcology extends Application { clearSelections(); updateTreeView(); showSuccessAlert("升级包制作成功!"); + System.out.println("压缩包位置: " + outputFile.getPath()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/test/java/youhong/ai/pcn/UtilTest.java b/src/test/java/youhong/ai/pcn/UtilTest.java index 12bde69..f2f61e9 100644 --- a/src/test/java/youhong/ai/pcn/UtilTest.java +++ b/src/test/java/youhong/ai/pcn/UtilTest.java @@ -2,6 +2,7 @@ package youhong.ai.pcn; import aiyh.utils.GenerateFileUtil; import aiyh.utils.Util; +import aiyh.utils.recordset.MapperBuilderSql; import aiyh.utils.tool.org.apache.commons.jexl3.*; import basetest.BaseTest; import com.alibaba.fastjson.JSON; @@ -308,4 +309,13 @@ public class UtilTest extends BaseTest { public void testSS() { out.println(Util.getTime("yyyyMMddHHmmssSSSS")); } + + + @Test + public void testssfss() { + Map map = new HashMap<>(); + map.put("lx", "2"); + map.put("dxxx", "2"); + out.println(MapperBuilderSql.builderWhereAnd(map, "where", true)); + } }