洪城义警-正式版后台
tangzy
2021-11-03 e9504664a87d9960646899803028989c15823753
1.任务
1 files modified
9 files added
617 ■■■■■ changed files
src/main/java/org/springblade/common/config/BladeConfiguration.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/controller/TaskqdController.java 186 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/dto/TaskqdDTO.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/entity/Taskqd.java 132 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/mapper/TaskqdMapper.java 39 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/mapper/TaskqdMapper.xml 48 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/service/ITaskqdService.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/service/impl/TaskqdServiceImpl.java 55 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/vo/TaskqdVO.java 37 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/taskqd/wrapper/TaskqdWrapper.java 46 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/config/BladeConfiguration.java
@@ -101,6 +101,7 @@
        secureRegistry.excludePathPatterns("/comment/**");
        secureRegistry.excludePathPatterns("/collect/**");
        secureRegistry.excludePathPatterns("/investigate/**");
        secureRegistry.excludePathPatterns("/taskqd/**");
        return secureRegistry;
    }
src/main/java/org/springblade/modules/taskqd/controller/TaskqdController.java
New file
@@ -0,0 +1,186 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.task.service.ITaskService;
import org.springblade.modules.task.vo.TaskVO;
import org.springblade.modules.task.wrapper.TaskWrapper;
import org.springblade.modules.taskqd.entity.Taskqd;
import org.springblade.modules.taskqd.service.impl.TaskqdServiceImpl;
import org.springblade.modules.taskqd.vo.TaskqdVO;
import org.springblade.modules.taskqd.wrapper.TaskqdWrapper;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
/**
 * 控制器
 *
 * @author BladeX
 * @since 2020-08-06
 */
