后端
一. 插入\更新一条数据(老)
Map<String, Object> parameterMap = MybatisUtil.initParameterSave("Send_ProjectFrozenLog", sendProjectFrozenLog);
commonMapper.insert(parameterMap);
parameterMap = MybatisUtil.initParameterSave("Send_ProjectFrozenLog", sendProjectFrozenLog);
commonMapper.update(parameterMap);
二. Service里面方法的注解(老)
@Transactional(readOnly = false,propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
“readOnly = false ” 这个需要注意有没有写,以上问题源于铜陵派单pc端施工环节和勘察环节冻结和解冻功能,数据库sql输出但是数据库没有变化。原因一:查询冻结日志的Sysyguid的时候,projectNo写成了projectNO。原因二:至今不知道为什么新写的方法没有执行,大概跟框架有关,使用框架的insert和update方法。
三.新框架SpringBoot中有一些Dao可以直接使用一些方法
Project sendProjectInfo = projectDao.selectByPrimaryKey(projectNo);
projectDao.updateByPrimaryKeySelective(sendProjectInfo);
以上问题源于铜陵派单app端施工环节和勘察环节冻结和解冻功能,在任一Mapper中如果使用自己写的sql更新send_projectInfo表,会启动失败。使用框架中方法不会
四.mapper文件格式
1.老框架
<select id="id" parameterType="String" resultType="String">
<![CDATA[
SELECT sysGuid
FROM (
SELECT sysGuid
FROM ${@Send_ProjectFrozenLog}
WHERE projectNo = #{projectNo}
ORDER BY frozenDate DESC, frozenTime DESC
)
WHERE ROWNUM = 1
]]>
</select>
表:
${@Send_Flow_SysConf}
2.新框架
<select id="queryLatestSendProjectFrozenLogSysGuid" parameterType="string" resultType="String">
<![CDATA[
SELECT sysGuid
FROM (
SELECT sysGuid
FROM Send_ProjectFrozenLog
WHERE projectNo = #{projectNo}
ORDER BY frozenDate DESC, frozenTime DESC
)
WHERE ROWNUM = 1
]]>
</select>
表:
Send_ProjectFrozenLog
3.差不多的
parameterType,resultType:
1.com.bestvike.modules.rfis.core.send.model.sendProjectFrozenLog
2.SendProjectInfo
3.map
4.String
用法:
1.set:
<set>
<if test="reconState !=null and reconState !=''">
reconState=#{reconState},
</if>
<if test="reconPredictDate !=null and reconPredictDate !=''">
reconPredictDate = #{reconPredictDate},
</if>
<if test="reconExpireDate !=null and reconExpireDate !=''">
reconExpireDate = #{reconExpireDate},
</if>
<if test="repairState !=null and repairState !=''">
repairState=#{repairState},
</if>
<if test="repairPredictDate !=null and repairPredictDate !=''">
repairPredictDate = #{repairPredictDate},
</if>
<if test="repairExpireDate !=null and repairExpireDate !=''">
repairExpireDate = #{repairExpireDate}
</if>
</set>
五. 获取前端的值
框架封装了是后端控制文件里定义并且写方法就可以读取前端的值。
也可以:httpServletRequest.getParameter(“JSKey”)
六. 新框架查询 不用写sql就可以查到某个实体类从而查到某个值
Example example = new Example(SysParameter.class);
example.createCriteria().andEqualTo("configName", "reconValidDays");
SysParameter sysParameter = sysParameterDao.selectOneByExample(example);
String repairExploreDays = sysParameter.getValue();
七. 新框架和老框架获取用户
新:
sendProjectFrozenLog.setThawDate(DateUtil.getDate());
sendProjectFrozenLog.setThawTime(DateUtil.getTime());
sendProjectFrozenLog.setThawUserId(user.getId());
sendProjectFrozenLog.setThawUserName(user.getName());
老:
sendProjectFrozenLog.setThawDate(DateUtil.getDate());
sendProjectFrozenLog.setThawTime(DateUtil.getTime());
sendProjectFrozenLog.setThawUserId(SessionThread.getUserId());
sendProjectFrozenLog.setThawUserName(SessionThread.getUserId());
八. 打包
使用notepad++编辑批处理文件updateFile-GitOrSvn0919.bat
updateFile-GitOrSvn0919.bat:
通过百度网盘分享的文件:updateFile-GitOrSvn0919.bat
链接:https://pan.baidu.com/s/1Zgf9hy7gwV3IdXGMg6aeVw
提取码:o6a3
notepad++:
通过百度网盘分享的文件:Notepad++.lnk
链接:https://pan.baidu.com/s/1F5EEX1uUmrt2BmBOMlOcXQ
提取码:7e71
,然后保存之后双击运行
去目标文件查看
按照规范命名整理
九. 环境配置
1.maven(tomcat ----strust\spring)
apache-maven-3.8.5:
通过百度网盘分享的文件:apache-maven-3.8.5.zip
链接:https://pan.baidu.com/s/1Mc2FSnUNWMnKCQnS_BpjIA
提取码:h735
-Dfile.encoding=utf-8
D:\apache-maven-3.8.5\conf\settings_bestvike.xml
D:\apache-maven-3.8.5\maven_repository
2.gradle(Application—springboot)
gradle-6.8.3:
通过百度网盘分享的文件:gradle-6.8.3.rar
链接:https://pan.baidu.com/s/1NTIRpVv35MCwtajLXmMa_w
提取码:53af
十. sql用法
1.instr
判断后面字符串是否包含在前面的字符串,如果是返回大于0的数,最终返回true
instr(sfi.steprole2, sfd.rolecode) > 0
2.listagg
把某个字段按照分组聚合起来用某个字符连接
listagg( t.value, ';') within GROUP(order by t.projecttype)
3.decode
判断某个字段(b)是否是某个值从而返回不同字段(a1\a2)
decode(p.ispecial, 'Y', p.ispeRegionName, p1.regionName) AS regionName:
p.ispecial: 这是第一个参数,代表要检查的值。
‘Y’: 这是第二个参数,代表要比较的值。
p.ispeRegionName: 如果 p.ispecial 等于 ‘Y’,则 DECODE 函数返回这个值。
p1.regionName: 如果 p.ispecial 不等于 ‘Y’,则 DECODE 函数返回这个值。
4.如果时间是date或者时间戳类型(年月日时分秒)但是取(年月日字符串类型)
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') AS date_string FROM dual;
5. extract
是一个SQL函数,用于从日期/时间值中提取特定的部分,如年、月、日、小时、分钟或秒。
SELECT EXTRACT(YEAR FROM timestamp_column) FROM my_table;
5. wm_concat
to_char(wm_concat(t.itemType)) as itemType
是Oracle数据库中的一个函数,它用于将多个字符串连接成一个单一的字符串,每个字符串之间用指定的分隔符隔开(默认是逗号,)。这个函数通常用于聚合操作,它会将分组中的多个值合并成一个字符串。
6. nvl
nvl( t1.inspectedtities, 0 )
处理空值,如果是空值就返回0
7. case when
---报修阶段审核中
UPDATE send_PROJECTINFO epi
SET epi.nodeSummary = CASE
WHEN epi.busiNode = '1' AND epi.nodeStatus = '1' THEN (
SELECT CASE
WHEN rac.step = '2' THEN '维修资金审核中'
WHEN rac.step = '3' THEN '报修信息审核中'
ELSE '报修阶段审核中'
END
FROM (
SELECT sfr.businesskey, sfr.step, sfr.flowName, ad.auditFlag
FROM Send_Flow_RunInstance sfr
left join (
SELECT businesskey , auditFlag, flowName
FROM (
SELECT businesskey, auditFlag, auditDate, auditTime, flowName,
ROW_NUMBER() OVER (PARTITION BY businesskey ORDER BY auditDate DESC, auditTime DESC) AS rn
FROM Send_Flow_AuditDetail
)
WHERE rn = 1
) ad ON sfr.businesskey = ad.businesskey and sfr.flowName = ad.flowName
) rac
WHERE rac.businesskey = epi.projectNo and rac.flowName='repair_process'
)
ELSE '报修阶段审核中'
END
WHERE epi.busiNode = '1' AND epi.nodeStatus = '1'
;
---项目终止
UPDATE send_PROJECTINFO epi
SET epi.nodeSummary = CASE
WHEN epi.busiNode = 'S' AND epi.nodeStatus = '3' THEN (
SELECT CASE
WHEN rac.flowName='reconnaissance_back_process' AND rac.auditFlag='Y' THEN'项目终止(勘察阶段退单)'
WHEN rac.flowName='receipt_back_process' AND rac.auditFlag='Y' THEN '项目终止(施工阶段退单)'
WHEN rac.flowName='repair_process' and rac.step='2' and rac.auditFlag='N' AND rac.roleCode='42' THEN '项目终止(维修资金审核不通过)'
WHEN rac.flowName='repair_process' and rac.auditFlag='S' and epi.isRepeat='Y' THEN '项目终止(重复报修)'
WHEN rac.flowName='repair_process' and rac.auditFlag='S' and epi.isOrigin='Y' and epi.originStatus='6' THEN '项目终止(原点且原企业能修)'
WHEN rac.flowName='repair_process' and rac.auditFlag='S' and epi.isOrigin='Y' and epi.originStatus='7' THEN '项目终止(原企业无法维修)'
ELSE '项目终止(报修信息审核不通过)'
END
FROM (
select t.businesskey, t.step, t.flowName, t.auditFlag,t.roleCode
from (
SELECT sfr.businesskey, sfr.step, sfr.flowName, ad.auditFlag,ad.roleCode,
ROW_NUMBER() OVER (PARTITION BY sfr.businesskey ORDER BY sfr.LASTTIME DESC) AS rn
FROM Send_Flow_RunInstance sfr
left join (
SELECT businesskey , auditFlag, flowName,roleCode
FROM (
SELECT businesskey, auditFlag, auditDate, auditTime, flowName,roleCode,
ROW_NUMBER() OVER (PARTITION BY businesskey ORDER BY auditDate DESC, auditTime DESC) AS rn
FROM Send_Flow_AuditDetail
)
WHERE rn = 1
) ad ON sfr.businesskey = ad.businesskey and sfr.flowName = ad.flowName
)t
where t.rn=1
) rac
WHERE rac.businesskey = epi.projectNo
)
ELSE '项目终止'
END
WHERE epi.busiNode = 'S' AND epi.nodeStatus = '3'
;
前端
一. 调用后台方法
1.grid里gridTriggerConfirm ----- ajax
action="gridTriggerConfirm('float', '_parent',
{projectNo: '#projectNo#',busiNode: '#busiNode#', _title:'请确认'},
null, undefined, '您确定要提交该条施工信息吗?', submitRepairInfo)"/>
function submitRepairInfo(param) {
var projectNo = param.projectNo;
var busiNode = param.busiNode;
var nodeStatus = param.nodeStatus;
showProgress();
$.ajax({
type: 'post',
url: 'submitRepairInfo.bv',
data: {'projectNo': projectNo,'busiNode':busiNode,'nodeStatus':nodeStatus},
success: function(jsonData) {
if (!$.isEmpty(jsonData.promptInfo.showType)) {
showPrompt(jsonData.promptInfo.showType, jsonData.promptInfo.showMsg);
} else {
showPrompt("操作成功!");
}
hideProgress();
gridRefresh();
}
});
}
2.grid里gridTriggerFrame点击出现弹窗
直接进入jsp
action="gridTriggerFrame('float', '_self',
{projectNo: '#projectNo#',flag: 'repair', _title:'冻结项目'},
'modules/rfis/core/send/project/freezeProject.jsp', 500, 180,false,window)" />
先调用后端再进入jsp(有初始化回显得值)
action="gridTriggerFrame('float', '_self',
{projectNo: '#projectNo#',CorpName: '#CorpName#',regionName: '#regionName#',
bldName: '#bldName#',address:'#address#',roomNo:'#showName#',corpNo:'#corpNo#',
_title:'施工回单维护'}, 'queryProMessMainById.bv?flag=sg', 1300, 900)" />
弹窗中含有表单情况就是看下面form表单介绍
3.form表单
<form id="freezeForm" method="post" action="freezeProject.bv">
<div class="operateDiv">
<bv:button name="save" id="save" value="确认冻结"/>
<bv:button id="cancel" name="cancel" cssClass="closeModal" value="取消"/>
</div>
</form>
<head>
<%@include file="/modules/common/head.jsp" %>
<bv:define extra="date,auto" close="true" focusId="false"/>
<script type="text/javascript">
$(document).ready(function () {
$("#save").click(function () {
$.submit($(this), $(this).parents("form"), "false", {success: beforeSubmitSuccess});
});
});
function beforeSubmitSuccess(data){
showPrompt("操作成功!");
top.frameContent.gridAjax(undefined, true); // 刷新父页面
top.uiDialog("close", "iframe", window); // 关闭当前页面
};
</script>
</head>
二. 点击调用后端接口校验
在原本bv方法中,添加校验如果失败就提示错误信息(框架自带),如果校验成功就继续往下走
function submitProjectApplication(param) {
var projectNo = param.projectNo;
showProgress();
$.ajax({
type: 'post',
url: 'submitProjectApplication.bv',
data: {'projectNo': projectNo},
success: function(jsonData) {
if (!$.isEmpty(jsonData.promptInfo.showType)) {
showPrompt(jsonData.promptInfo.showType, jsonData.promptInfo.showMsg);
} else {
showPrompt("操作成功!");
}
hideProgress();
gridRefresh();
}
});
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void submitProjectApplication(String projectNo, PromptInfo promptInfo, FlowProgress flowProgress) {
//判断必填文档是否上传
boolean isUploadFile = true;
List<DicDocType> docTypeList = sendMapper.listRequiredDocTypeByBusiType("1201");
for (DicDocType dicDocType : docTypeList) {
List<ArcUploadFile> uploadFileList = sendMapper.listUploadFilesByDocTypeAndKeyId(projectNo, dicDocType.getDocType());
if (uploadFileList.isEmpty()) {
isUploadFile = false;
promptInfo.setShowType("error");
promptInfo.setShowMsg("存在相关必填图档未维护,无法提交");
break;
}
}