zhongrj
2024-02-20 870510b1a1de5f55f9e5e61be65fe4761e431883
二手交易新增导出
5 files modified
2 files added
379 ■■■■■ changed files
src/main/java/org/springblade/common/param/CommonParamSet.java 91 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/controller/TaskLabelReportingEventController.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/excel/TaskLabelReportingEventExcel.java 82 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml 118 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskLabelReportingEventService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java 47 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/param/CommonParamSet.java
New file
@@ -0,0 +1,91 @@
package org.springblade.common.param;
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.grid.service.IGridService;
import org.springblade.modules.police.service.IPoliceAffairsGridService;
import org.springblade.modules.system.service.IRegionService;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
public class CommonParamSet<T> {
    /**
     * 区域编号集合
     */
    private List<String> regionChildCodesList;
    /**
     * 是否为超级管理员
     */
    private Integer isAdministrator;
    /**
     * 网格编号集合
     */
    private List<String> gridCodeList;
    public List<String> getRegionChildCodesList() {
        return regionChildCodesList;
    }
    public Integer getIsAdministrator() {
        return isAdministrator;
    }
    public List<String> getGridCodeList() {
        return gridCodeList;
    }
    public <U> CommonParamSet invoke(Class<U> clazz, T t) {
        //获取传入对象信息
        U u = clazz.cast(t);
        try {
            Field roleNameField = u.getClass().getDeclaredField("roleName");
            Field communityCodeField = u.getClass().getDeclaredField("communityCode");
            // 获取请求头中的角色别名
            String roleName = SpringUtils.getRequestParam("roleName");
            // 获取请求头中的社区编号
            String communityCode = SpringUtils.getRequestParam("communityCode");
            if (!Strings.isBlank(communityCode)) {
                // 校验社区编号是否合规
                if (null != SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
                    // 设置社区编号
                    communityCodeField.setAccessible(true);
                    communityCodeField.set(t,communityCode);
                }
            }
            isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
            if (isAdministrator==2) {
                // 获取当前用户的所属行政区划编号
                regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
                // 获取网格编号集合
                gridCodeList = new ArrayList<>();
                if (!Strings.isBlank(roleName)) {
                    // 设置角色别名
                    roleNameField.setAccessible(true);
                    roleNameField.set(t, roleName);
                    // 民警角色
                    if (roleName.equals("mj")) {
                        regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
                    }
                    // 网格员角色
                    if (roleName.equals("wgy")) {
                        gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId());
                    }
                }
                // 特定账号设置
                if (AuthUtil.getUserAccount().equals("18879306957")) {
                    // 设置社区编号
                    communityCodeField.setAccessible(true);
                    communityCodeField.set(t, "361102003027");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return this;
    }
}
src/main/java/org/springblade/modules/task/controller/TaskLabelReportingEventController.java
@@ -23,18 +23,25 @@
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
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.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.place.excel.PlaceCheckExcel;
import org.springblade.modules.place.vo.PlaceCheckVO;
import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
import org.springblade.modules.task.excel.TaskLabelReportingEventExcel;
import org.springblade.modules.task.service.ITaskLabelReportingEventService;
import org.springblade.modules.task.vo.TaskLabelReportingEventVO;
import org.springblade.modules.task.wrapper.TaskLabelReportingEventWrapper;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
/**
 * 打金店报事 控制器
@@ -122,5 +129,16 @@
        return R.status(taskLabelReportingEventService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 导出二手交易信息
     * @param taskLabelReportingEvent
     */
    @GetMapping("export-taskLabelReportingEvent")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "导出交易登记信息", notes = "传入taskLabelReportingEvent")
    public void exportTaskLabelReportingEvent(TaskLabelReportingEventVO taskLabelReportingEvent, HttpServletResponse response) {
        List<TaskLabelReportingEventExcel> list = taskLabelReportingEventService.exportTaskLabelReportingEvent(taskLabelReportingEvent);
        ExcelUtil.export(response, "交易登记" + DateUtil.time(), "交易登记表", list, TaskLabelReportingEventExcel.class);
    }
}
src/main/java/org/springblade/modules/task/excel/TaskLabelReportingEventExcel.java
New file
@@ -0,0 +1,82 @@
package org.springblade.modules.task.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import org.springblade.common.excel.ExcelDictConverter;
import org.springblade.common.excel.ExcelDictItem;
import org.springblade.common.excel.ExcelDictItemLabel;
import java.io.Serializable;
/**
 * 二手交易记录
 *
 * @author zhongrj
 * @date 2024/02/20
 */
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class TaskLabelReportingEventExcel implements Serializable {
    private static final long serialVersionUID = 2L;
    @ExcelProperty(value = "场所负责人")
    private String principal;
    @ExcelProperty(value = "场所负责人电话")
    private String principalPhone;
    @ExcelProperty( value = "场所名称")
    private String placeName;
    @ExcelProperty( value = "阵地类型",converter = ExcelDictConverter.class)
    @ExcelDictItem(type = "frontType")
    private String frontType;
    /** 街道名称 */
    @ExcelProperty( "交易对象")
    private String transactionObject;
    @ExcelProperty(value = "交易对象电话")
    private String transactionObjectTel;
    @ExcelProperty(value = "身份证号码")
    private String idCard;
    @ExcelProperty( value = "交易数量")
    private Integer goodsNums;
    @ExcelProperty( value = "交易金额")
    private Float transactionMoney;
    @ExcelProperty( value = "交易过程")
    private String transactionProcess;
    @ExcelProperty( value = "发生时间")
    private String createTime;
    @ExcelProperty(value = "地址")
    private String location;
    @ExcelProperty( "所属街道")
    private String streetName;
    @ExcelProperty(value = "所属社区")
    private String communityName;
    @ExcelProperty(value = "审核状态")
    private String confirmFlag;
    @ExcelProperty(value = "审核意见")
    private String confirmNotion;
}
src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java
@@ -19,6 +19,7 @@
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
import org.springblade.modules.task.excel.TaskLabelReportingEventExcel;
import org.springblade.modules.task.vo.TaskLabelReportingEventVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -46,7 +47,6 @@
                                                                      @Param("gridCodeList") List<String> gridCodeList);
    /**
     * 查询打金店报事
     *
@@ -62,4 +62,18 @@
     * @return 打金店报事集合
     */
    public List<TaskLabelReportingEventDTO> selectTaskLabelReportingEventList(TaskLabelReportingEventDTO taskLabelReportingEventDTO);
    /**
     * 导出二手交易信息
     *
     * @param taskLabelReportingEvent
     * @param regionChildCodesList
     * @param isAdministrator
     * @param gridCodeList
     * @return
     */
    List<TaskLabelReportingEventExcel> exportTaskLabelReportingEventList(@Param("taskLabelReportingEvent") TaskLabelReportingEventVO taskLabelReportingEvent,
                                                                         @Param("regionChildCodesList") List<String> regionChildCodesList,
                                                                         @Param("isAdministrator") Integer isAdministrator,
                                                                         @Param("gridCodeList") List<String> gridCodeList);
}
src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml
@@ -138,6 +138,7 @@
                </otherwise>
            </choose>
        </if>
        order by jtlre.create_time desc,jtlre.id desc
    </select>
