jinpengyong
2023-11-14 931734244f977a65dd35c6f606afb999d7c3c967
Merge remote-tracking branch 'origin/wb' into qa
2 files added
8 files modified
289 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/AllocationController.java 28 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/AllocationLog.java 67 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/AllocationLogMapper.java 7 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/enums/SysDictTypeEnum.java 1 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationPageExt.java 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/query/allocation/AllocationPageCond.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationPageVo.java 3 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/AllocationService.java 20 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java 132 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/AllocationMapper.xml 21 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/AllocationController.java
@@ -6,16 +6,17 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.aspectj.apache.bcel.generic.RET;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.AllocationLog;
import com.moral.api.pojo.enums.SysDictTypeEnum;
import com.moral.api.pojo.ext.allocation.AllocationExt;
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;
import com.moral.constant.PageResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +24,6 @@
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -32,9 +32,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.moral.api.entity.Allocation;
import com.moral.api.entity.ResponsibilityUnit;
import com.moral.api.pojo.dto.allocation.AllocationUnitViewDto;
import com.moral.api.service.AllocationService;
import com.moral.api.utils.EasyExcelUtils;
import com.moral.api.utils.NoModelWriteData;
@@ -202,6 +201,23 @@
        }
    }
    @GetMapping("updataUnit")
    @ApiOperation("修改责任单位")
    public ResultMessage updataUnit(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id,
                                    @RequestParam @ApiParam(value = "unitId",name = "责任主题Id") Integer unitId,
                                    @RequestParam @ApiParam(value = "polluteType",name = "污染分类Id") Integer polluteType){
        allocationService.updataUnit(id,unitId,polluteType);
        return ResultMessage.ok();
    }
    @GetMapping("getLog")
    @ApiOperation("修改记录")
    public ResultMessage getLog(@RequestParam @ApiParam(value = "allocationNum",name = "责任单号") String allocationNum){
        List<AllocationLog> log = allocationService.getLog(allocationNum);
        return ResultMessage.ok(log);
    }
}
screen-api/src/main/java/com/moral/api/entity/AllocationLog.java
New file
@@ -0,0 +1,67 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
@Data
@EqualsAndHashCode(callSuper = false)
public class AllocationLog {
    private static final long serialVersionUID = 1L;
    /**
     * 序号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 操作描述
     */
    private String content;
    /**
     * 操作人账号
     */
    private  String account;
    /**
     * 操作人姓名
     */
    private  String  userName;
    /**
     * 操作人员id
     */
    private Integer accountId;
    /**
     * Ip地址
     */
    private String ip;
    /**
     * 交办单号
     */
    private String allocationNum;
    private  String polluteType;
    /**
     * 操作时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
screen-api/src/main/java/com/moral/api/mapper/AllocationLogMapper.java
New file
@@ -0,0 +1,7 @@
package com.moral.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.AllocationLog;
public interface AllocationLogMapper extends BaseMapper<AllocationLog> {
}
screen-api/src/main/java/com/moral/api/pojo/enums/SysDictTypeEnum.java
@@ -41,6 +41,7 @@
    SYS_DEVICE("DEVICE","设备秒机数据"),
    SYS_AMEND("AMEND","立行立改修改数据"),
    ;
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationPageExt.java
@@ -29,6 +29,10 @@
    @ApiModelProperty(value = "状态名字")
    private String stateName;
    @ApiModelProperty(value = "pc端修改权限标识")
    private String isCode;
    //上报单位名字
    private String escalationUnitName;
}
screen-api/src/main/java/com/moral/api/pojo/query/allocation/AllocationPageCond.java
@@ -25,13 +25,13 @@
public class AllocationPageCond implements Serializable{
    @ApiModelProperty(value = "责任单位id")
    private Integer unitId;
    private List<Integer> unitId;
    @ApiModelProperty(value = "污染分类id")
    private Integer polluteType;
    private List<Integer> polluteType;
    @ApiModelProperty(value = "流程状态")
    private Integer state;
    private List<Integer> state;
    @ApiModelProperty(value = "排查方式id")
    private Integer investigationType;
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationPageVo.java
@@ -99,6 +99,9 @@
    @ApiModelProperty(value = "能否审批")
    private Integer isApprove;
    @ApiModelProperty(value = "pc端修改权限标识")
    private String isCode;
    public static AllocationPageVo convert(AllocationPageExt allocationPageExt) {
        AllocationPageVo allocationPageVo = BeanConverts.convert(allocationPageExt, AllocationPageVo.class);
        return allocationPageVo;
screen-api/src/main/java/com/moral/api/service/AllocationService.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.Allocation;
import com.moral.api.entity.AllocationLog;
import com.moral.api.entity.ResponsibilityUnit;
import com.moral.api.pojo.ext.allocation.AllocationExt;
import com.moral.api.pojo.ext.allocation.AllocationListExt;
@@ -139,5 +140,24 @@
     */
    AppAuthority authority(String allocationNum, Integer userId);
    /**
     * 修改责任单位
     * @param id
     * @param unitId
     */
    void updataUnit(Integer id,Integer unitId,Integer polluteType);
    /**
     * 查看修改记录
     * @param allocationNum
     * @return
     */
    List<AllocationLog> getLog(String allocationNum);
    /**
     * 根据字典名称获取权限   空值无权,有值有权
     * @param code
     * @return
     */
    List<Integer> getUnitAuthority(String code);
}
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java
@@ -6,12 +6,15 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.config.Interceptor.UserHelper;
import com.moral.api.controller.LogController;
import com.moral.api.entity.*;
import com.moral.api.exception.BusinessException;
import com.moral.api.mapper.AllocationLogMapper;
import com.moral.api.mapper.AllocationMapper;
import com.moral.api.mapper.ResponsibilityUnitMapper;
import com.moral.api.mapper.SysDictDataMapper;
import com.moral.api.mapper.SysDictTypeMapper;
import com.moral.api.mapper.UserLogMapper;
import com.moral.api.mapper.UserMapper;
import com.moral.api.pojo.bean.BaseInvalidEntity;
import com.moral.api.pojo.dto.allocation.AllocationUnitViewDto;
@@ -31,6 +34,8 @@
import com.moral.constant.Constants;
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import com.moral.util.WebUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
@@ -39,9 +44,13 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
@Service
@@ -73,6 +82,8 @@
    private SysDictTypeService sysDictTypeService;
    @Autowired
    private UserService userService;
    @Autowired
    private AllocationLogMapper allocationLogMapper;
    /**
     * 根据字典类型获取字典数据
@@ -211,32 +222,7 @@
            }
        }
//        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
//        Object unitId = userInfo.get("unitId");
//        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
//        Integer orgId = (Integer) orgInfo.get("id");
//        if (!ObjectUtils.isEmpty(map.get("unitId"))){
//            wrapper.in("unit_id",map.get("unitId").toString());
//        }else {
//            if (orgId!=24){
//                if (ObjectUtils.isEmpty(unitId)){
//                    return null;
//                }
//                ResponsibilityUnit responsibilityUnit1 = responsibilityUnitMapper.selectById(Integer.parseInt(unitId.toString()));
//                Integer areaCode = responsibilityUnit1.getAreaCode();
//                List<ResponsibilityUnit> responsibilityUnits = responsibilityUnitService.selectUnit(areaCode);
//                if (ObjectUtils.isEmpty(responsibilityUnits)){
//                    List<ResponsibilityUnit> responsibilityUnits1 = responsibilityUnitService.selectAreaUnit(areaCode);
//                    Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits1.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                    List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                    wrapper.in("unit_id",collect1);
//                }else {
//                    Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                    List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                    wrapper.in("unit_id",collect1);
//                }
//            }
//        }
        HashMap<String, Object> rsMap = new HashMap<>();
        ArrayList<Map<String, Object>> polluteArrayList = new ArrayList<>();
@@ -394,29 +380,7 @@
                }
            }
        }
//        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
//        Object unitId = userInfo.get("unitId");
//        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
//        Integer orgId = (Integer) orgInfo.get("id");
//
//        if (ObjectUtils.isEmpty(unitId)){
//            return null;
//        }
//        if (orgId!=24){
//            ResponsibilityUnit responsibilityUnit1 = responsibilityUnitMapper.selectById(Integer.parseInt(unitId.toString()));
//            Integer areaCode = responsibilityUnit1.getAreaCode();
//            List<ResponsibilityUnit> responsibilityUnits = responsibilityUnitService.selectUnit(areaCode);
//            if (ObjectUtils.isEmpty(responsibilityUnits)){
//                List<ResponsibilityUnit> responsibilityUnits1 = responsibilityUnitService.selectAreaUnit(areaCode);
//                Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits1.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                wrapper.in("unit_id",collect1);
//            }else {
//                Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                wrapper.in("unit_id",collect1);
//            }
//        }
        ArrayList<Map<String, Object>> rsMap = new ArrayList<>();
        Object number1 = map.get("number");
@@ -485,6 +449,7 @@
    @Override
    public Page<AllocationPageExt> extPage(AllocationPageCond allocationPageCond) {
        List<Integer> unitAuthority = this.getUnitAuthority(SysDictTypeEnum.SYS_AMEND.value);
        List<Integer> unitList = unitResult();
        Integer codeId =  unitAreaCode();
        allocationPageCond.setUnitList(unitList);
@@ -496,6 +461,7 @@
                }else {
                    it.setIsApprove(0);
                }
                it.setIsCode(ObjectUtils.isEmpty(unitAuthority)?"2":"1");
            });
        }
        return page;
@@ -913,6 +879,74 @@
        return appAuthority;
    }
    /**
     * 修改责任单位
     *
     * @param id
     * @param unitId
     */
    @Override
    @Transactional
    public void updataUnit(Integer id, Integer unitId,Integer polluteType) {
        AllocationLog allocationLog = new AllocationLog();
        //获取用户信息
        QxUser user = UserHelper.getCurrentUser();
        Allocation allocation = allocationMapper.selectById(id);
        if (!ObjectUtils.isEmpty(unitId)){
            ResponsibilityUnit unitName1 = getUnitName(allocation.getUnitId());
            ResponsibilityUnit unitName2 = getUnitName(unitId);
            allocation.setUnitId(unitId);
            allocationLog.setContent(unitName1.getUnitName()+"----修改成----"+unitName2.getUnitName());
        }
        if (!ObjectUtils.isEmpty(polluteType)){
            SysDictData sysDictData1 = sysDictTypeService.listOne(Constants.WU_RAN_LEI_XING,allocation.getPolluteType().toString());
            SysDictData sysDictData2 = sysDictTypeService.listOne(Constants.WU_RAN_LEI_XING, polluteType.toString());
            allocation.setPolluteType(polluteType);
            allocationLog.setPolluteType(sysDictData1.getDataValue()+"----修改成----"+sysDictData2.getDataValue());
        }
        allocationMapper.updateById(allocation);
        //日志
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        allocationLog.setAllocationNum(allocation.getAllocationNum());
        allocationLog.setIp(WebUtils.getIpAddr(request));
        allocationLog.setAccountId(user.getUserId());
        allocationLog.setAccount(user.getAccount());
        allocationLog.setUserName(user.getUserName());
        allocationLog.setCreateTime(new Date());
        allocationLogMapper.insert(allocationLog);
    }
    /**
     * 查看修改记录
     *
     * @param allocationNum
     * @return
     */
    @Override
    public List<AllocationLog> getLog(String allocationNum) {
        LambdaQueryWrapper<AllocationLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AllocationLog::getAllocationNum,allocationNum);
        wrapper.orderByAsc(AllocationLog::getCreateTime);
        List<AllocationLog> allocationLogs = allocationLogMapper.selectList(wrapper);
        return allocationLogs;
    }
    /**
     * 根据字典名称获取权限
     *
     * @param code
     * @return
     */
    @Override
    public List<Integer> getUnitAuthority(String code) {
        QxUser user = UserHelper.getCurrentUser();
        List<Integer> userList = responsibilityUnitMapper.selectCodeList(code,user.getUserId());
        return userList;
    }
    @Override
    public List<Integer>  unitResult() {
        QxUser user = UserHelper.getCurrentUser();
screen-api/src/main/resources/mapper/AllocationMapper.xml
@@ -67,14 +67,23 @@
        left join allocation_extension t1 on t1.allocation_id = allocation.allocation_id and t1.is_del =0 and t1.is_invalid = 0 and t1.state = 30
        <where>
            1 = 1 and allocation.is_del = 0
            <if test="allocation.unitId != null">
                and allocation.unit_id = #{allocation.unitId}
            <if test="allocation.unitId != null and allocation.unitId.size != 0">
                and allocation.unit_id in
                <foreach collection="allocation.unitId" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.polluteType != null and allocation.polluteType != 0">
                and allocation.pollute_type = #{allocation.polluteType}
            <if test="allocation.polluteType != null and allocation.polluteType.size != 0">
                and allocation.pollute_type in
                <foreach collection="allocation.polluteType" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.state != null and allocation.state != 0">
                and allocation.state = #{allocation.state}
            <if test="allocation.state != null and allocation.state.size != 0">
                and allocation.state in
                <foreach collection="allocation.state" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.investigationType != null and allocation.investigationType != 0">
                and allocation.investigation_type = #{allocation.investigationType}