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


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

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

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

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

    1. /**
    2. * @Description 更新上报状态
    3. * @param
    4. * @return
    5. * @Author ying.wang1
    6. * @Date 2022年03月14日 上午11:07:16
    7. */
    8. int updateReportStatusByBusIds(@Param("reportStatus")int reportStatus, @Param("list") List list);

    三、mapper层写sql。

    1、添加字段。

    1. "reportStatus" property="reportStatus" jdbcType="VARCHAR" />

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

    1. "Base_Column_List" >
    2. modifyTime,claimTypeId
    3. orgCode, isDelete, createrId, createrName, createTime, modifierId, modifierName,
    4. modifyTime,claimTypeId, reportStatus

    3、查询条件添加字段。

    1. <!-- 查询纠纷列表-->
    2. <select id="queryDsDetailList" resultType="com.pcitc.slms.ds.system.dto.DsDetailDto" parameterType="java.util.Map" >
    3. select
    4. dsd.dsDetailId,
    5. dsd.endCaseReduce,
    6. dsd.createTime,
    7. dsd.reportStatus,
    8. group_concat(DISTINCT dsl.lawyerName) as lawyerNames,
    9. group_concat(DISTINCT CASE WHEN dsp.legalStatus = 1 THEN dsp.partyName END) as sourceMan,
    10. LEFT JOIN ds_party dsp on dsd.dsDetailId = dsp.dsDetailId and dsp.isDelete = 0
    11. where dsd.isDelete = 0
    12. <if test="disputesBeginTime != null and disputesBeginTime != ''">
    13. and dsd.disputesBeginTime &gt;= #{disputesBeginTime,jdbcType=TIMESTAMP}
    14. </if>
    15. <if test="disputesEndTime != null and disputesEndTime != ''">
    16. and dsd.disputesBeginTime &lt;= #{disputesEndTime,jdbcType=TIMESTAMP}
    17. </if>
    18. <if test="reportStatus != null and reportStatus != ''">
    19. and dsd.reportStatus = #{reportStatus,jdbcType=VARCHAR}
    20. </if>
    21. GROUP BY dsd.dsDetailId
    22. order by createTime desc

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

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

    四、service接口。

    1. /**
    2. * @Description 上报纠纷信息
    3. * @param
    4. * @return
    5. * @Author ying.wang1
    6. * @Date 2022年03月14日 上午09:18:47
    7. */
    8. boolean disputeUp(List ids);

    五、Impl实现。

    1. @Override
    2. @Transactional(rollbackFor = Exception.class)
    3. public boolean disputeUp(List ids) {
    4. DsDetailDto disputeList = new DsDetailDto();
    5. //调用成功后将状态改为上报成功
    6. int num = dsDetailDao.updateReportStatusByBusIds(1,ids);
    7. if(num > 0){
    8. return true;
    9. }else{
    10. return false;
    11. }
    12. }

    六、controller接口。

    1. /**上报纠纷信息
    2. * @param [ids]
    3. * @author t-aiai.gao
    4. * @date 2022/9/9 14:20
    5. * @return com.pcitc.slms.common.dto.ResultInfoDTO
    6. **/
    7. @RequestMapping(value = "/disputeUp", method = RequestMethod.POST)
    8. public ResultInfoDTO disputeUp(@RequestBody List ids){
    9. ResultInfoDTO infoDTO = new ResultInfoDTO();
    10. if(CollectionUtils.isNotEmpty(ids)){
    11. log.info("上报纠纷信息开始===================>");
    12. boolean result = dsDetailService.disputeUp(ids);
    13. infoDTO.setReturnValue(true);
    14. infoDTO.setData(result);
    15. infoDTO.setMsg("上报纠纷信息成功!");
    16. log.info("上报纠纷信息结束====================>");
    17. }
    18. return infoDTO;
    19. }

    七、前端页面之html。

    1. class="ivu-form-item-content-x-lg">
    2. <button class="ipt-btn btnprimary mr5" type="button"
    3. onclick="upData()">上报
    4. button>
  • 八、前端页面之js。

    1、点击上报。

    1. //点击上报
    2. function upData() {
    3. var checkVal = $("input[name='choseUp']:checked").val();
    4. var choseYesIds = $("#ds-up-list").jqGrid('getGridParam', 'selarrrow');
    5. console.log(choseYesIds)
    6. var allIds = $("#ds-up-list").getDataIDs();
    7. //已选中;未选中
    8. if(checkVal == 1){
    9. if(choseYesIds.length <= 0) {
    10. layer.confirm("请至少选中一条数据!", {
    11. icon: 2,
    12. title: '提示'
    13. },
    14. function (e) {
    15. layer.close(e);
    16. });
    17. }else{
    18. disputeUp(choseYesIds)
    19. }
    20. }else if(checkVal == 0){
    21. var choseNoIds = allIds.filter(function (val) { return !(choseYesIds.indexOf(val) > -1) })
    22. .concat(choseYesIds.filter(function (val) { return !(allIds.indexOf(val) > -1) }))
    23. disputeUp(choseNoIds)
    24. }
    25. }

    2、调用接口。

    1. //调用上报后台接口
    2. function disputeUp(ids) {
    3. if(ids.length > 0){
    4. layer.confirm("确定上报?", {
    5. icon: 3,
    6. title: '提示'
    7. },
    8. function () {
    9. $.ajax({
    10. type: "POST",
    11. contentType: "application/json",
    12. url: "/请求名称/请求路径/请求方法",
    13. dataType: "json",
    14. data: JSON.stringify(ids),
    15. success: function (data) {
    16. if (data && data.returnValue) {
    17. layer.msg("上报成功", {time: 1500, icon: 1}, function () {
    18. 刷新本表
    19. });
    20. } else {
    21. layer.msg(data.msg, {time: 2000, icon: 2}, function () {
    22. 刷新另一个表
    23. });
    24. }
    25. },
    26. error: function () {
    27. layer.msg("上报异常", {time: 2000, icon: 2}, function () {
    28. 刷新本表
    29. });
    30. },
    31. });
    32. });
    33. }else{
    34. layer.confirm("请至少选中一条数据!", {
    35. icon: 2,
    36. title: '提示'
    37. },
    38. function (e) {
    39. layer.close(e);
    40. });
    41. }
    42. }

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

  • 相关阅读:
    Elasticsearch与Sping Data框架的集成
    小分子化合物在重编程中的应用
    在.NET程序中整合微软的Playwright,使用 Playwright 的最佳实践和技巧
    Reactor 之 手把手教你 Spring Boot 整合 Reactor
    systemverilog中@和wait的区别
    杰理-watch-更新状态到APP
    JDK1.8对HashMap的优化、以及通过源码解析1,8扩容机制
    C++笔记之引用折叠规则
    Selenium自动化测试面试题全家桶
    极智AI | 讲解 TensoRT Activation 算子
  • 原文地址:https://blog.csdn.net/m0_64818669/article/details/126783009