8 changed files with 868 additions and 0 deletions
@ -0,0 +1,121 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.ReportMaCodeDTO; |
||||
|
import com.elink.esua.epdc.excel.ReportMaCodeExcel; |
||||
|
import com.elink.esua.epdc.service.ReportMaCodeService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("reportmacode") |
||||
|
public class ReportMaCodeController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ReportMaCodeService reportMaCodeService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<ReportMaCodeDTO>> page(@RequestParam Map<String, Object> params) { |
||||
|
PageData<ReportMaCodeDTO> page = reportMaCodeService.page(params); |
||||
|
return new Result<PageData<ReportMaCodeDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<ReportMaCodeDTO> get(@PathVariable("id") String id) { |
||||
|
ReportMaCodeDTO data = reportMaCodeService.get(id); |
||||
|
return new Result<ReportMaCodeDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody ReportMaCodeDTO dto) { |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
reportMaCodeService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody ReportMaCodeDTO dto) { |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
reportMaCodeService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids) { |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
reportMaCodeService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<ReportMaCodeDTO> list = reportMaCodeService.list(params); |
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, ReportMaCodeExcel.class); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 所有部门报事码初始化 |
||||
|
* |
||||
|
* @param |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author zhy |
||||
|
* @date 2020/11/12 13:43 |
||||
|
*/ |
||||
|
@PostMapping("init") |
||||
|
public Result initReportMaCode() { |
||||
|
return reportMaCodeService.initReportMaCode(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成指定网格报事码 |
||||
|
* |
||||
|
* @param gridId |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author zhy |
||||
|
* @date 2020/11/12 13:43 |
||||
|
*/ |
||||
|
@PostMapping("create/{gridId}") |
||||
|
public Result createReportMaCode(@PathVariable("gridId") String gridId) { |
||||
|
return reportMaCodeService.createReportMaCode(gridId); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,70 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.dto.ReportMaCodeDTO; |
||||
|
import com.elink.esua.epdc.entity.ReportMaCodeEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ReportMaCodeDao extends BaseDao<ReportMaCodeEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 获取部门报事码列表 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<com.elink.esua.epdc.dto.ReportMaCodeDTO> |
||||
|
* @author zhy |
||||
|
* @date 2020/11/12 13:33 |
||||
|
*/ |
||||
|
List<ReportMaCodeDTO> selectListDeptMaCode(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 查询所有未生成报事码的网格ID |
||||
|
* |
||||
|
* @param |
||||
|
* @return java.util.List<java.lang.Long> |
||||
|
* @author zhy |
||||
|
* @date 2020/11/12 13:33 |
||||
|
*/ |
||||
|
List<Long> selectListNoCodeGridId(); |
||||
|
|
||||
|
/** |
||||
|
* 根据机构类型,查询机构id及pids |
||||
|
* |
||||
|
* @param dataScopeDeptIds 用户部门数据权限 |
||||
|
* @param typeKey 机构类型{@link com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant} |
||||
|
* @return java.util.List<OptDeptMaCodeEntity> |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/5/15 13:58 |
||||
|
*/ |
||||
|
List<ReportMaCodeEntity> selectListDeptIdByTypeKey(@Param("dataScopeDeptIds") List<Long> dataScopeDeptIds, @Param("typeKey") String typeKey); |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_report_ma_code") |
||||
|
public class ReportMaCodeEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 网格ID |
||||
|
*/ |
||||
|
private Long gridId; |
||||
|
|
||||
|
/** |
||||
|
* 小程序码URL |
||||
|
*/ |
||||
|
private String codeUrl; |
||||
|
|
||||
|
/** |
||||
|
* 是否是网格长码,0否 1是 |
||||
|
*/ |
||||
|
private String leaderFlag; |
||||
|
|
||||
|
/** |
||||
|
* 网格名称 |
||||
|
*/ |
||||
|
private String grid; |
||||
|
|
||||
|
/** |
||||
|
* 父所有部门 |
||||
|
*/ |
||||
|
private String parentDeptIds; |
||||
|
|
||||
|
/** |
||||
|
* 父所有部门 |
||||
|
*/ |
||||
|
private String parentDeptNames; |
||||
|
|
||||
|
/** |
||||
|
* 所有部门ID |
||||
|
*/ |
||||
|
private String allDeptIds; |
||||
|
|
||||
|
/** |
||||
|
* 所有部门名称 |
||||
|
*/ |
||||
|
private String allDeptNames; |
||||
|
|
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.excel; |
||||
|
|
||||
|
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ReportMaCodeExcel { |
||||
|
|
||||
|
@Excel(name = "主键") |
||||
|
private String id; |
||||
|
|
||||
|
@Excel(name = "网格ID") |
||||
|
private Long gridId; |
||||
|
|
||||
|
@Excel(name = "小程序码URL") |
||||
|
private String codeUrl; |
||||
|
|
||||
|
@Excel(name = "乐观锁") |
||||
|
private Integer revision; |
||||
|
|
||||
|
@Excel(name = "创建人") |
||||
|
private String createdBy; |
||||
|
|
||||
|
@Excel(name = "创建时间") |
||||
|
private Date createdTime; |
||||
|
|
||||
|
@Excel(name = "更新人") |
||||
|
private String updatedBy; |
||||
|
|
||||
|
@Excel(name = "更新时间") |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
@Excel(name = "删除标记") |
||||
|
private String delFlag; |
||||
|
|
||||
|
@Excel(name = "是否是网格长码,0否 1是") |
||||
|
private String leaderFlag; |
||||
|
|
||||
|
@Excel(name = "网格名称") |
||||
|
private String grid; |
||||
|
|
||||
|
@Excel(name = "父所有部门") |
||||
|
private String parentDeptIds; |
||||
|
|
||||
|
@Excel(name = "父所有部门") |
||||
|
private String parentDeptNames; |
||||
|
|
||||
|
@Excel(name = "所有部门ID") |
||||
|
private String allDeptIds; |
||||
|
|
||||
|
@Excel(name = "所有部门名称") |
||||
|
private String allDeptNames; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.redis; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ReportMaCodeRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
public void delete(Object[] ids) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void set(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String get(String id){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,124 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.ReportMaCodeDTO; |
||||
|
import com.elink.esua.epdc.entity.ReportMaCodeEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
public interface ReportMaCodeService extends BaseService<ReportMaCodeEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<ReportMaCodeDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
PageData<ReportMaCodeDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<ReportMaCodeDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
List<ReportMaCodeDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return ReportMaCodeDTO |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
ReportMaCodeDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
void save(ReportMaCodeDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
void update(ReportMaCodeDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-11-12 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 所有部门小程序码初始化 |
||||
|
* |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2019/9/19 09:32 |
||||
|
*/ |
||||
|
Result initReportMaCode(); |
||||
|
|
||||
|
/** |
||||
|
* 生成指定网格小程序码 |
||||
|
* |
||||
|
* @param gridId |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2019/9/19 11:05 |
||||
|
*/ |
||||
|
Result createReportMaCode(String gridId); |
||||
|
|
||||
|
/** |
||||
|
* 根据部门权限,同步部门信息 |
||||
|
* |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/5/15 15:27 |
||||
|
*/ |
||||
|
Result initDeptForMaCode(); |
||||
|
} |
@ -0,0 +1,269 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
||||
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dao.ReportMaCodeDao; |
||||
|
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
||||
|
import com.elink.esua.epdc.dto.ReportMaCodeDTO; |
||||
|
import com.elink.esua.epdc.dto.UploadToOssDTO; |
||||
|
import com.elink.esua.epdc.entity.ReportMaCodeEntity; |
||||
|
import com.elink.esua.epdc.feign.OssFeignClient; |
||||
|
import com.elink.esua.epdc.optimize.modules.deptlevel.dao.OptSysDeptDao; |
||||
|
import com.elink.esua.epdc.optimize.utils.DeptUtils; |
||||
|
import com.elink.esua.epdc.redis.ReportMaCodeRedis; |
||||
|
import com.elink.esua.epdc.service.ReportMaCodeService; |
||||
|
import com.elink.esua.epdc.utils.WxMaServiceUtils; |
||||
|
import com.google.common.collect.Lists; |
||||
|
import me.chanjar.weixin.common.error.WxErrorException; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.File; |
||||
|
import java.io.FileInputStream; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 网格报事码 |
||||
|
* |
||||
|
* @author zhangyuan qu@elink-cn.com |
||||
|
* @since v1.0.0 2020-11-12 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ReportMaCodeServiceImpl extends BaseServiceImpl<ReportMaCodeDao, ReportMaCodeEntity> implements ReportMaCodeService { |
||||
|
|
||||
|
@Autowired |
||||
|
private ReportMaCodeRedis reportMaCodeRedis; |
||||
|
|
||||
|
@Autowired |
||||
|
private WxMaServiceUtils wxMaServiceUtils; |
||||
|
|
||||
|
@Autowired |
||||
|
private OssFeignClient ossFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private OptSysDeptDao sysDeptDao; |
||||
|
|
||||
|
/** |
||||
|
* 小程序首页 |
||||
|
*/ |
||||
|
private static String MA_FRONT_PAGE_URL = "pages/index/index"; |
||||
|
private static String MA_GRID_SUFFIX = "RP"; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<ReportMaCodeDTO> page(Map<String, Object> params) { |
||||
|
params.put("dataScopeDeptIds", SecurityUser.getUser().getDeptIdList()); |
||||
|
IPage<ReportMaCodeDTO> page = getPage(params); |
||||
|
List<ReportMaCodeDTO> pageDataList = baseDao.selectListDeptMaCode(params); |
||||
|
return new PageData<>(pageDataList, page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ReportMaCodeDTO> list(Map<String, Object> params) { |
||||
|
List<ReportMaCodeEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, ReportMaCodeDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<ReportMaCodeEntity> getWrapper(Map<String, Object> params) { |
||||
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<ReportMaCodeEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ReportMaCodeDTO get(String id) { |
||||
|
ReportMaCodeEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, ReportMaCodeDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(ReportMaCodeDTO dto) { |
||||
|
ReportMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, ReportMaCodeEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(ReportMaCodeDTO dto) { |
||||
|
ReportMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, ReportMaCodeEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result initReportMaCode() { |
||||
|
|
||||
|
List<Long> gridIdList = this.baseDao.selectListNoCodeGridId(); |
||||
|
if (CollUtil.isEmpty(gridIdList)) { |
||||
|
return new Result(); |
||||
|
} |
||||
|
ReportMaCodeEntity entity; |
||||
|
for (Long gridId : gridIdList) { |
||||
|
entity = new ReportMaCodeEntity(); |
||||
|
entity.setCodeUrl(this.createMaCode(String.valueOf(gridId).concat(MA_GRID_SUFFIX), MA_FRONT_PAGE_URL)); |
||||
|
entity.setGridId(gridId); |
||||
|
this.baseDao.insert(entity); |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result createReportMaCode(String gridId) { |
||||
|
ReportMaCodeEntity entity = new ReportMaCodeEntity(); |
||||
|
entity.setCodeUrl(this.createMaCode(gridId.concat(MA_GRID_SUFFIX), MA_FRONT_PAGE_URL)); |
||||
|
entity.setGridId(Long.parseLong(gridId)); |
||||
|
entity.setLeaderFlag(YesOrNoEnum.NO.value()); |
||||
|
this.baseDao.insert(entity); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result initDeptForMaCode() { |
||||
|
List<Long> dataScopeList = SecurityUser.getUser().getDeptIdList(); |
||||
|
List<ReportMaCodeEntity> deptIdList = baseDao.selectListDeptIdByTypeKey(dataScopeList, OrganizationTypeConstant.ORG_TYPE_GRID_PARTY); |
||||
|
if (CollUtil.isEmpty(deptIdList)) { |
||||
|
return new Result(); |
||||
|
} |
||||
|
List<ReportMaCodeEntity> insertList = Lists.newArrayList(); |
||||
|
for (ReportMaCodeEntity deptMaCodeEntity : deptIdList) { |
||||
|
ReportMaCodeEntity entity = packDeptBaseInfo(deptMaCodeEntity.getGridId(), deptMaCodeEntity.getParentDeptIds()); |
||||
|
if (null != entity) { |
||||
|
insertList.add(entity); |
||||
|
} |
||||
|
} |
||||
|
insertBatch(insertList, NumConstant.FIFTY); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取部门及父部门信息,拼接部门id,部门名称 |
||||
|
* |
||||
|
* @param deptId 本部门id |
||||
|
* @param pids 所有父部门id |
||||
|
* @return OptDeptMaCodeEntity |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/5/18 14:06 |
||||
|
*/ |
||||
|
private ReportMaCodeEntity packDeptBaseInfo(Long deptId, String pids) { |
||||
|
|
||||
|
String[] deptPids = pids.split(StrConstant.COMMA); |
||||
|
// 查询机构及父级机构
|
||||
|
List<DeptLevelAndLeaderDTO> deptList = sysDeptDao.selectListDeptAndParents(deptId, deptPids); |
||||
|
|
||||
|
DeptLevelAndLeaderDTO deptLevel = DeptUtils.packageDeptLevelDto(deptPids, deptList); |
||||
|
|
||||
|
ReportMaCodeEntity reportMaCodeEntity = ConvertUtils.sourceToTarget(deptLevel, ReportMaCodeEntity.class); |
||||
|
if (null == reportMaCodeEntity) { |
||||
|
return null; |
||||
|
} |
||||
|
reportMaCodeEntity.setGrid(deptLevel.getDeptName()); |
||||
|
reportMaCodeEntity.setGridId(deptLevel.getDeptId()); |
||||
|
reportMaCodeEntity.setLeaderFlag(YesOrNoEnum.NO.value()); |
||||
|
|
||||
|
return reportMaCodeEntity; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建微信小程序码,并上传到oss |
||||
|
* |
||||
|
* @param param 小程序码的参数 |
||||
|
* @param pageUrl 小程序码的跳转链接 |
||||
|
* @return java.lang.String 小程序码的下载抵制 |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2019/10/22 10:14 |
||||
|
*/ |
||||
|
private String createMaCode(String param, String pageUrl) { |
||||
|
File wxaCodeUnlimit; |
||||
|
try { |
||||
|
wxaCodeUnlimit = wxMaServiceUtils.normalWxMaService().getQrcodeService() |
||||
|
.createWxaCodeUnlimit(param, pageUrl, 1280, true, null, false); |
||||
|
} catch (WxErrorException e) { |
||||
|
throw new RenException("请求微信接口失败"); |
||||
|
} |
||||
|
|
||||
|
UploadToOssDTO dto = new UploadToOssDTO(); |
||||
|
dto.setFileByte(this.fileToByteArray(wxaCodeUnlimit)); |
||||
|
dto.setFileName(wxaCodeUnlimit.getName()); |
||||
|
|
||||
|
Result<String> ossResult = ossFeignClient.uploadFile(dto); |
||||
|
if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { |
||||
|
throw new RenException("小程序码上传失败"); |
||||
|
} |
||||
|
return ossResult.getData(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* File文件转为byte[] |
||||
|
* |
||||
|
* @param file |
||||
|
* @return byte[] |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2019/9/19 15:56 |
||||
|
*/ |
||||
|
private byte[] fileToByteArray(File file) { |
||||
|
try { |
||||
|
//获取输入流
|
||||
|
FileInputStream fis = new FileInputStream(file); |
||||
|
//新的 byte 数组输出流,缓冲区容量1024byte
|
||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); |
||||
|
//缓存
|
||||
|
byte[] b = new byte[1024]; |
||||
|
int n; |
||||
|
while ((n = fis.read(b)) != NumConstant.ONE_NEG) { |
||||
|
bos.write(b, NumConstant.ZERO, n); |
||||
|
} |
||||
|
fis.close(); |
||||
|
//改变为byte[]
|
||||
|
byte[] data = bos.toByteArray(); |
||||
|
bos.close(); |
||||
|
return data; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,76 @@ |
|||||
|
<?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.elink.esua.epdc.dao.ReportMaCodeDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.entity.ReportMaCodeEntity" id="reportMaCodeMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="gridId" column="GRID_ID"/> |
||||
|
<result property="codeUrl" column="CODE_URL"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="leaderFlag" column="LEADER_FLAG"/> |
||||
|
<result property="grid" column="GRID"/> |
||||
|
<result property="parentDeptIds" column="PARENT_DEPT_IDS"/> |
||||
|
<result property="parentDeptNames" column="PARENT_DEPT_NAMES"/> |
||||
|
<result property="allDeptIds" column="ALL_DEPT_IDS"/> |
||||
|
<result property="allDeptNames" column="ALL_DEPT_NAMES"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<select id="selectListDeptMaCode" resultType="com.elink.esua.epdc.dto.ReportMaCodeDTO"> |
||||
|
SELECT |
||||
|
ds.`name` street, |
||||
|
dc.`name` community, |
||||
|
dg.`name` grid, |
||||
|
dg.id AS GRID_ID, |
||||
|
ed.CREATED_TIME, |
||||
|
ed.ID, |
||||
|
ed.leader_flag, |
||||
|
ed.CODE_URL |
||||
|
FROM |
||||
|
sys_dept dg |
||||
|
LEFT JOIN epdc_report_ma_code ed ON dg.id = ed.GRID_ID and ed.del_flag = '0' |
||||
|
LEFT JOIN sys_dept dc ON dg.pid = dc.id |
||||
|
LEFT JOIN sys_dept ds ON dc.pid = ds.id |
||||
|
WHERE |
||||
|
dg.type_key = 'grid_party' and dg.del_flag = '0' |
||||
|
<if test="streetId != null and streetId != ''">and ds.id = #{streetId}</if> |
||||
|
<if test="communityId != null and communityId != ''">and dc.id = #{communityId}</if> |
||||
|
<if test="gridId != null and gridId != ''">and dg.id = #{gridId}</if> |
||||
|
<if test='dataScopeDeptIds != null and dataScopeDeptIds.size() > 0'> |
||||
|
AND ma.grid_id IN <foreach collection="dataScopeDeptIds" open="(" separator="," close=")" item="deptId">#{deptId}</foreach> |
||||
|
</if> |
||||
|
ORDER BY |
||||
|
dc.`name` asc,dg.`name` asc |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectListNoCodeGridId" resultType="java.lang.Long"> |
||||
|
SELECT |
||||
|
d.id |
||||
|
FROM |
||||
|
sys_dept d |
||||
|
WHERE |
||||
|
d.type_key = 'grid_party' |
||||
|
AND NOT EXISTS (SELECT 1 FROM epdc_report_ma_code e WHERE e.GRID_ID = d.id AND e.DEL_FLAG = '0') |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectListDeptIdByTypeKey" |
||||
|
resultType="com.elink.esua.epdc.entity.ReportMaCodeEntity"> |
||||
|
SELECT |
||||
|
t.id as gridId,t.pids as parentDeptIds |
||||
|
FROM |
||||
|
sys_dept t |
||||
|
WHERE |
||||
|
t.type_key = #{typeKey} AND t.del_flag = '0' |
||||
|
AND NOT EXISTS (SELECT 1 FROM epdc_report_ma_code c WHERE c.GRID_ID = t.id AND c.del_flag = '0') |
||||
|
<if test="dataScopeDeptIds != null and dataScopeDeptIds.size() > 0"> |
||||
|
AND t.id IN <foreach collection="dataScopeDeptIds" open="(" separator="," close=")" item="deptId">#{deptId}</foreach> |
||||
|
</if> |
||||
|
ORDER BY t.update_date ASC; |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue