Ver código fonte

完善一期用户

JX.Li 7 meses atrás
pai
commit
1c4829ac54

+ 157 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/controller/YqGUserController.java

@@ -0,0 +1,157 @@
+package com.ruoyi.yiqi.controller;
+
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.core.validate.AddGroup;
+import com.ruoyi.common.core.validate.EditGroup;
+import com.ruoyi.common.core.validate.QueryGroup;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.yiqi.entity.YqGUser;
+import com.ruoyi.yiqi.service.IYqGUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 用户Controller
+ *
+ * @author ruoyi
+ * @date 2021-11-12
+ */
+@Validated
+@RestController
+@RequestMapping("/yq/gas/user")
+public class YqGUserController extends BaseController {
+
+    @Autowired
+    private IYqGUserService iGUserService;
+
+    /**
+     * 查询用户列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo<YqGUser> list(@Validated(QueryGroup.class) YqGUser bo) {
+        return iGUserService.queryPageList(bo);
+    }
+
+    /**
+     * 导出用户列表
+     */
+    @GetMapping("/export")
+    public void export(@Validated YqGUser bo, HttpServletResponse response) {
+        List<YqGUser> list = iGUserService.queryList(bo);
+        ExcelUtil.exportExcel(list, "用户", YqGUser.class, response);
+    }
+
+    /**
+     * 获取用户详细信息
+     */
+    @GetMapping("/{id}")
+    public R<YqGUser> getInfo(@NotNull(message = "主键不能为空")
+                                                  @PathVariable("id") Long id) {
+        return R.ok(iGUserService.queryById(id));
+    }
+
+    /**
+     * 新增用户
+     */
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody YqGUser bo) {
+        return toAjax(iGUserService.insertByBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 修改用户
+     */
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody YqGUser bo) {
+        return toAjax(iGUserService.updateByBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 删除用户
+     */
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                                       @PathVariable Long[] ids) {
+        return toAjax(iGUserService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
+    }
+
+    /**
+     * 列表查询
+     * @param bo
+     * @return
+     */
+    @GetMapping("/getList")
+    public TableDataInfo<YqGUser> getList(@Validated(QueryGroup.class) YqGUser bo) {
+        return iGUserService.getList(bo);
+    }
+
+    /**
+     * 工人下拉
+     * @return
+     */
+    @GetMapping("/getWorker")
+    public R getWorker() {
+        return R.ok(iGUserService.getWorker());
+    }
+
+    /**
+     * 黑名单列表
+     * @param bo
+     * @return
+     */
+    @GetMapping("/getBlacklist")
+    public TableDataInfo<YqGUser> getBlacklist(@Validated(QueryGroup.class) YqGUser bo) {
+        return iGUserService.getBlacklist(bo);
+    }
+
+    /**
+     * 合格/不合格统计-工长
+     * @return
+     */
+    @GetMapping("/getExamineForeman")
+    public R getExamineForeman(Long foremanId) {
+        return R.ok(iGUserService.getExamineForeman(foremanId));
+    }
+
+    /**
+     * 合格/不合格统计-工人
+     * @return
+     */
+    @GetMapping("/getExamineWorker")
+    public R getExamineWorker(Long workerId) {
+        return R.ok(iGUserService.getExamineWorker(workerId));
+    }
+
+    /**
+     * 手机号唯一校验
+     * @param phone
+     * @return
+     */
+    @GetMapping("/getForPhone")
+    public R getForPhone(Long phone, String id) {
+        return R.ok(iGUserService.getForPhone(phone,id));
+    }
+
+    /**
+     *工号唯一校验
+     * @param jobNum
+     * @return
+     */
+    @GetMapping("/getForJobnum")
+    public R getForJobnum(String jobNum,String id) {
+        return R.ok(iGUserService.getForJobnum(jobNum,id));
+    }
+}

+ 68 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/entity/YqGUser.java

@@ -0,0 +1,68 @@
+package com.ruoyi.yiqi.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 用户对象 g_user
+ *
+ * @author ruoyi
+ * @date 2021-11-12
+ */
+@Data
+@TableName("yq_g_user")
+public class YqGUser extends BaseEntity {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键id
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 姓名
+     */
+    private String name;
+    /**
+     * 工号
+     */
+    private String jobNum;
+    /**
+     * 手机号
+     */
+    private Long phone;
+
+    /**
+     * 删除标志
+     */
+    @TableLogic
+    private String delFlag;
+    private String password;
+    /**
+     * 工程权限
+     */
+    private String power;
+    /**
+     * 民用工程权限
+     */
+    private String civilPower;
+    /**
+     * 分页大小
+     */
+    @TableField(exist = false)
+    private Integer pageSize;
+
+    /**
+     * 当前页数
+     */
+    @TableField(exist = false)
+    private Integer pageNum;
+
+}

+ 86 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/enums/Constants.java

@@ -0,0 +1,86 @@
+package com.ruoyi.yiqi.enums;
+
+
+/**
+ * <p>
+ * 枚举
+ * </p>
+ *
+ * @author cxp
+ * @since 2021-06-23
+ */
+public class Constants {
+
+    /**
+     * <p>
+     * 字典配置
+     * </p>
+     *
+     * @author cxp
+     * @since 2020-09-02
+     */
+    public enum Dict {
+
+        EXAMINE_STATUS001("审核状态", "examine_status", "001", "合格"),
+        EXAMINE_STATUS002("审核状态", "examine_status", "002", "不合格"),
+
+        ORDER_STATUS001("订单状态", "order_status", "001", "待审核"),
+        ORDER_STATUS002("订单状态", "order_status", "002", "已完成"),
+
+
+        SERVICE_TYPE001("服务类别", "service_type", "001", "上门未预"),
+        SERVICE_TYPE002("服务类别", "service_type", "002", "正常施工"),
+        SERVICE_TYPE003("服务类别", "service_type", "003", "不符合规定"),
+        SERVICE_TYPE004("服务类别", "service_type", "004", "安检"),
+        SERVICE_TYPE005("服务类别", "service_type", "005", "维修"),
+        SERVICE_TYPE006("服务类别", "service_type", "006", "开栓"),
+
+        RELEASE_STATUS001("释放状态", "release_status", "001", "未释放"),
+        RELEASE_STATUS002("释放状态", "release_status", "002", "已释放"),
+
+
+
+        ;
+        /**
+         * 编码
+         */
+        private String dictName;
+        /**
+         * 编码
+         */
+        private String code;
+        /**
+         * 字典值
+         */
+        private String itemValue;
+        /**
+         * 字典值描述
+         */
+        private String itemName;
+
+        public String getDictName() {
+            return dictName;
+        }
+
+        public String getCode() {
+            return code;
+        }
+
+        public String getItemValue() {
+            return itemValue;
+        }
+
+        public String getItemName() {
+            return itemName;
+        }
+
+        Dict(String dictName, String code, String itemValue, String itemName) {
+            this.dictName = dictName;
+            this.code = code;
+            this.itemValue = itemValue;
+            this.itemName = itemName;
+        }
+
+    }
+
+}

+ 31 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/mapper/YqGUserMapper.java

@@ -0,0 +1,31 @@
+package com.ruoyi.yiqi.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.mapper.BaseMapperPlus;
+import com.ruoyi.yiqi.entity.YqGUser;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 用户Mapper接口
+ *
+ * @author ruoyi
+ * @date 2021-11-12
+ */
+public interface YqGUserMapper extends BaseMapperPlus<YqGUserMapper, YqGUser, YqGUser> {
+
+    Page<YqGUser> getList(@Param("p") YqGUser bo, Page<?> page);
+
+    List<YqGUser> getWorker();
+
+    Page<YqGUser> getBlacklist(@Param("p") YqGUser bo, Page<?> page);
+
+    List<YqGUser> getExamineForeman(Long foremanId);
+
+    List<YqGUser> getExamineWorker(Long workerId);
+
+    YqGUser getForPhone(@Param("phone") Long phone, @Param("id") String id);
+
+    YqGUser getForJobnum(@Param("jobNum") String jobNum, @Param("id") String id);
+}

+ 75 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/service/IYqGUserService.java

@@ -0,0 +1,75 @@
+package com.ruoyi.yiqi.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.yiqi.entity.YqGUser;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 用户Service接口
+ *
+ * @author ruoyi
+ * @date 2021-11-12
+ */
+public interface IYqGUserService extends IService<YqGUser> {
+	/**
+	 * 查询单个
+	 * @return
+	 */
+	YqGUser queryById(Long id);
+
+	/**
+	 * 查询列表
+	 */
+    TableDataInfo<YqGUser> queryPageList(YqGUser bo);
+
+	/**
+	 * 查询列表
+	 */
+	List<YqGUser> queryList(YqGUser bo);
+
+	/**
+	 * 根据新增业务对象插入用户
+	 * @param bo 用户新增业务对象
+	 * @return
+	 */
+	Boolean insertByBo(YqGUser bo);
+
+	/**
+	 * 根据编辑业务对象修改用户
+	 * @param bo 用户编辑业务对象
+	 * @return
+	 */
+	Boolean updateByBo(YqGUser bo);
+
+	/**
+	 * 校验并删除数据
+	 * @param ids 主键集合
+	 * @param isValid 是否校验,true-删除前校验,false-不校验
+	 * @return
+	 */
+	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+	TableDataInfo<YqGUser> getList(YqGUser bo);
+
+
+	/**
+	 * 工人下拉
+	 * @return
+	 */
+	List<YqGUser>  getWorker();
+
+	/**
+	 * 黑名单列表
+	 * @param bo
+	 * @return
+	 */
+	TableDataInfo<YqGUser> getBlacklist(YqGUser bo);
+
+	List<YqGUser> getExamineForeman(Long foremanId);
+	List<YqGUser> getExamineWorker(Long workerId);
+	Boolean getForPhone(Long phone,String id);
+	Boolean getForJobnum(String jobNum,String id);
+}

+ 210 - 0
ruoyi-yiqi/src/main/java/com/ruoyi/yiqi/service/impl/YqGUserServiceImpl.java

@@ -0,0 +1,210 @@
+package com.ruoyi.yiqi.service.impl;
+
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.utils.PageUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.yiqi.entity.YqGUser;
+import com.ruoyi.yiqi.enums.Constants;
+import com.ruoyi.yiqi.mapper.YqGUserMapper;
+import com.ruoyi.yiqi.service.IYqGUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.function.Function;
+
+/**
+ * 用户Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2021-11-12
+ */
+@Service
+public class YqGUserServiceImpl  implements IYqGUserService {
+
+    @Autowired
+    private YqGUserMapper gUserMapper;
+
+    @Override
+    public YqGUser queryById(Long id){
+        return gUserMapper.selectVoById(id);
+    }
+
+    @Override
+    public TableDataInfo<YqGUser> queryPageList(YqGUser bo) {
+        Page<YqGUser> page = new Page<>(bo.getPageNum(), bo.getPageSize());
+        Page<YqGUser> list = gUserMapper.getList(bo,page);
+        return PageUtils.buildDataInfo(list);
+    }
+
+    @Override
+    public List<YqGUser> queryList(YqGUser bo) {
+        return gUserMapper.selectVoList(buildQueryWrapper(bo));
+    }
+
+    private LambdaQueryWrapper<YqGUser> buildQueryWrapper(YqGUser bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<YqGUser> lqw = Wrappers.lambdaQuery();
+        lqw.like(StringUtils.isNotBlank(bo.getName()), YqGUser::getName, bo.getName());
+        lqw.like(bo.getJobNum() != null, YqGUser::getJobNum, bo.getJobNum());
+        return lqw;
+    }
+
+    @Override
+    public Boolean insertByBo(YqGUser add) {
+        boolean flag = save(add);
+        return flag;
+    }
+
+    @Override
+    public Boolean updateByBo(YqGUser bo) {
+        YqGUser update = BeanUtil.toBean(bo, YqGUser.class);
+        validEntityBeforeSave(update);
+        return updateById(update);
+    }
+
+    /**
+     * 保存前的数据校验
+     *
+     * @param entity 实体类数据
+     */
+    private void validEntityBeforeSave(YqGUser entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return removeByIds(ids);
+    }
+
+    @Override
+    public TableDataInfo<YqGUser> getList(YqGUser bo) {
+        Page<YqGUser> page = new Page<>(bo.getPageNum(), bo.getPageSize());
+        Page<YqGUser> list = gUserMapper.getList(bo,page);
+        return PageUtils.buildDataInfo(list);
+
+    }
+
+
+    @Override
+    public List<YqGUser> getWorker() {
+        return gUserMapper.getWorker();
+    }
+
+    @Override
+    public TableDataInfo<YqGUser> getBlacklist(YqGUser bo) {
+        Page<YqGUser> page = new Page<>(bo.getPageNum(), bo.getPageSize());
+        Page<YqGUser> list = gUserMapper.getBlacklist(bo,page);
+        return PageUtils.buildDataInfo(list);
+
+    }
+
+    @Override
+    public List<YqGUser> getExamineForeman(Long foremanId) {
+        List<YqGUser> list = gUserMapper.getExamineForeman(foremanId);
+        list.forEach(i -> {
+            if (Constants.Dict.EXAMINE_STATUS001.getItemValue().equals(i.getName())){
+                i.setName(Constants.Dict.EXAMINE_STATUS001.getItemName());
+            }
+            if (Constants.Dict.EXAMINE_STATUS002.getItemValue().equals(i.getName())){
+                i.setName(Constants.Dict.EXAMINE_STATUS002.getItemName());
+            }
+        });
+        return list;
+    }
+
+    @Override
+    public List<YqGUser> getExamineWorker(Long workerId) {
+        List<YqGUser> list = gUserMapper.getExamineWorker(workerId);
+        list.forEach(i -> {
+            if (Constants.Dict.EXAMINE_STATUS001.getItemValue().equals(i.getName())){
+                i.setName(Constants.Dict.EXAMINE_STATUS001.getItemName());
+            }
+            if (Constants.Dict.EXAMINE_STATUS002.getItemValue().equals(i.getName())){
+                i.setName(Constants.Dict.EXAMINE_STATUS002.getItemName());
+            }
+        });
+        return list;
+    }
+
+    @Override
+    public Boolean getForPhone(Long phone,String id) {
+        YqGUser vo = gUserMapper.getForPhone(phone,id);
+        if (vo==null){
+            return true;
+        }else {
+            return false;
+        }
+    }
+
+    @Override
+    public Boolean getForJobnum(String jobNum,String id) {
+        YqGUser vo = gUserMapper.getForJobnum(jobNum,id);
+        if (vo==null){
+            return true;
+        }else {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean saveBatch(Collection<YqGUser> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<YqGUser> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean updateBatchById(Collection<YqGUser> entityList, int batchSize) {
+        return false;
+    }
+
+    @Override
+    public boolean saveOrUpdate(YqGUser entity) {
+        return false;
+    }
+
+    @Override
+    public YqGUser getOne(Wrapper<YqGUser> queryWrapper, boolean throwEx) {
+        return null;
+    }
+
+    @Override
+    public Optional<YqGUser> getOneOpt(Wrapper<YqGUser> queryWrapper, boolean throwEx) {
+        return Optional.empty();
+    }
+
+    @Override
+    public Map<String, Object> getMap(Wrapper<YqGUser> queryWrapper) {
+        return new HashMap<>();
+    }
+
+    @Override
+    public <V> V getObj(Wrapper<YqGUser> queryWrapper, Function<? super Object, V> mapper) {
+        return null;
+    }
+
+    @Override
+    public BaseMapper<YqGUser> getBaseMapper() {
+        return null;
+    }
+
+    @Override
+    public Class<YqGUser> getEntityClass() {
+        return null;
+    }
+}

+ 93 - 0
ruoyi-yiqi/src/main/resources/mapper/YqGUserMapper.xml

@@ -0,0 +1,93 @@
+<?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="com.ruoyi.yiqi.mapper.YqGUserMapper">
+    <resultMap type="com.ruoyi.yiqi.entity.YqGUser" id="GUserResult">
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="jobNum" column="job_num"/>
+        <result property="password" column="password"/>
+        <result property="phone" column="phone"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="power" column="power"/>
+        <result property="civilPower" column="civil_power"/>
+    </resultMap>
+    <select id="getList" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select *
+        from yq_g_user a
+        <where>
+            a.del_flag = '0'
+            <if test="p.name != null  and p.name != ''">
+                and a.name LIKE CONCAT('%',#{p.name},'%')
+            </if>
+            <if test="p.jobNum != null  and p.jobNum != ''">
+                and a.job_num LIKE CONCAT('%',#{p.jobNum},'%')
+            </if>
+        </where>
+    </select>
+
+    <select id="getWorker" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select id   as id,
+               name as name
+        from yq_g_user
+        where del_flag = '0'
+    </select>
+    <select id="getBlacklist" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        SELECT q.*
+        FROM (SELECT DISTINCT a.id AS id,
+        a.NAME AS NAME,
+        a.job_num as jobNum,
+        a.phone as phone,
+        COUNT(b.id) AS num
+        FROM g_order b
+        LEFT JOIN yq_g_user a ON b.user_id = a.id
+        WHERE b.examine_status = '002'
+        and b.del_flag = '0'
+        GROUP BY a.id ) q,
+        (SELECT parameter AS parameter FROM g_parameter LIMIT 1) w
+        WHERE q.num >= w.parameter
+    </select>
+    <select id="getExamineForeman" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select count(o.id) as value,
+            o.examine_status as name
+        from g_order o
+                left join yq_g_user a on o.user_id = a.id and a.del_flag = '0'
+        where o.order_status = '002'
+        and o.service_type = '002'
+          and o.del_flag = '0'
+        group by  o.examine_status
+    </select>
+    <select id="getExamineWorker" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select count(o.id) as value,
+            o.examine_status as name
+        from g_order o
+        where  o.order_status = '002'
+        and o.service_type = '002'
+          and o.del_flag = '0'
+        <if test="workerId != null  and workerId != ''">
+            and o.user_id = #{workerId}
+        </if>
+        group by  o.examine_status
+    </select>
+    <select id="getForPhone" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select * from yq_g_user
+        where phone = #{phone}
+        and del_flag = '0'
+        <if test="id != null  and id!= ''">
+            and id != #{id}
+        </if>
+    </select>
+    <select id="getForJobnum" resultType="com.ruoyi.yiqi.entity.YqGUser">
+        select * from yq_g_user
+        where job_num = #{jobNum}
+        and del_flag = '0'
+        <if test="id != null  and id!= ''">
+            and id != #{id}
+        </if>
+    </select>
+</mapper>