diff --git a/WebContent/Frame/page/js/as_control.js b/WebContent/Frame/page/js/as_control.js index 40399ec3d..038ccf6b7 100644 --- a/WebContent/Frame/page/js/as_control.js +++ b/WebContent/Frame/page/js/as_control.js @@ -450,6 +450,10 @@ AsControl.RunJavaMethodSqlca = function (ClassName,MethodName,Args) { return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,"&ArgsObject=Sqlca"),ClassName); }; +AsControl.RunJavaMethodSqlcaCustom = function (ClassName,MethodName,Args) { + return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethodCustom(ClassName,MethodName,Args,"&ArgsObject=Sqlca"),ClassName); +}; + /** * 运行JBOTransaction Trans参数后台java方法 * @param ClassName 类路径字符串,且必须有空构造 @@ -461,6 +465,10 @@ AsControl.RunJavaMethodTrans = function (ClassName,MethodName,Args) { return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,"&ArgsObject=Trans"),ClassName); }; +AsControl.RunJavaMethodTransCustom = function (ClassName,MethodName,Args) { + return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethodCustom(ClassName,MethodName,Args,"&ArgsObject=Trans"),ClassName); +}; + /** * 运行后台java方法 * @param ClassName 类路径字符串,且必须有空构造 @@ -522,6 +530,20 @@ AsControl.CallJavaMethod = function (ClassName,MethodName,Args,ArgsObjectText) { }).responseText.trim()); }; +AsControl.CallJavaMethodCustom = function (ClassName,MethodName,Args,ArgsObjectText) { + return AsControl.dealAjaxText(jQuery.ajax({ + type: "POST", + url: sWebRootPath+"/servlet/run?1=1"+ArgsObjectText, + data : { + "ClassName":ClassName, + "MethodName":MethodName, + "Args":Args.replace(/\+/g, 'Ж').replace(/\%/g, 'ё') + }, + async: false, + error: AsControl.ajaxError + }).responseText.trim()); +}; + AsControl.RewriteCallJavaMethod = function (ClassName,MethodName,Args,ArgsObjectText) { if(Args.length>0){ Args=Args+AsControl.getParamToFixedParam(Args); diff --git a/WebContent/Tenwa/Lease/Flow/Rent/PenaltyReduction/VILCRentPlanForReductionList.jsp b/WebContent/Tenwa/Lease/Flow/Rent/PenaltyReduction/VILCRentPlanForReductionList.jsp index 19f3cfce8..48ae1d2d4 100644 --- a/WebContent/Tenwa/Lease/Flow/Rent/PenaltyReduction/VILCRentPlanForReductionList.jsp +++ b/WebContent/Tenwa/Lease/Flow/Rent/PenaltyReduction/VILCRentPlanForReductionList.jsp @@ -40,13 +40,25 @@ } var overPenaltys = getItemValueArray(0, "PENALTY_OVER") + "," + TablePage.getCheckedItemValueArrayWithOtherPage("PENALTY_OVER", s_c_p[0]); var planLists = getItemValueArray(0, "PLAN_LIST") + "," + TablePage.getCheckedItemValueArrayWithOtherPage("PLAN_LIST", s_c_p[0]); + + let params = { + flowunid: '<%=flowunid%>', + paymentNumber: '<%=paymentNumber%>', + planLists: planLists + }; + console.info('AsControl', AsControl.RunJavaMethodSqlcaCustom); + let sReturn = AsControl.RunJavaMethodSqlcaCustom("com.tenwa.flow.rent.penalty_reduction_flow.PenaltyReductionFlowAction", "checkPlanIsAdded", JSON.stringify({params: JSON.stringify(params)})); + if(sReturn !== "SUCCESS") { + alert(sReturn.substring(6)); + return; + } planIDs = planIDs.replace(/,/ig, "@"); overPenaltys = overPenaltys.replace(/,/ig, "@"); - var sReturn = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/PenaltyReduction/CheckPlanOverMoney.jsp", "planIDs=" + planIDs + "&flowunid=<%=flowunid%>&overPenaltys=" + overPenaltys); + sReturn = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/PenaltyReduction/CheckPlanOverMoney.jsp", "planIDs=" + planIDs + "&flowunid=<%=flowunid%>&overPenaltys=" + overPenaltys); if ("ERROR" == sReturn) { if (confirm("罚息余额已产生变化,是否以最新的余额自动生成记录?")) { - var sReturn = RunJavaMethodTrans("com.tenwa.flow.rent.rentincome.RentIncomeMethod", "setPenaltyDataToRentIncome", "planIDs=" + planIDs + ",flowunid=<%=flowunid%>,isChanged=Y"); + sReturn = RunJavaMethodTrans("com.tenwa.flow.rent.rentincome.RentIncomeMethod", "setPenaltyDataToRentIncome", "planIDs=" + planIDs + ",flowunid=<%=flowunid%>,isChanged=Y"); if (sReturn == "SUCCESS") { planLists = planLists.split(","); var planList = ""; @@ -56,14 +68,14 @@ } } planList = planList.substring(1); - alert("计划期项为" + planList + "的数据已添加到罚息减免计划中!"); + alert("计划期项为" + planList + "的数据添加到罚息减免明细成功!"); reloadSelf(); } } else { reloadSelf(); } } else { - var sReturn = RunJavaMethodTrans("com.tenwa.flow.rent.rentincome.RentIncomeMethod", "setPenaltyDataToRentIncome", "planIDs=" + planIDs + ",overPenaltys=" + overPenaltys + ",flowunid=<%=flowunid%>,isChanged=N"); + sReturn = RunJavaMethodTrans("com.tenwa.flow.rent.rentincome.RentIncomeMethod", "setPenaltyDataToRentIncome", "planIDs=" + planIDs + ",overPenaltys=" + overPenaltys + ",flowunid=<%=flowunid%>,isChanged=N"); if (sReturn == "SUCCESS") { planLists = planLists.split(","); var planList = ""; @@ -73,7 +85,7 @@ } } planList = planList.substring(1); - alert("计划期项为" + planList + "的数据已添加到罚息减免计划中!"); + alert("计划期项为" + planList + "的数据添加到罚息减免明细成功!"); reloadSelf(); } } diff --git a/src_core/com/tenwa/util/JsonUtil.java b/src_core/com/tenwa/util/JsonUtil.java new file mode 100644 index 000000000..3ac59f083 --- /dev/null +++ b/src_core/com/tenwa/util/JsonUtil.java @@ -0,0 +1,64 @@ +package com.tenwa.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import java.io.IOException; +import java.text.SimpleDateFormat; + +/** + * @program: xdzl-uifm + * @description: + * @author: 鏉庤秴鏉 + * @create: 2023-07-12 11:36 + */ +public class JsonUtil { + + private static ObjectMapper objectMapper = new ObjectMapper(); + static { + objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); +// objectMapper.registerModule(new JavaTimeModule()); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd")); + } + + public static ObjectMapper getObjectMapper() { + return objectMapper; + } + + public static String convertToJson(Object obj) { + try { + return objectMapper.writeValueAsString(obj); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public static T convertToObj(String jsonStr, Class tClass) { + try { + return objectMapper.readValue(jsonStr, tClass); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public static T convertToObj(String xmlStr, TypeReference typeReference) { + try { + return objectMapper.readValue(xmlStr, typeReference); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public static T convertToObj(Object obj, Class tClass) { + return objectMapper.convertValue(obj, tClass); + } + + public static T convertToObj(Object obj, TypeReference typeReference) { + return objectMapper.convertValue(obj, typeReference); + } +} diff --git a/src_tenwa/com/tenwa/flow/rent/penalty_reduction_flow/PenaltyReductionFlowAction.java b/src_tenwa/com/tenwa/flow/rent/penalty_reduction_flow/PenaltyReductionFlowAction.java new file mode 100644 index 000000000..34d10c7ef --- /dev/null +++ b/src_tenwa/com/tenwa/flow/rent/penalty_reduction_flow/PenaltyReductionFlowAction.java @@ -0,0 +1,73 @@ +package com.tenwa.flow.rent.penalty_reduction_flow; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityListHandler; +import cn.hutool.db.sql.SqlBuilder; +import cn.hutool.db.sql.SqlExecutor; +import com.amarsoft.awe.util.Transaction; +import com.fasterxml.jackson.core.type.TypeReference; +import com.tenwa.util.JsonUtil; + +import java.sql.SQLException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @program: apzl_leasing + * @description: + * @author: 李超杰 + * @create: 2024-12-18 11:04 + */ +public class PenaltyReductionFlowAction { + + private String params; + + + /** + * 检查罚息减免租金计划是否已提交 + * @param transaction + * @return + * @throws SQLException + */ + public String checkPlanIsAdded(Transaction transaction) throws SQLException { + Map paramMap = JsonUtil.convertToObj(this.params, new TypeReference>() { + }); + String flowunid = Objects.toString(paramMap.get("flowunid")); + if (StrUtil.isBlank(flowunid)) { + return "ERROR@flowunid不能为空"; + } + String paymentNumber = Objects.toString(paramMap.get("paymentNumber")); + if (StrUtil.isBlank(paymentNumber)) { + return "ERROR@paymentNumber不能为空"; + } + + String planList = Objects.toString(paramMap.get("planLists"), ""); + Object[] planListArr = Arrays.stream(planList.split(",")).filter(StrUtil::isNotBlank).map(Integer::parseInt).toArray(); + if (planListArr.length == 0) { + return "ERROR@planListStr不能为空"; + } + + Map sqlParams = new HashMap<>(); + sqlParams.put("flowunid", flowunid); + sqlParams.put("paymentNumber", paymentNumber); + sqlParams.put("planList", planListArr); + String querySql = "select plan_list from lc_rent_income_temp where flowunid = :flowunid and payment_number = :paymentNumber and plan_list in (:planList)"; + SqlBuilder sqlBuilder = SqlBuilder.of(querySql); + sqlBuilder.addParams(sqlParams); + List entityList = SqlExecutor.query(transaction.getConnection(), sqlBuilder, new EntityListHandler()); + if (entityList.size() > 0) { + String errorPlanListStr = entityList.stream().map(entity -> "【" + entity.getStr("plan_list") + "】").collect(Collectors.joining()); + return "ERROR@租金计划期次" + errorPlanListStr + "已添加,请勿重复添加!"; + } + return "SUCCESS"; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } +}