un9.9:实现上报及上报状态修改功能。

本文详细介绍了如何从数据库设计、DAO接口、Mapper SQL到前端页面的交互,演示了如何通过Java技术更新报告状态并完成前端上报功能的完整流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目中,我们经常会遇到上报数据的功能,今天小编就和大家从数据库到后端,再从后端到前端页面,一起实现这一功能。

逻辑:首先我需要查询表中的数据,查询到后再进行修改,修改的同时,状态也会修改。

一、我们首先设计数据库,命名规范,命名字段这些我就不多说了,只截取这一部分字段。

 二、dao层写修改状态的接口。

/**
	 * @Description 更新上报状态
	 * @param
	 * @return
	 * @Author ying.wang1
	 * @Date 2022年03月14日 上午11:07:16
	 */
	int updateReportStatusByBusIds(@Param("reportStatus")int reportStatus, @Param("list") List<String> list);

三、mapper层写sql。

1、添加字段。

<resultMap>
    <result column="reportStatus" property="reportStatus" jdbcType="VARCHAR" />
</resultMap>

2、sql上添加字段,我没写全部的字段,只写了部分。

<sql id="Base_Column_List" >
		modifyTime,claimTypeId
		orgCode, isDelete, createrId, createrName, createTime, modifierId, modifierName,
		modifyTime,claimTypeId, reportStatus
	</sql>

3、查询条件添加字段。

<!-- 查询纠纷列表-->
	<select id="queryDsDetailList" resultType="com.pcitc.slms.ds.system.dto.DsDetailDto" parameterType="java.util.Map" >
		select
		dsd.dsDetailId,
		dsd.endCaseReduce,
		dsd.createTime,
		dsd.reportStatus,
		group_concat(DISTINCT dsl.lawyerName) as lawyerNames,
		group_concat(DISTINCT CASE WHEN  dsp.legalStatus = 1 THEN dsp.partyName  END) as sourceMan,
		LEFT JOIN ds_party dsp  on dsd.dsDetailId = dsp.dsDetailId and dsp.isDelete = 0
		where dsd.isDelete = 0
<if test="disputesBeginTime != null and disputesBeginTime != ''">
			and dsd.disputesBeginTime &gt;= #{disputesBeginTime,jdbcType=TIMESTAMP}
		</if>
		<if test="disputesEndTime != null and disputesEndTime != ''">
			and dsd.disputesBeginTime &lt;= #{disputesEndTime,jdbcType=TIMESTAMP}
		</if>
		<if test="reportStatus != null and reportStatus != ''">
			and dsd.reportStatus = #{reportStatus,jdbcType=VARCHAR}
		</if>
		GROUP BY dsd.dsDetailId
		order by createTime desc

4、更新上报信息(对应刚才dao的接口)。

<!-- 更新上报状态信息-->
	<update id="updateReportStatusByBusIds" parameterType="com.pcitc.slms.ds.system.entity.DsDetail" >
		update ds_detail
		<set >
			<if test="reportStatus != null" >
				reportStatus = #{reportStatus,jdbcType=VARCHAR},
			</if>
		</set>
		where dsDetailId in
		<foreach collection="list" index="index" item="id" separator="," close=")" open="(">
			#{id}
		</foreach>
	</update>

四、service接口。

/**
	 * @Description 上报纠纷信息
	 * @param
	 * @return
	 * @Author ying.wang1
	 * @Date 2022年03月14日 上午09:18:47
	 */
	boolean disputeUp(List<String> ids);

五、Impl实现。

@Override
	@Transactional(rollbackFor = Exception.class)
	public boolean disputeUp(List<String> ids) {
		DsDetailDto disputeList = new DsDetailDto();
		//调用成功后将状态改为上报成功
		int num = dsDetailDao.updateReportStatusByBusIds(1,ids);
		if(num > 0){
			return true;
		}else{
			return false;
		}
	}

六、controller接口。

/**上报纠纷信息
	* @param [ids]
	* @author t-aiai.gao
	* @date 2022/9/9 14:20
	* @return com.pcitc.slms.common.dto.ResultInfoDTO<java.lang.Boolean>
	**/
	@RequestMapping(value = "/disputeUp", method = RequestMethod.POST)
	public ResultInfoDTO<Boolean> disputeUp(@RequestBody List<String> ids){
		ResultInfoDTO<Boolean> infoDTO = new ResultInfoDTO<Boolean>();
		if(CollectionUtils.isNotEmpty(ids)){
			log.info("上报纠纷信息开始===================>");
			boolean result = dsDetailService.disputeUp(ids);
			infoDTO.setReturnValue(true);
			infoDTO.setData(result);
			infoDTO.setMsg("上报纠纷信息成功!");
			log.info("上报纠纷信息结束====================>");
		}
		return infoDTO;
	}

七、前端页面之html。

<div class="ivu-form-item-content-x-lg">
                                <!--<div class="input-radio-box">-->
                                    <!--业务暂未开放,确认后开放
                                    <input class="ipt-type mr3" type="radio" name="choseUp"
                                           value="1" checked/>已选中
                                    <input class="ipt-type mr3" style="margin-left: 10px;" type="radio"
                                           name="choseUp" value="0" />未选中-->
                                    <button class="ipt-btn btnprimary mr5" type="button"
                                            onclick="upData()">上报
                                    </button>
                                <!--</div>-->
                            </div>

八、前端页面之js。

1、点击上报。

//点击上报
function upData() {
    var checkVal = $("input[name='choseUp']:checked").val();
    var choseYesIds = $("#ds-up-list").jqGrid('getGridParam', 'selarrrow');
    console.log(choseYesIds)
    var allIds = $("#ds-up-list").getDataIDs();
    //已选中;未选中
    if(checkVal == 1){
        if(choseYesIds.length <= 0) {
            layer.confirm("请至少选中一条数据!", {
                    icon: 2,
                    title: '提示'
                },
                function (e) {
                    layer.close(e);
                });
        }else{
            disputeUp(choseYesIds)
        }
    }else if(checkVal == 0){
        var choseNoIds = allIds.filter(function (val) { return !(choseYesIds.indexOf(val) > -1) })
            .concat(choseYesIds.filter(function (val) { return !(allIds.indexOf(val) > -1) }))
        disputeUp(choseNoIds)
    }
}

2、调用接口。

//调用上报后台接口
function disputeUp(ids) {
    if(ids.length > 0){
        layer.confirm("确定上报?", {
                icon: 3,
                title: '提示'
            },
            function () {
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "/请求名称/请求路径/请求方法",
            dataType: "json",
            data: JSON.stringify(ids),
            success: function (data) {
                if (data && data.returnValue) {
                    layer.msg("上报成功", {time: 1500, icon: 1}, function () {
                        刷新本表
                    });
                } else {
                    layer.msg(data.msg, {time: 2000, icon: 2}, function () {
                        刷新另一个表
                    });
                }
            },
            error: function () {
                layer.msg("上报异常", {time: 2000, icon: 2}, function () {
                    刷新本表
                });
            },
        });
    });
    }else{
        layer.confirm("请至少选中一条数据!", {
                icon: 2,
                title: '提示'
            },
            function (e) {
                layer.close(e);
            });
    }

}

如此,便能实现上报功能了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小格子衬衫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值