@@ -252,5 +253,122 @@
        </where>
    </select>
    <!--二手交易自定义分页查询-->
    <select id="exportTaskLabelReportingEventList" resultType="org.springblade.modules.task.excel.TaskLabelReportingEventExcel">
        select
        jtlre.id,
        jtlre.transaction_object,
        jtlre.transaction_object_tel,
        jtlre.id_card,
        jtlre.goods_nums,
        jtlre.transaction_money,
        jtlre.transaction_process,
        case when jtlre.confirm_flag=1 then '待审核'
        when jtlre.confirm_flag=2 then '审核通过'
        when jtlre.confirm_flag=3 then '审核不通过'
        else '待完成' end as confirm_flag,
        jtlre.confirm_notion,
        jtlre.create_time,
        jp.place_name,
        jp.principal,
        jp.principal_phone,
        jp.nine_type ,
        jp.front_type ,
        jp.location,
        br.town_name streetName,
        br.village_name communityName
        from
        jczz_task_label_reporting_event jtlre
        LEFT JOIN jczz_place jp ON jtlre.place_id=jp.id and jp.is_deleted = 0
        LEFT JOIN jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jpag.community_code
        where jtlre.is_deleted = 0
        <if test="taskLabelReportingEvent.userId != null and taskLabelReportingEvent.userId != ''">
            AND jtlre.user_id = #{taskLabelReportingEvent.userId}
        </if>
        <if test="taskLabelReportingEvent.eventType != null and taskLabelReportingEvent.eventType != ''">
            AND jtlre.event_type = #{taskLabelReportingEvent.eventType}
        </if>
        <if test="taskLabelReportingEvent.transactionObject != null and taskLabelReportingEvent.transactionObject != ''">
            AND jtlre.transaction_object like concat('%',#{taskLabelReportingEvent.transactionObject},'%')
        </if>
        <if test="taskLabelReportingEvent.transactionObjectTel != null and taskLabelReportingEvent.transactionObjectTel != ''">
            AND jtlre.transaction_object_tel like concat('%',#{taskLabelReportingEvent.transactionObjectTel},'%')
        </if>
        <if test="taskLabelReportingEvent.idCard != null and taskLabelReportingEvent.idCard != ''">
            AND jtlre.id_card like concat('%',#{taskLabelReportingEvent.idCard},'%')
        </if>
        <if test="taskLabelReportingEvent.frontType != null ">
            AND jp.front_type = #{taskLabelReportingEvent.frontType}
        </if>
        <if test="taskLabelReportingEvent.placeName != null and taskLabelReportingEvent.placeName != ''">
            AND jp.place_name like concat('%',#{taskLabelReportingEvent.placeName},'%')
        </if>
        <if test="taskLabelReportingEvent.principal != null and taskLabelReportingEvent.principal != ''">
            AND jp.principal like concat('%',#{taskLabelReportingEvent.principal},'%')
        </if>
        <if test="taskLabelReportingEvent.principalPhone != null and taskLabelReportingEvent.principalPhone != ''">
            AND jp.principal_phone like concat('%',#{taskLabelReportingEvent.principalPhone},'%')
        </if>
        <if test="taskLabelReportingEvent.roleName != null and taskLabelReportingEvent.roleName != ''">
            <if test="taskLabelReportingEvent.roleName=='wgy'">
                <if test="isAdministrator==2">
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and jp.grid_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                        </when>
                        <otherwise>
                            and jp.grid_code in ('')
                        </otherwise>
                    </choose>
                </if>
            </if>
            <if test="taskLabelReportingEvent.roleName=='mj'">
                <if test="isAdministrator==2">
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and jpag.community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                        </when>
                        <otherwise>
                            and jpag.community_code in ('')
                        </otherwise>
                    </choose>
                </if>
            </if>
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                    and
                    (
                    jg.grid_code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                    or
                    br.village_code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                    )
                </when>
                <otherwise>
                    and
                    (
                    jg.grid_code in ('') or br.village_code in ('')
                    )
                </otherwise>
            </choose>
        </if>
        order by jtlre.create_time desc,jtlre.id desc
    </select>
</mapper>
src/main/java/org/springblade/modules/task/service/ITaskLabelReportingEventService.java
@@ -21,6 +21,7 @@
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
import org.springblade.modules.task.excel.TaskLabelReportingEventExcel;
import org.springblade.modules.task.vo.TaskLabelReportingEventVO;
import java.util.List;
@@ -62,4 +63,10 @@
     * @return 打金店报事集合
     */
    public List<TaskLabelReportingEventDTO> selectTaskLabelReportingEventList(TaskLabelReportingEventDTO taskLabelReportingEventDTO);
    /**
     * 导出二手交易信息
     * @param taskLabelReportingEvent
     */
    List<TaskLabelReportingEventExcel> exportTaskLabelReportingEvent(TaskLabelReportingEventVO taskLabelReportingEvent);
}
src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java
@@ -19,12 +19,11 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.grid.service.IGridService;
@@ -34,6 +33,7 @@
import org.springblade.modules.system.service.IRegionService;
import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
import org.springblade.modules.task.excel.TaskLabelReportingEventExcel;
import org.springblade.modules.task.mapper.TaskLabelReportingEventMapper;
import org.springblade.modules.task.service.ITaskLabelReportingEventService;
import org.springblade.modules.task.service.ITaskService;
@@ -65,31 +65,10 @@
    @Override
    public IPage<TaskLabelReportingEventVO> selectTaskLabelReportingEventPage(IPage<TaskLabelReportingEventVO> page, TaskLabelReportingEventVO taskLabelReportingEvent) {
        String roleName = SpringUtils.getRequestParam("roleName");
        String communityCode = SpringUtils.getRequestParam("communityCode");
        if (!Strings.isBlank(communityCode)) {
            // 校验社区编号是否合规
            if (null != SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
                taskLabelReportingEvent.setCommunityCode(communityCode);
            }
        }
        List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
        Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
        // 网格编号集合
        List<String> gridCodeList = new ArrayList<>();
        // 民警角色
        if (!Strings.isBlank(roleName)) {
            taskLabelReportingEvent.setRoleName(roleName);
            if (roleName.equals("mj")) {
                regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
            }
            if (roleName.equals("wgy")) {
                gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId());
            }
        }
        if (AuthUtil.getUserAccount().equals("18879306957")) {
            taskLabelReportingEvent.setCommunityCode("361102003027");
        }
        CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskLabelReportingEventVO.class,taskLabelReportingEvent);
        List<String> regionChildCodesList = commonParamSet.getRegionChildCodesList();
        Integer isAdministrator = commonParamSet.getIsAdministrator();
        List<String> gridCodeList = commonParamSet.getGridCodeList();
        return page.setRecords(baseMapper.selectTaskLabelReportingEventPage(page, taskLabelReportingEvent,regionChildCodesList,isAdministrator,gridCodeList));
    }
@@ -157,4 +136,18 @@
        return this.baseMapper.selectTaskLabelReportingEventList(taskLabelReportingEventDTO);
    }
    /**
     * 导出二手交易信息
     * @param taskLabelReportingEvent
     */
    @Override
    public List<TaskLabelReportingEventExcel> exportTaskLabelReportingEvent(TaskLabelReportingEventVO taskLabelReportingEvent) {
        // 公共参数设置
        CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskLabelReportingEventVO.class,taskLabelReportingEvent);
        return baseMapper.exportTaskLabelReportingEventList(taskLabelReportingEvent,
            commonParamSet.getRegionChildCodesList(),
            commonParamSet.getIsAdministrator(),
            commonParamSet.getGridCodeList());
    }
}