Compare commits
3 Commits
a94700e4f6
...
324b241e12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
324b241e12 | ||
|
|
ec37eaf03b | ||
|
|
18e1ed5e68 |
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.staff.controller.admin;
|
package cn.iocoder.yudao.module.staff.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
@ -15,6 +16,8 @@ import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO;
|
|||||||
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
|
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
|
||||||
import cn.iocoder.yudao.module.staff.vo.StaffLoginBody;
|
import cn.iocoder.yudao.module.staff.vo.StaffLoginBody;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
||||||
@ -40,6 +43,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -63,6 +67,8 @@ public class CompanyStaffController {
|
|||||||
private AdminAuthService loginService;
|
private AdminAuthService loginService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiAppLoginService apiAppLoginService;
|
private ApiAppLoginService apiAppLoginService;
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
@ -326,4 +332,25 @@ public class CompanyStaffController {
|
|||||||
return error(2_002_000_005,e.getMessage());
|
return error(2_002_000_005,e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID获取信息
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 15:12 2024/12/18
|
||||||
|
* @param id 用户ID
|
||||||
|
**/
|
||||||
|
@GetMapping("/getByUserId")
|
||||||
|
public CommonResult<?> getByUserId(@RequestParam("id")Long id){
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
List<CompanyStaff> list = staffService.list(new LambdaQueryWrapper<CompanyStaff>().eq(CompanyStaff::getUserId, id));
|
||||||
|
if (CollUtil.isNotEmpty(list)){
|
||||||
|
map.put("staff", list.get(0));
|
||||||
|
}
|
||||||
|
AdminUserRespDTO user = adminUserApi.getUser(id);
|
||||||
|
if (ObjectUtil.isNotEmpty(user)){
|
||||||
|
map.put("user", user);
|
||||||
|
}
|
||||||
|
return success(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,9 @@ public enum InspectionRoleCommon {
|
|||||||
/** 检测业务管理员 */
|
/** 检测业务管理员 */
|
||||||
JIANCE("jiance", 1),
|
JIANCE("jiance", 1),
|
||||||
|
|
||||||
|
/** 站长 */
|
||||||
|
JCZZ("jczz", 1),
|
||||||
|
|
||||||
/** 检测站老板 */
|
/** 检测站老板 */
|
||||||
JCBOSS("jcboss", 1),
|
JCBOSS("jcboss", 1),
|
||||||
|
|
||||||
@ -66,6 +69,30 @@ public enum InspectionRoleCommon {
|
|||||||
/** 检测用户 */
|
/** 检测用户 */
|
||||||
JCYH("jcyh", 4),
|
JCYH("jcyh", 4),
|
||||||
|
|
||||||
|
/** 安检外检 */
|
||||||
|
JCAJWJ("jcajwj", 4),
|
||||||
|
|
||||||
|
/** 收费登录 */
|
||||||
|
JCSFDL("jcsfdl", 4),
|
||||||
|
|
||||||
|
/** 环检外检 */
|
||||||
|
JCHJWJ("jchjwj", 4),
|
||||||
|
|
||||||
|
/** 底盘检测 */
|
||||||
|
JCDPJC("jcdpjc", 4),
|
||||||
|
|
||||||
|
/** 环检操作 */
|
||||||
|
JCHJCZ("jchjcz", 4),
|
||||||
|
|
||||||
|
/** 检测总检 */
|
||||||
|
JCZJ("jczj", 4),
|
||||||
|
|
||||||
|
/** 检测资料管理员 */
|
||||||
|
JCZLGLY("jczlgly", 4),
|
||||||
|
|
||||||
|
/** 安全检验员 */
|
||||||
|
AQJYY("aqjyy", 4),
|
||||||
|
|
||||||
/** 检测员工 */
|
/** 检测员工 */
|
||||||
JCWORKER("jcworker", 4);
|
JCWORKER("jcworker", 4);
|
||||||
|
|
||||||
|
|||||||
@ -359,4 +359,15 @@ public class InspectionInfoController extends BaseController {
|
|||||||
String name = inspectionInfoService.easyPoiExport("template/word/四川省超标排放汽车维护修理告知书.docx", str, map, request, response);
|
String name = inspectionInfoService.easyPoiExport("template/word/四川省超标排放汽车维护修理告知书.docx", str, map, request, response);
|
||||||
return CommonResult.success(name);
|
return CommonResult.success(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得不同状态的数据的数量
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 16:22 2024/12/18
|
||||||
|
**/
|
||||||
|
@GetMapping("/getCountByType")
|
||||||
|
public CommonResult<?> getCountByType(@RequestParam("partnerId")Integer partnerId){
|
||||||
|
return success(inspectionInfoService.getCountByType(partnerId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.inspection.controller;
|
package cn.iocoder.yudao.module.inspection.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.inspection.entity.InspectionNews;
|
import cn.iocoder.yudao.module.inspection.entity.InspectionNews;
|
||||||
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsService;
|
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsService;
|
||||||
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
|
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -13,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import cn.iocoder.yudao.module.core.controller.BaseController;
|
import cn.iocoder.yudao.module.core.controller.BaseController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Controller
|
* 【请填写功能名称】Controller
|
||||||
*
|
*
|
||||||
@ -26,6 +35,15 @@ public class InspectionNewsController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IInspectionNewsService inspectionNewsService;
|
private IInspectionNewsService inspectionNewsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictDataApi dataApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PermissionApi permissionApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RoleApi roleApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
*/
|
*/
|
||||||
@ -63,4 +81,22 @@ public class InspectionNewsController extends BaseController
|
|||||||
{
|
{
|
||||||
return toAjax(inspectionNewsService.deleteInspectionNewsByIds(ids));
|
return toAjax(inspectionNewsService.deleteInspectionNewsByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证当前登录用户是否可以发布通知
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 16:00 2024/12/18
|
||||||
|
**/
|
||||||
|
@GetMapping("/ifSend")
|
||||||
|
public CommonResult<?> ifSend(){
|
||||||
|
List<DictDataRespDTO> dataList = dataApi.getDictDataList("ins_send_news");
|
||||||
|
List<String> values = dataList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
|
||||||
|
List<Long> roleIds = permissionApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||||
|
List<RoleReqDTO> roles = roleApi.getRoleList();
|
||||||
|
List<RoleReqDTO> role = roles.stream().filter(item -> roleIds.contains(item.getId())).collect(Collectors.toList());
|
||||||
|
List<String> codes = role.stream().map(RoleReqDTO::getCode).collect(Collectors.toList());
|
||||||
|
List<String> collect = codes.stream().filter(values::contains).collect(Collectors.toList());
|
||||||
|
return success(!collect.isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,4 +139,12 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
|
|||||||
List<RoleDO> getRoleList();
|
List<RoleDO> getRoleList();
|
||||||
|
|
||||||
String easyPoiExport(String templatePath, String filename, Map<String, Object> data, HttpServletRequest request, HttpServletResponse response);
|
String easyPoiExport(String templatePath, String filename, Map<String, Object> data, HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得不同状态的数据的数量
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 16:22 2024/12/18
|
||||||
|
**/
|
||||||
|
Map<String, Long> getCountByType(Integer partnerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,11 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.afterturn.easypoi.word.WordExportUtil;
|
import cn.afterturn.easypoi.word.WordExportUtil;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
@ -623,26 +625,26 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
|||||||
/**
|
/**
|
||||||
* 判断是否可以修改引车员
|
* 判断是否可以修改引车员
|
||||||
*
|
*
|
||||||
|
* @param id 工单ID
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 15:22 2024/12/11
|
* @date 15:22 2024/12/11
|
||||||
* @param id 工单ID
|
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Boolean judgeUpdateLeadMan(Long id){
|
public Boolean judgeUpdateLeadMan(Long id) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
InspectionInfo inspectionInfo = baseMapper.selectById(id);
|
InspectionInfo inspectionInfo = baseMapper.selectById(id);
|
||||||
if (!inspectionInfo.getStatus().equals("2")){
|
if (!inspectionInfo.getStatus().equals("2")) {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
if (!result){
|
if (!result) {
|
||||||
List<InspectionWorkNode> list = workNodeService.list(new LambdaQueryWrapper<InspectionWorkNode>().eq(InspectionWorkNode::getInspectionInfoId, id));
|
List<InspectionWorkNode> list = workNodeService.list(new LambdaQueryWrapper<InspectionWorkNode>().eq(InspectionWorkNode::getInspectionInfoId, id));
|
||||||
Set<String> status = list.stream().map(InspectionWorkNode::getStatus).collect(Collectors.toSet());
|
Set<String> status = list.stream().map(InspectionWorkNode::getStatus).collect(Collectors.toSet());
|
||||||
if (status.contains("3")){
|
if (status.contains("3")) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result){
|
if (result) {
|
||||||
result = inspectionInfo.getCreator().equals(SecurityFrameworkUtils.getLoginUserId()+"");
|
result = inspectionInfo.getCreator().equals(SecurityFrameworkUtils.getLoginUserId() + "");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -663,6 +665,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* EasyPoi 替换数据 导出 word
|
* EasyPoi 替换数据 导出 word
|
||||||
|
*
|
||||||
* @param templatePath word模板地址
|
* @param templatePath word模板地址
|
||||||
* @param filename 文件名称
|
* @param filename 文件名称
|
||||||
* @param data 替换参数
|
* @param data 替换参数
|
||||||
@ -691,10 +694,71 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
|||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultipartFile convertXWPFDocumentToMultipartFile(XWPFDocument document, String filename) throws IOException {
|
public static MultipartFile convertXWPFDocumentToMultipartFile(XWPFDocument document, String filename) throws IOException {
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
document.write(bos);
|
document.write(bos);
|
||||||
byte[] bytes = bos.toByteArray();
|
byte[] bytes = bos.toByteArray();
|
||||||
return new MockMultipartFile(filename, filename, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", bytes);
|
return new MockMultipartFile(filename, filename, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得不同状态的数据的数量
|
||||||
|
*
|
||||||
|
* @author 小李
|
||||||
|
* @date 16:22 2024/12/18
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public Map<String, Long> getCountByType(Integer partnerId) {
|
||||||
|
// 创建线程池
|
||||||
|
ExecutorService executor = Executors.newFixedThreadPool(6);
|
||||||
|
|
||||||
|
try {
|
||||||
|
InspectionInfo inspectionInfo = new InspectionInfo();
|
||||||
|
inspectionInfo.setPartnerId(partnerId.longValue());
|
||||||
|
|
||||||
|
// 获取当前登录人
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
// 获取当前登陆人的角色
|
||||||
|
List<UserRoleDO> byUserId = roleService.getByUserId(loginUser.getId());
|
||||||
|
inspectionInfo.setLeadManId(loginUser.getId());
|
||||||
|
List<Long> roleIds = byUserId.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
|
||||||
|
if (!"1".equals(inspectionInfo.getStatus())) {
|
||||||
|
// 进行中 已完成
|
||||||
|
inspectionInfo.setDealUserId(loginUser.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Long> result = new ConcurrentHashMap<>(); // 使用ConcurrentHashMap以确保线程安全
|
||||||
|
|
||||||
|
// 定义一个数组来保存所有的CompletableFuture
|
||||||
|
CompletableFuture<Void>[] futures = new CompletableFuture[6];
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
final String status = String.valueOf(i);
|
||||||
|
|
||||||
|
// 复制一份inspectionInfo对象,避免多线程修改同一个对象导致的问题
|
||||||
|
InspectionInfo infoCopy = BeanUtil.toBean(inspectionInfo, InspectionInfo.class);
|
||||||
|
infoCopy.setStatus(status);
|
||||||
|
|
||||||
|
// 为每个任务创建一个新的Page对象
|
||||||
|
Page<InspectionInfo> page = new Page<>(1, 10);
|
||||||
|
|
||||||
|
futures[i] = CompletableFuture.runAsync(() -> {
|
||||||
|
IPage<InspectionInfo> iPage = baseMapper.selectByUser(page, roleIds, infoCopy);
|
||||||
|
result.put(status, iPage.getTotal());
|
||||||
|
}, executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待所有任务完成
|
||||||
|
CompletableFuture.allOf(futures).join();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to execute tasks in parallel", e);
|
||||||
|
} finally {
|
||||||
|
// 关闭线程池
|
||||||
|
executor.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -409,5 +409,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!-- </if>-->
|
<!-- </if>-->
|
||||||
<!-- </where>-->
|
<!-- </where>-->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user