jinpengyong
2023-10-18 cc120d54e26f64753e99b349599875cf6911a0af
chore:小程序测试提交
3 files added
7 files modified
401 ■■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/AllocationController.java 29 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java 45 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java 5 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java 76 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/AllocationService.java 26 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/UserService.java 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java 128 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java 64 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/AllocationMapper.xml 20 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/AllocationController.java
@@ -12,6 +12,7 @@
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.query.allocation.*;
import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.allocation.AllocationPageVo;
import com.moral.api.pojo.vo.allocation.AllocationVo;
import com.moral.api.utils.BeanConverts;
@@ -197,4 +198,32 @@
        }
    }
    @GetMapping("selectSmallRoutine")
    @ApiOperation("小程序查询")
    public ResultMessage selectSmallRoutine(@RequestParam @ApiParam(value = "state",name = "状态") Integer state,
                                            @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime,
                                            @RequestParam @ApiParam(value = "endTime",name = "结束时间") String endTime){
        List<AllocationFindVo> allocationFindVos = allocationService.selectSmallRoutine(state,startTime,endTime);
        return ResultMessage.ok(ObjectUtils.isEmpty(allocationFindVos)? "0":allocationFindVos);
    }
    @PostMapping("changeRoutine")
    @ApiOperation("小程序整改")
    public ResultMessage changeSmallRoutine(@Valid @RequestBody AllocationChangeCond changeCond){
        allocationService.changeSmallRoutine(changeCond);
        return ResultMessage.ok();
    }
    @PostMapping("checkRoutine")
    @ApiOperation("小程序审批")
    public ResultMessage checkSmallRoutine(@Valid @RequestBody AllocationCheckCond checkCond){
        allocationService.checkSmallRoutine(checkCond);
        return ResultMessage.ok();
    }
}
screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java
New file
@@ -0,0 +1,45 @@
package com.moral.api.controller;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import com.moral.api.service.UserService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
@Slf4j
@Api(tags = {"小程序用户管理"})
@RestController
@RequestMapping("/UserSmallRoutine")
public class UserSmallRoutineController {
    @Autowired
    private UserService userService;
    @ApiOperation(value = "登陆信息", notes = "登陆信息")
    @PostMapping("login")
    public ResultMessage login(@RequestBody Map<String, Object> parameters) {
        if (!(parameters.containsKey("account") && parameters.containsKey("password"))) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> result = userService.loginSmallRoutine(parameters);
        if (!result.containsKey("token")) {
            return ResultMessage.fail((int) result.get("code"), (String) result.get("msg"));
        }
        return ResultMessage.ok(result);
    }
}
screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java
@@ -8,6 +8,8 @@
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.query.allocation.AllocationListCond;
import com.moral.api.pojo.query.allocation.AllocationPageCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -30,4 +32,7 @@
     */
    List<AllocationListExt> extList(@Param("allocation") AllocationListCond allocationListCond);
    List<AllocationFindVo> selectSmallRoutine( Integer state);
}
screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java
New file
@@ -0,0 +1,4 @@
package com.moral.api.mapper;
public interface UserSmallRoutineMapper {
}
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java
New file
@@ -0,0 +1,76 @@
package com.moral.api.pojo.vo.allocation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.moral.api.pojo.enums.AllocationApproveEnum;
import com.moral.util.DateUtils;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="Allocation - 查询VO对象", description="Allocation - 查询VO对象")
public class AllocationFindVo implements Serializable {
    @ApiModelProperty(value = "主键id")
    private Integer allocationId;
    @ApiModelProperty(value = "交办单号")
    private String allocationNum;
    @ApiModelProperty(value = "上报时间")
    @JsonFormat(pattern="yyyy-MM-dd")
    private Date escalationTime;
    @ApiModelProperty(value = "责任单位id")
    private Integer unitId;
    @ApiModelProperty(value = "污染分类id")
    private Integer polluteType;
    @ApiModelProperty(value = "整改类型id")
    private Integer changeType;
    @ApiModelProperty(value = "期限天数")
    private Integer changeDay;
    @ApiModelProperty(value = "剩余天数")
    private Integer residueDay;
    @ApiModelProperty(value = "上报单位id")
    private Integer escalationUnitId;
    @ApiModelProperty(value = "上报人")
    private String escalationName;
    @ApiModelProperty(value = "排查方式id")
    private Integer investigationType;
    @ApiModelProperty(value = "状态")
    private Integer state;
    @ApiModelProperty(value = "是否作废")
    private Integer isInvalid;
    @ApiModelProperty(value = "能否审批")
    private Integer isApprove;
    public Integer getResidueDay() {
        int day = this.changeDay;
        if(AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(state)){
            Date date = new Date();
            int days = DateUtils.getDays(escalationTime, date);
            return day-days;
        }
        return day;
    }
}
screen-api/src/main/java/com/moral/api/service/AllocationService.java
@@ -14,6 +14,8 @@
import com.moral.api.pojo.query.allocation.*;
import com.moral.api.pojo.dto.allocation.AllocationUnitDto;
import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.allocation.AllocationPageVo;
public interface AllocationService extends IService<Allocation> {
@@ -97,4 +99,28 @@
     * @return
     */
    boolean applyFor (AllocationExtensionAddCond allocationExtensionAddCond);
    /**
     * 小程序查询
     * @param state
     * @return
     */
    List<AllocationFindVo> selectSmallRoutine(Integer state,String startTime,String endTime);
    /**
     * 小程序整改
     * @param changeCond
     */
    void changeSmallRoutine(AllocationChangeCond changeCond);
    /**
     * 小程序审批
     * @param checkCond
     */
    void checkSmallRoutine(AllocationCheckCond checkCond);
}
screen-api/src/main/java/com/moral/api/service/UserService.java
@@ -44,4 +44,8 @@
    //根据所传条件获取用户信息
    UserBO selectUserInfo(Map<String, Object> parameters);
    //小程序登陆
    Map<String, Object> loginSmallRoutine(Map<String, Object> parameters);
}
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java
@@ -1,5 +1,6 @@
package com.moral.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.config.Interceptor.UserHelper;
@@ -10,10 +11,9 @@
import com.moral.api.pojo.ext.allocation.AllocationExt;
import com.moral.api.pojo.ext.allocation.AllocationListExt;
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.query.PageCond;
import com.moral.api.pojo.query.allocation.*;
import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond;
import com.moral.api.pojo.vo.approvetable.ApproveTableListVo;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.user.QxUser;
import com.moral.api.service.AllocationExtensionService;
import com.moral.api.service.ApproveTableService;
@@ -62,6 +62,7 @@
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import com.moral.util.TokenUtils;
import com.sun.javafx.scene.control.skin.VirtualFlow;
@Service
@@ -636,6 +637,129 @@
    }
    @Override
    public List<AllocationFindVo> selectSmallRoutine(Integer state,String startTime,String endTime) {
        ArrayList<AllocationFindVo> allocationFindVos = new ArrayList<>();
        LambdaQueryWrapper<Allocation> wrapper = new LambdaQueryWrapper<>();
        //获取用户信息
        List<Integer> list = unitResult();
        if (!ObjectUtils.isEmpty(list)){
            Integer integer = list.get(0);
            if (integer==0){
                return null;
            }else {
                wrapper.in(Allocation::getUnitId,list);
            }
        }
        Integer integer = unitAreaCode();
        //普通权限或 管理员
        if (integer==0 || integer==1){
            if (state==3){
                wrapper.in(Allocation::getState,40,50);
            }else if (state==2){
                wrapper.eq(Allocation::getState,30);
            }else if (state==1){
                wrapper.eq(Allocation::getState,20);
            }
        //区域权限
        }else if (integer==2){
            if (state==3){
                wrapper.in(Allocation::getState,40,50);
            }else if (state==2){
                wrapper.eq(Allocation::getState,20);
            }else if (state==1){
                wrapper.eq(Allocation::getState,30);
            }
        }
        if (!ObjectUtils.isEmpty(startTime) && !ObjectUtils.isEmpty(endTime)){
            wrapper.between(Allocation::getEscalationTime,startTime,endTime);
        }
        wrapper.eq(Allocation::getIsDel,0).eq(Allocation::getIsInvalid,0);
        List<Allocation> allocations = allocationMapper.selectList(wrapper);
        for (Allocation allocation : allocations) {
            AllocationFindVo allocationFindVo = new AllocationFindVo();
            BeanUtils.copyProperties(allocation,allocationFindVo);
            allocationFindVos.add(allocationFindVo);
        }
//        List<AllocationFindVo> allocationFindVos = allocationMapper.selectSmallRoutine(state);
        return allocationFindVos;
    }
    /**
     * 小程序整改
     *
     * @param changeCond
     */
    @Override
    @Transactional
    public void changeSmallRoutine(AllocationChangeCond changeCond) {
        Integer integer = unitAreaCode();
        if (integer==1){
            throw new BusinessException("此账户只能审批,不能整改!");
        }
        AllocationExt allocationExt = oneAllocation(changeCond.getAllocationId());
        if(!AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(allocationExt.getState())) {
            throw new BusinessException("整改状态,才能提交审批!");
        }
        Allocation allocation = new Allocation();
        allocation.setAllocationId(changeCond.getAllocationId());
        allocation.setIsChange(changeCond.getIsChange());
        allocation.setChangeName(changeCond.getChangeName());
        allocation.setChangeDescribe(changeCond.getChangeDescribe());
        allocation.setState(changeCond.getState());
        allocation.setChangeTime(new Date());
        this.updateById(allocation);
        //添加流程数据
        ApproveTable approveTable = new ApproveTable();
        approveTable.setRelationId(allocation.getAllocationId());
        approveTable.setState(AllocationApproveEnum.UNDER_RECTIFICATION.value);
        approveTable.setStateName(AllocationApproveEnum.UNDER_RECTIFICATION.name);
        approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value);
        approveTableService.saveResult(approveTable);
        fileTableService.upDateResult(changeCond.getFileChangeList(),allocation.getAllocationId(), FileTableEnum.ALLOCATION_RECTIFICATION.value);
    }
    /**
     * 小程序审批
     *
     * @param checkCond
     */
    @Override
    @Transactional
    public void checkSmallRoutine(AllocationCheckCond checkCond) {
        Integer integer = unitAreaCode();
        if (integer==0){
            throw new BusinessException("此账户只能整改,不能审批!");
        }
        AllocationExt allocationExt = oneAllocation(checkCond.getAllocationId());
        if(!AllocationApproveEnum.IN_APPROVAL.value.equals(allocationExt.getState())) {
            throw new BusinessException("审批状态,才能进行审批操作!");
        }
        QxUser qxUser = UserHelper.getCurrentUser();
        Allocation allocation = new Allocation();
        allocation.setCheckScore(checkCond.getCheckScore());
        allocation.setAllocationId(checkCond.getAllocationId());
        allocation.setCheckDescribe(checkCond.getCheckDescribe());
        allocation.setCheckName(qxUser.getUserName());
        allocation.setCheckTime(new Date());
        allocation.setState(checkCond.getState());
        this.updateById(allocation);
        //添加流程数据
        ApproveTable approveTable = new ApproveTable();
        approveTable.setRelationId(allocation.getAllocationId());
        if(AllocationApproveEnum.PASS.value.equals(checkCond.getState())){
            approveTable.setState(AllocationApproveEnum.PASS.value);
            approveTable.setStateName(AllocationApproveEnum.PASS.name);
        }else {
            approveTable.setState(AllocationApproveEnum.REFUSE.value);
            approveTable.setStateName(AllocationApproveEnum.REFUSE.name);
        }
        approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value);
        approveTableService.saveResult(approveTable);
        fileTableService.upDateResult(checkCond.getFileApproveList(),checkCond.getAllocationId(), FileTableEnum.ALLOCATION_APPROVE.value);
    }
    @Override
    public List<Integer>  unitResult() {
        QxUser user = UserHelper.getCurrentUser();
        Integer unitId = Objects.nonNull(user.getUnitId())?user.getUnitId():0;
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java
@@ -90,6 +90,70 @@
    }
    @Override
    public Map<String, Object> loginSmallRoutine(Map<String, Object> parameters) {
        UserBO userBo = selectUserInfo(parameters);
        Map<String, Object> result = new HashMap<>();
        //校验账户
        if (userBo == null) {
            result.put("code", ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode());
            result.put("msg", ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg());
            return result;
        }
        //校验密码
        String password = parameters.get("password").toString();
        //密码解密
        password = AESUtils.decrypt(password, AESKey);
        if (!MD5Utils.saltMD5Verify(password, userBo.getPassword())) {
            result.put("code", ResponseCodeEnum.PASSWORD_INVALID.getCode());
            result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg());
            return result;
        }
        //校验是否删除
        if (Constants.DELETE.equals(userBo.getIsDelete())) {
            result.put("code", ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode());
            result.put("msg", ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg());
            return result;
        }
        //校验是否过期
        if (userBo.getExpireTime() != null && userBo.getExpireTime().getTime() < System.currentTimeMillis()) {
            result.put("code", ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getCode());
            result.put("msg", ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getMsg());
            return result;
        }
        //封装用户信息
        Map<String, Object> userInfo = new LinkedHashMap<>();
        userInfo.put("userId", userBo.getId());
        userInfo.put("account", userBo.getAccount());
        userInfo.put("userName", userBo.getUserName());
        userInfo.put("email", userBo.getEmail());
        userInfo.put("mobile", userBo.getMobile());
        userInfo.put("unitId",userBo.getUnitId());
        userInfo.put("wechat", userBo.getWechat());
        userInfo.put("expireTime", DateUtils.dateToDateString(userBo.getExpireTime()));
        userInfo.put("isAdmin", userBo.getIsAdmin());
        try {
            //生成token,并存入redis
            String token = TokenUtils.getToken(userBo.getId().toString(), userInfo);
            result.put("token", token);
        } catch (Exception e) {
            log.error("token生成异常:" + e.getMessage());
            result.put("code", ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode());
            result.put("msg", ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg());
            return result;
        }
        //日志
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        UserLog userLog = new UserLog();
        userLog.setType(Constants.LOGIN_OPERTATE_TYPE);
        userLog.setIp(WebUtils.getIpAddr(request));
        userLog.setOperateId(userBo.getId());
        userLog.setOrganizationId(userBo.getOrganizationId());
        userLog.setContent("登陆了用户:" + userBo.getAccount());
        userLogMapper.insert(userLog);
        return result;
    }
    @Override
    public Map<String, Object> login(Map<String, Object> parameters) {
        UserBO userBo = selectUserInfo(parameters);
        Map<String, Object> result = new HashMap<>();
screen-api/src/main/resources/mapper/AllocationMapper.xml
@@ -59,6 +59,26 @@
        </where>
    </select>
    <select id="selectSmallRoutine" resultType="com.moral.api.pojo.vo.allocation.AllocationFindVo">
        SELECT
        <include refid="Allocation_Column_List"/>
        FROM  allocation as a
        <where>
            and is_del = 0 and is_invalid =0
            <if test="allocation.state != null and allocation.id != 0">
                and a.state = #{state}
            </if>
            <if test="allocation.startTime != null and allocation.startTime != '' ">
                and date(escalation_time) <![CDATA[>=]]> #{startTime}
            </if>
            <if test="allocation.endTime != null and allocation.endTime !='' ">
                and date(escalation_time) <![CDATA[<=]]>  #{endTime}
            </if>
        </where>
        order by escalation_time desc,allocation_id desc
    </select>
    <select id="extPage" resultType="com.moral.api.pojo.ext.allocation.AllocationPageExt">
        SELECT
        <include refid="Allocation_Column_List"/>,t1.id as applyState