Przeglądaj źródła

数据权限提交

Zimo 2 tygodni temu
rodzic
commit
59afe79cef

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/config/PmsDataPermissionConfiguration.java

@@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentRepor
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.QhseAccidentCaseDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.IotMeasureCertDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseCertPersonDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseOrgCertDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.devicecert.QhseDeviceCertDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.emergency.QhseEmergencyBookDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.emergency.QhseEmergencyCertDO;
@@ -89,6 +90,7 @@ public class PmsDataPermissionConfiguration {
             rule.addDeptColumn(QhseFileTreeDO.class, "dept_id");
             rule.addDeptColumn(QhseInfoDO.class, "dept_id");
             rule.addDeptColumn(IotWebtopoProjectDO.class, "dept_id");
+            rule.addDeptColumn(QhseOrgCertDO.class, "dept_id");
             // user
 //            rule.addUserColumn(SupplierDO.class);
             rule.addUserColumn(AdminUserDO.class, "id");

+ 6 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/inspect/order/vo/IotInspectOrderDetailPageReqVO.java

@@ -1,11 +1,14 @@
 package cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo;
 
-import lombok.*;
-import java.util.*;
-import io.swagger.v3.oas.annotations.media.Schema;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
+
 import java.time.LocalDateTime;
+import java.util.Set;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 

+ 64 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/report/QhseMonthReportController.java

@@ -6,15 +6,19 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.report.vo.QhseMonthReportPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.report.vo.QhseMonthReportRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.qhse.report.vo.QhseMonthReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.report.QhseMonthReportDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.report.QhseMonthReportMapper;
 import cn.iocoder.yudao.module.pms.service.qhse.report.QhseMonthReportService;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 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.service.dept.DeptService;
+import com.google.common.collect.ImmutableMap;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -27,8 +31,10 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
@@ -47,6 +53,10 @@ public class QhseMonthReportController {
     private AdminUserApi adminUserApi;
     @Autowired
     private DeptApi deptApi;
+    @Autowired
+    private DeptService deptService;
+    @Autowired
+    private QhseMonthReportMapper qhseMonthReportMapper;
 
     @PostMapping("/create")
     @Operation(summary = "创建资料")
@@ -85,6 +95,13 @@ public class QhseMonthReportController {
     @Operation(summary = "获得资料分页")
     @PreAuthorize("@ss.hasPermission('rq:qhse-month-report:query')")
     public CommonResult<PageResult<QhseMonthReportRespVO>> getQhseMonthReportPage(@Valid QhseMonthReportPageReqVO pageReqVO) {
+        Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(loginUserDeptId)) {
+            ids = deptService.getChildDeptIdListFromCache(loginUserDeptId);
+            ids.add(loginUserDeptId);
+        }
+        pageReqVO.setDeptIds(ids);
         PageResult<QhseMonthReportDO> pageResult = qhseMonthReportService.getQhseMonthReportPage(pageReqVO);
         List<QhseMonthReportRespVO> collect = pageResult.getList().stream().map(e -> {
             QhseMonthReportRespVO qhseMonthReportRespVO = new QhseMonthReportRespVO();
@@ -127,4 +144,51 @@ public class QhseMonthReportController {
                         BeanUtils.toBean(list, QhseMonthReportRespVO.class));
     }
 
+
+    @PostMapping("/approval/{id}")
+    public CommonResult<String> approvalMonthReport(@PathVariable Long id) {
+        assert Objects.nonNull(id);
+        QhseMonthReportDO qhseMonthReport = qhseMonthReportService.getQhseMonthReport(id);
+        qhseMonthReport.setStatus("approved");//审批通过
+        qhseMonthReportMapper.updateById(qhseMonthReport);
+        return success("审批完成");
+    }
+    @PostMapping("/reject")
+    public CommonResult<String> rejectMonthReport(@RequestBody ImmutableMap<String, String> map) {
+        assert Objects.nonNull(map);
+        Long id = Long.parseLong(map.get("id").toString());
+        String rejectDesc = map.get("rejectDesc").toString();
+        QhseMonthReportDO qhseMonthReport = qhseMonthReportService.getQhseMonthReport(id);
+        qhseMonthReport.setStatus("reject");//审批拒绝
+        qhseMonthReport.setRejectDesc(rejectDesc);
+        qhseMonthReportMapper.updateById(qhseMonthReport);
+        return success("审批完成");
+    }
+//
+//    @GetMapping("/company/page")
+//    @Operation(summary = "获得公司级别的月报分页")
+//    @PreAuthorize("@ss.hasPermission('rq:qhse-month-report:query')")
+//    public CommonResult<PageResult<QhseMonthReportRespVO>> getQhseMonthReportCompanyPage(@Valid QhseMonthReportPageReqVO pageReqVO) {
+//        PageResult<QhseMonthReportDO> pageResult = qhseMonthReportService.getQhseMonthReportPage(pageReqVO);
+//        List<QhseMonthReportRespVO> collect = pageResult.getList().stream().map(e -> {
+//            QhseMonthReportRespVO qhseMonthReportRespVO = new QhseMonthReportRespVO();
+//            BeanUtils.copyProperties(e, qhseMonthReportRespVO);
+//            if (Objects.nonNull(qhseMonthReportRespVO.getDutyPerson())){
+//                AdminUserRespDTO user = adminUserApi.getUser(qhseMonthReportRespVO.getDutyPerson());
+//                if (Objects.nonNull(user)){
+//                    qhseMonthReportRespVO.setPersonName(user.getNickname());
+//                }
+//            }
+//            if (Objects.nonNull(qhseMonthReportRespVO.getDeptId())){
+//                DeptRespDTO dept = deptApi.getDept(qhseMonthReportRespVO.getDeptId());
+//                if (Objects.nonNull(dept)){
+//                    qhseMonthReportRespVO.setDeptName(dept.getName());
+//                }
+//            }
+//            return qhseMonthReportRespVO;
+//        }).collect(Collectors.toList());
+//        return success(new PageResult<>(collect, pageResult.getTotal()));
+//    }
+
+
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/report/vo/QhseMonthReportPageReqVO.java

@@ -8,6 +8,7 @@ import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
+import java.util.Set;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
@@ -122,4 +123,5 @@ public class QhseMonthReportPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    private Set<Long> deptIds;
 }

+ 6 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/report/vo/QhseMonthReportRespVO.java

@@ -24,6 +24,9 @@ public class QhseMonthReportRespVO {
     @Schema(description = "部门id")
     private Long deptId;
 
+    @Schema(description = "月报审批状态")
+    private String status;
+
     @Schema(description = "员工人数", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("员工人数")
     private String employee;
@@ -159,4 +162,7 @@ public class QhseMonthReportRespVO {
     private String personName;
 
     private String deptName;
+
+    @Schema(description = "拒绝描述")
+    private String rejectDesc;
 }

+ 8 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/report/QhseMonthReportDO.java

@@ -30,6 +30,10 @@ public class QhseMonthReportDO extends BaseDO {
      * 月报名称
      */
     private String title;
+    /**
+     * 月报审批状态
+     */
+    private String status;
     /**
      * 年月
      */
@@ -167,4 +171,8 @@ public class QhseMonthReportDO extends BaseDO {
      */
     private String remark;
 
+    /**
+     * 拒绝描述
+     */
+    private String rejectDesc;
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/report/QhseMonthReportMapper.java

@@ -23,6 +23,7 @@ public interface QhseMonthReportMapper extends BaseMapperX<QhseMonthReportDO> {
     default PageResult<QhseMonthReportDO> selectPage(QhseMonthReportPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<QhseMonthReportDO>()
                 .eqIfPresent(QhseMonthReportDO::getEmployee, reqVO.getEmployee())
+                .inIfPresent(QhseMonthReportDO::getDeptId, reqVO.getDeptIds())
                 .eqIfPresent(QhseMonthReportDO::getSubcontractors, reqVO.getSubcontractors())
                 .eqIfPresent(QhseMonthReportDO::getDrivingMileage, reqVO.getDrivingMileage())
                 .eqIfPresent(QhseMonthReportDO::getTotalManHours, reqVO.getTotalManHours())
@@ -55,6 +56,7 @@ public interface QhseMonthReportMapper extends BaseMapperX<QhseMonthReportDO> {
                 .eqIfPresent(QhseMonthReportDO::getRemark, reqVO.getRemark())
                 .eqIfPresent(QhseMonthReportDO::getTitle, reqVO.getTitle())
                 .betweenIfPresent(QhseMonthReportDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(QhseMonthReportDO::getYearMonths, reqVO.getYearMonths())
                 .orderByDesc(QhseMonthReportDO::getId));
     }
 

+ 29 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/qhse/MonthReportJob.java

@@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.system.api.permission.RoleApi;
 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.service.dept.DeptService;
+import com.google.common.collect.ImmutableList;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
@@ -64,7 +65,7 @@ public class MonthReportJob implements JobHandler {
         LocalDateTime lastDayOfLastMonth = getLastDayOfLastMonth();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
         String yearMonth = firstDayOfLastMonth.format(formatter);
-        List<Long> userIds = roleApi.getRoleUserIds("QHSE月报");
+        List<Long> userIds = roleApi.getRoleUserIds("QHSE月报填报");
         userIds.forEach(e ->{
             Set<Long> ids = new HashSet<>();
             AdminUserRespDTO user = adminUserApi.getUser(e);
@@ -100,6 +101,33 @@ public class MonthReportJob implements JobHandler {
                 });
             });
         });
+        ImmutableList.of(156L,157L,158L,163L).forEach(e ->{
+            Set<Long> ids = new HashSet<>();
+            ids = deptService.getChildDeptIdListFromCache(e);
+            ids.add(e);
+            IotSocSummaryPageReqVO pageReqVO = new IotSocSummaryPageReqVO();
+            pageReqVO.setObservationDate(new LocalDateTime[]{firstDayOfLastMonth, lastDayOfLastMonth});
+            Long socCount = iotSocSummaryMapper.selectCountBySocClassAndTime(pageReqVO, ids);
+            QhseJsaPageReqVO qhseJsaPageReqVO = new QhseJsaPageReqVO();
+            qhseJsaPageReqVO.setJsaTime(new LocalDateTime[]{firstDayOfLastMonth, lastDayOfLastMonth});
+            Long jsaCount = qhseJsaMapper.selectCountByDeptAndTime(qhseJsaPageReqVO, ids);
+            QhsePtwPageReqVO qhsePtwPageReqVO = new QhsePtwPageReqVO();
+            qhsePtwPageReqVO.setPtwTime(new LocalDateTime[]{firstDayOfLastMonth, lastDayOfLastMonth});
+            Long ptwCount = qhsePtwMapper.selectCountByDeptAndTime(qhsePtwPageReqVO, ids);
+
+
+            QhseMonthReportDO reportDO = new QhseMonthReportDO();
+            DeptRespDTO dept = deptApi.getDept(e);
+            reportDO.setTitle(dept.getName()+yearMonth+"QHSE月报");
+            reportDO.setYearMonths(yearMonth);
+            reportDO.setDeleted(false);
+            reportDO.setSocCards(String.valueOf(socCount));
+            reportDO.setJsa(String.valueOf(jsaCount));
+            reportDO.setPtwAudit(String.valueOf(ptwCount));
+//            reportDO.setDutyPerson();
+            reportDO.setDeptId(e);
+            qhseMonthReportMapper.insert(reportDO);
+        });
         return "";
     }
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/report/QhseMonthReportServiceImpl.java

@@ -41,6 +41,8 @@ public class QhseMonthReportServiceImpl implements QhseMonthReportService {
         // 插入
         QhseMonthReportDO qhseMonthReport = BeanUtils.toBean(createReqVO, QhseMonthReportDO.class);
         qhseMonthReport.setDeleted(false);
+        //待审批
+        qhseMonthReport.setStatus("approving");
         qhseMonthReportMapper.insert(qhseMonthReport);
         // 返回
         return qhseMonthReport.getId();