//党组织上移
"click #main_table_up": function (e, value, row, index) {
var $tr = $(this).parents("tr");
if ($tr.index() == 0) {
$.alert({title: "提示", content: "当前组织中的首行数据不可上移"});
} else {
$tr.fadeOut().fadeIn();
$tr.prev().before($tr);
//党组织上移(数据库写入)
$.ajax({
type: "get",
dataType: "json",//服务器返回的数据类型
url: urlUtils.getRootPath() + "daaOrginfoxController.do?moveUp&id=" + row.id,
success: function (result) {
if (result.success == false) {
partyOrgTable_fun.refreshBootstrapTable();
$.alert({title: "提示", content: "上移失败:" + result.msg});
}
},
error: function () {
$.alert({title: "提示", content: "党组织上移出现异常:" + result.msg});
}
});
}
}
"click #main_table_down": function (e, value, row, index) {
//下移
var $tr = $(this).parents("tr");
if ($tr.index() != -1) {
$tr.fadeOut().fadeIn();
$tr.next().after($tr);
//党组织下移(数据库写入)
$.ajax({
type: "get",
dataType: "json",//服务器返回的数据类型
url: urlUtils.getRootPath() + "daaOrginfoxController.do?moveDown&id=" + row.id,
success: function (result) {
if (result.success == false) {
$.alert({title: "提示", content: "下移失败:" + result.msg});
partyOrgTable_fun.refreshBootstrapTable();
}
},
error: function () {
$.alert({title: "提示", content: "党组织下移出现异常:" + result.msg});
}
});
}
}
/**
* 上移
*
* @param request
* @return
*/
@RequestMapping(params = "moveUp")
@ResponseBody
public AjaxJson moveUp(HttpServletRequest request) {
systemService.addLog("删除党组织成立表单", Globals.Log_Type_OTHER, Globals.Log_Leavel_INFO);
AjaxJson ajaxJson = new AjaxJson();
String id = request.getParameter("id");
DaaOrginfo daaOrginfo = daaOrginfoxServiceI.getEntityById(id);
//查询上一条记录
String daaIdSj = daaOrginfo.getDaaIdSj();
int ordNum = daaOrginfo.getOrdNum();
DaaOrginfo daaOrginfo2 = daaOrginfoxServiceI.getPrevEntity(daaIdSj, ordNum);
//最上面的不能上移
if (null == daaOrginfo2) {
ajaxJson.setSuccess(false);
ajaxJson.setMsg("最上面的不能上移");
return ajaxJson;
}
//交换ord_num的值
int temp = daaOrginfo.getOrdNum();
daaOrginfo.setOrdNum(daaOrginfo2.getOrdNum());
daaOrginfo2.setOrdNum((short) temp);
//更新到数据库中
daaOrginfoxServiceI.update(daaOrginfo);
daaOrginfoxServiceI.update(daaOrginfo2);
return ajaxJson;
}
/**
* 下移
*
* @param request
* @return
*/
@RequestMapping(params = "moveDown")
@ResponseBody
public AjaxJson moveDown(HttpServletRequest request) {
systemService.addLog("删除党组织成立表单", Globals.Log_Type_OTHER, Globals.Log_Leavel_INFO);
AjaxJson ajaxJson = new AjaxJson();
String id = request.getParameter("id");
DaaOrginfo daaOrginfo = daaOrginfoxServiceI.getEntityById(id);
//查询下一条记录
String daaIdSj = daaOrginfo.getDaaIdSj();
int ordNum = daaOrginfo.getOrdNum();
DaaOrginfo daaOrginfo2 = daaOrginfoxServiceI.getNextEntity(daaIdSj, ordNum);
//最下面的不能上移
if (null == daaOrginfo2) {
ajaxJson.setSuccess(false);
ajaxJson.setMsg("最下面的不能上移");
return ajaxJson;
}
//交换ord_num的值
int temp = daaOrginfo.getOrdNum();
daaOrginfo.setOrdNum(daaOrginfo2.getOrdNum());
daaOrginfo2.setOrdNum((short) temp);
//更新到数据库中
daaOrginfoxServiceI.update(daaOrginfo);
daaOrginfoxServiceI.update(daaOrginfo2);
return ajaxJson;
}
4.1、查询上一条记录
--上移-获取上一条数据的SQL语句
SELECT *
FROM (SELECT F.*
FROM DAA_ORGINFO F
WHERE F.DAA_ID_SJ = '1-02-002' AND F.ORD_NUM < 12
ORDER BY F.ORD_NUM DESC)
WHERE ROWNUM = 1 ;
<!-- 获取上一条记录 -->
<select id="getPrevEntity" resultType="com.ctg.pbis.partymanage.daaorginfo_x.entity.DaaOrginfo">
SELECT *
FROM (SELECT *
FROM DAA_ORGINFO
WHERE DAA_ID_SJ = #{daaIdSj,jdbcType=VARCHAR} AND ORD_NUM < #{ordNum,jdbcType=INTEGER}
ORDER BY ORD_NUM DESC)
WHERE ROWNUM = 1
</select>
4.2、查询下一条记录
--下移-获取下一条数据的SQL语句
SELECT *
FROM (SELECT F.*
FROM DAA_ORGINFO F
WHERE F.DAA_ID_SJ = '1-02-002' AND F.ORD_NUM > 12
ORDER BY F.ORD_NUM ASC)
WHERE ROWNUM = 1 ;
<!-- 获取下一条记录 -->
<select id="getNextEntity" resultType="com.ctg.pbis.partymanage.daaorginfo_x.entity.DaaOrginfo">
SELECT *
FROM (SELECT *
FROM DAA_ORGINFO
WHERE DAA_ID_SJ = #{daaIdSj,jdbcType=VARCHAR} AND ORD_NUM > #{ordNum,jdbcType=INTEGER}
ORDER BY ORD_NUM ASC)
WHERE ROWNUM = 1
</select>