@RestController
@AllArgsConstructor
@RequestMapping("/taskqd")
@Api(value = "", tags = "接口")
public class TaskqdController extends BladeController {
    private final TaskqdServiceImpl taskqdService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入task")
    public R<TaskqdVO> detail(Taskqd taskqd) {
        Taskqd detail = taskqdService.getOne(Condition.getQueryWrapper(taskqd));
        return R.data(TaskqdWrapper.build().entityVO(detail));
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入task")
    public R<IPage<TaskqdVO>> list(Taskqd taskqd, Query query) {
        IPage<Taskqd> pages = taskqdService.page(Condition.getPage(query), Condition.getQueryWrapper(taskqd));
        return R.data(TaskqdWrapper.build().pageVO(pages));
    }
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入task")
    public R save(@Valid @RequestBody Taskqd taskqd) {
        return R.status(taskqdService.save(taskqd));
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入task")
    public R update(@Valid @RequestBody Taskqd taskqd) {
        return R.status(taskqdService.updateById(taskqd));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入task")
    public R submit(@Valid @RequestBody Taskqd taskqd) {
        return R.status(taskqdService.saveOrUpdate(taskqd));
    }
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(taskqdService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 抢单
     */
    @PostMapping("/Graborder")
    public R Graborder(@Valid @RequestBody Taskqd taskqd) {
        List<Taskqd> list = taskqdService.selectList(taskqd.getId());
        //总数
        Integer jnum = list.get(0).getJnum();
        //人数
        Integer num = list.get(0).getNum();
        boolean empty = StringUtil.isEmpty(list.get(0).getSerid());
        if (num == jnum) {
            return R.success("抢单失败");
        } else {
            if (num == jnum - 1) {
                int i = num + 1;
                String serid = taskqd.getSerid();
                String serid2 = list.get(0).getSerid();
                String substring = serid2.substring(0, serid.length() - 1);
                String s = serid + substring;
                if (empty==true){
                    taskqdService.updatet(taskqd.getId(), i, s);
                    return R.success("抢单成功");
                }
                else {
                    String ser = taskqd.getSerid();
                    String ser2 = list.get(0).getSerid();
                    String sub = ser2.substring(0, serid.length() - 1);
                    String ss = ser + sub;
                    taskqdService.updatet(taskqd.getId(), i, ss);
                    return R.success("抢单成功");
                }
            } else {
                int i = num + 1;
                String serid = taskqd.getSerid();
                if (empty==true){
                    taskqdService.updatet(taskqd.getId(), i, serid);
                    return R.success("抢单成功");
                }
                else {
                    String serid1 = list.get(0).getSerid();
                    String s = serid + serid1;
                    taskqdService.updatet(taskqd.getId(), i, s);
                    return R.success("抢单成功");
                }
            }
        }
    }
    /**
     * 查询任务
     * @param type
     * @param serid
     * @return
     */
    @PostMapping("/selectLi")
    public R selectLi(String type,String serid) {
        return R.data(taskqdService.selectLi(type,serid));
    }
}
src/main/java/org/springblade/modules/taskqd/dto/TaskqdDTO.java
New file
@@ -0,0 +1,35 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.taskqd.entity.Taskqd;
/**
 * 数据传输对象实体类
 *
 * @author BladeX
 * @since 2020-08-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class TaskqdDTO extends Taskqd {
    private static final long serialVersionUID = 1L;
}
src/main/java/org/springblade/modules/taskqd/entity/Taskqd.java
New file
@@ -0,0 +1,132 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * 实体类
 *
 * @author BladeX
 * @since 2020-08-06
 */
@Data
@TableName("sys_taskqd")
@ApiModel(value = "Taskqd对象", description = "Taskqd对象")
public class Taskqd implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 任务标题
     */
    @ApiModelProperty(value = "任务标题")
    private String rname;
    /**
     * 任务内容
     */
    @ApiModelProperty(value = "任务内容")
    private String content;
    /**
     * 任务时间
     */
    @ApiModelProperty(value = "任务时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String time;
    /**
     * 省
     */
    @ApiModelProperty(value = "省")
    private String province;
    /**
     * 城市
     */
    @ApiModelProperty(value = "城市")
    private String city;
    /**
     * 区县
     */
    @ApiModelProperty(value = "区县")
    private String district;
    /**
     * 接受总数
     */
    @ApiModelProperty(value = "接受总数")
    private Integer jnum;
    /**
     * 路线
     */
    @ApiModelProperty(value = "路线")
    private String line;
    /**
     * 任务地点
     */
    @ApiModelProperty(value = "任务地点")
    private String raddress;
    /**
     * 任务类型
     */
    @ApiModelProperty(value = "任务类型")
    private String rtype;
    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id")
    private String serid;
    /**
     * 人数
     */
    @ApiModelProperty(value = "人数")
    private Integer num;
    /**
     * 积分
     */
    @ApiModelProperty(value = "积分")
    private String integral;
    /**
     * 图片
     */
    @ApiModelProperty(value = "图片")
    private String url;
}
src/main/java/org/springblade/modules/taskqd/mapper/TaskqdMapper.java
New file
@@ -0,0 +1,39 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.bytedeco.javacpp.presets.opencv_core;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.task.vo.TaskVO;
import org.springblade.modules.taskqd.entity.Taskqd;
import java.util.List;
/**
 *  Mapper 接口
 *
 * @author BladeX
 * @since 2020-08-06
 */
public interface TaskqdMapper extends BaseMapper<Taskqd> {
    //抢单任务
    void updatet(Integer id, Integer num, String serid);
    List<Taskqd> selectList(Integer id);
    List<Taskqd> selectLi(String type,String serid);
}
src/main/java/org/springblade/modules/taskqd/mapper/TaskqdMapper.xml
New file
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.taskqd.mapper.TaskqdMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="taskResultMap" type="org.springblade.modules.taskqd.entity.Taskqd">
        <id column="id" property="id"/>
        <result column="rname" property="rname"/>
        <result column="content" property="content"/>
        <result column="time" property="time"/>
        <result column="province" property="province"/>
        <result column="city" property="city"/>
        <result column="county" property="county"/>
        <result column="jnum" property="jnum"/>
        <result column="line" property="line"/>
        <result column="rtype" property="rtype"/>
        <result column="serid" property="serid"/>
        <result column="integral" property="integral"/>
        <result column="url" property="url"/>
    </resultMap>
    <update id="updatet">
        update sys_taskqd
        SET serid=#{serid},
            num=#{num}
        where id = #{id}
    </update>
    <!--日常任务列表-->
    <select id="selectList" resultMap="taskResultMap">
        select jnum, num, serid
        from sys_taskqd
        where id = #{id}
    </select>
    <select id="selectLi" resultMap="taskResultMap">
        select * from sys_taskqd where 1=1
        <if test="type==0">
            and find_in_set(#{serid}, serid);
        </if>
        <if test="type==1">
            and id NOT IN ( SELECT id FROM sys_taskqd WHERE find_in_set(#{serid}, serid ) );
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/taskqd/service/ITaskqdService.java
New file
@@ -0,0 +1,38 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.models.auth.In;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.task.vo.TaskVO;
import org.springblade.modules.taskqd.entity.Taskqd;
import java.util.List;
/**
 *  服务类
 *
 * @author BladeX
 * @since 2020-08-06
 */
public interface ITaskqdService extends IService<Taskqd> {
    void updatet(Integer id, Integer num, String serid);
    List<Taskqd> selectList(Integer id);
    List<Taskqd> selectLi(String type,String serid);
}
src/main/java/org/springblade/modules/taskqd/service/impl/TaskqdServiceImpl.java
New file
@@ -0,0 +1,55 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.task.mapper.TaskMapper;
import org.springblade.modules.task.vo.TaskVO;
import org.springblade.modules.taskqd.entity.Taskqd;
import org.springblade.modules.taskqd.mapper.TaskqdMapper;
import org.springblade.modules.taskqd.service.ITaskqdService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *  服务实现类
 *
 * @author BladeX
 * @since 2020-08-06
 */
@Service
public class TaskqdServiceImpl extends ServiceImpl<TaskqdMapper, Taskqd> implements ITaskqdService {
    @Override
    public void updatet(Integer id, Integer num, String serid) {
        baseMapper.updatet(id, num, serid);
    }
    @Override
    public List<Taskqd> selectList(Integer id) {
        return baseMapper.selectList(id);
    }
    @Override
    public List<Taskqd> selectLi(String type, String serid) {
        return baseMapper.selectLi(type, serid);
    }
}
src/main/java/org/springblade/modules/taskqd/vo/TaskqdVO.java
New file
@@ -0,0 +1,37 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.taskqd.entity.Taskqd;
/**
 * 视图实体类
 *
 * @author BladeX
 * @since 2020-08-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "TaskVO对象", description = "TaskVO对象")
public class TaskqdVO extends Taskqd {
    private static final long serialVersionUID = 1L;
}
src/main/java/org/springblade/modules/taskqd/wrapper/TaskqdWrapper.java
New file
@@ -0,0 +1,46 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.taskqd.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.task.entity.Task;
import org.springblade.modules.task.vo.TaskVO;
import org.springblade.modules.taskqd.entity.Taskqd;
import org.springblade.modules.taskqd.vo.TaskqdVO;
import java.util.Objects;
/**
 * 包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2020-08-06
 */
public class TaskqdWrapper extends BaseEntityWrapper<Taskqd, TaskqdVO> {
    public static TaskqdWrapper build() {
        return new TaskqdWrapper();
     }
    @Override
    public TaskqdVO entityVO(Taskqd taskqd) {
        TaskqdVO taskqdVO = Objects.requireNonNull(BeanUtil.copy(taskqd, TaskqdVO.class));
        return taskqdVO;
    }
}