Переглянути джерело

增加 了安全工具计划相关接口

lijie 4 роки тому
батько
коміт
b16c257d55
18 змінених файлів з 1193 додано та 0 видалено
  1. 92 0
      railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecScheduledController.java
  2. 63 0
      railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecScheduledToolController.java
  3. 60 0
      railway-business/src/main/java/com/railway/business/safetool/domain/SecScheduled.java
  4. 48 0
      railway-business/src/main/java/com/railway/business/safetool/domain/SecScheduledTool.java
  5. 32 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledDetailVo.java
  6. 35 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListParmVo.java
  7. 37 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo.java
  8. 34 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo2.java
  9. 24 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledToolsAddVo.java
  10. 31 0
      railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledToolsVo.java
  11. 51 0
      railway-business/src/main/java/com/railway/business/safetool/mapper/SecScheduledMapper.java
  12. 46 0
      railway-business/src/main/java/com/railway/business/safetool/mapper/SecScheduledToolMapper.java
  13. 47 0
      railway-business/src/main/java/com/railway/business/safetool/service/ISecScheduledService.java
  14. 37 0
      railway-business/src/main/java/com/railway/business/safetool/service/ISecScheduledToolService.java
  15. 153 0
      railway-business/src/main/java/com/railway/business/safetool/service/impl/SecScheduledServiceImpl.java
  16. 77 0
      railway-business/src/main/java/com/railway/business/safetool/service/impl/SecScheduledToolServiceImpl.java
  17. 177 0
      railway-business/src/main/resources/mapper/safetool/SecScheduledMapper.xml
  18. 149 0
      railway-business/src/main/resources/mapper/safetool/SecScheduledToolMapper.xml

+ 92 - 0
railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecScheduledController.java

@@ -0,0 +1,92 @@
+package com.railway.web.controller.business.safetool;
+
+
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.business.safetool.domain.vo.*;
+import com.railway.business.safetool.service.ISecScheduledService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.WebDataBinder;
+import com.railway.common.core.controller.BaseController;
+import com.railway.common.core.domain.AjaxResult;
+import com.railway.common.core.page.TableDataInfo;
+import javax.validation.Valid;
+import java.util.List;
+
+import javax.validation.Valid;
+
+@Api(value = "rest/safetool/sec/scheduled", tags = "安全工具-计划")
+@RestController
+@Validated
+@RequestMapping(value = "business/safetool/sec/scheduled")
+public class SecScheduledController extends BaseController {
+    @Autowired
+    private ISecScheduledService secScheduledService;
+
+    @ApiOperation(value = "新增")
+    @PostMapping("/add")
+    public AjaxResult add(@Validated @RequestBody SecScheduledListVo secScheduled) {
+        try {
+            return toAjax(secScheduledService.create(secScheduled));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toAjax(0);
+    }
+
+    @ApiOperation(value = "删除计划")
+    @DeleteMapping("/{ids}")
+    public AjaxResult delete(@RequestParam String[] ids) {
+        return toAjax(secScheduledService.delete(ids));
+    }
+
+//    @ApiOperation(value = "更新")
+    @PutMapping("/update")
+    public AjaxResult update(@RequestBody @Valid SecScheduled secScheduled) {
+        return toAjax(secScheduledService.update(secScheduled));
+    }
+
+    @ApiOperation(value = "查询详情")
+    @GetMapping(value = {"/", "/{id}"})
+    public AjaxResult getInfo(String id) {
+        List<SecScheduledDetailVo> info = secScheduledService.getInfo(id);
+        AjaxResult ajax = AjaxResult.success();
+        ajax.put("info",info);
+        return ajax;
+    }
+
+    @ApiOperation(value = "查询列表")
+    @GetMapping(value = "list")
+    public TableDataInfo getList(SecScheduledListParmVo secScheduled) {
+        startPage();
+        List<SecScheduledListVo2> list = secScheduledService.getList(secScheduled);
+        return getDataTable(list);
+    }
+
+
+    @ApiOperation(value = "删除计划中的安全工具")
+    @DeleteMapping(value = "delTools")
+    public AjaxResult delTools(SecScheduledToolsAddVo secScheduled) {
+        try {
+            return toAjax(secScheduledService.delTools(secScheduled));
+        } catch (Exception e) {
+            return toAjax(0);
+        }
+
+    }
+
+    @ApiOperation(value = "增加计划中的安全工具")
+    @PostMapping(value = "addTools")
+    public AjaxResult addTools(SecScheduledToolsAddVo secScheduled) {
+        try {
+            return toAjax(secScheduledService.addTools(secScheduled));
+        } catch (Exception e) {
+            return toAjax(0);
+        }
+
+    }
+}

+ 63 - 0
railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecScheduledToolController.java

@@ -0,0 +1,63 @@
+package com.railway.web.controller.business.safetool;
+
+import com.railway.business.safetool.domain.SecScheduledTool;
+import com.railway.business.safetool.service.ISecScheduledToolService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.WebDataBinder;
+import com.railway.common.core.controller.BaseController;
+import com.railway.common.core.domain.AjaxResult;
+import com.railway.common.core.page.TableDataInfo;
+import javax.validation.Valid;
+import java.util.List;
+
+import javax.validation.Valid;
+
+//@Api(value = "rest/safetool/sec/scheduled/tool", tags = "安全计划和工具关系表")
+@RestController
+@Validated
+@RequestMapping(value = "business/safetool/sec/scheduled/tool")
+public class SecScheduledToolController extends BaseController {
+    @Autowired
+    private ISecScheduledToolService secScheduledToolService;
+
+    @ApiOperation(value = "新增")
+    @PostMapping("/add")
+    public AjaxResult add(@Validated @RequestBody SecScheduledTool secScheduledTool) {
+        return toAjax(secScheduledToolService.create(secScheduledTool));
+    }
+
+    @ApiOperation(value = "删除")
+    @DeleteMapping("/{ids}")
+    public AjaxResult delete(@RequestParam String[] ids) {
+        return toAjax(secScheduledToolService.delete(ids));
+    }
+
+    @ApiOperation(value = "更新")
+    @PutMapping("/update")
+    public AjaxResult update(@RequestBody @Valid SecScheduledTool secScheduledTool) {
+        return toAjax(secScheduledToolService.update(secScheduledTool));
+    }
+
+    @ApiOperation(value = "单个")
+    @GetMapping(value = {"/", "/{id}"})
+    public AjaxResult getInfo(String id) {
+        SecScheduledTool info = secScheduledToolService.getInfo(id);
+        AjaxResult ajax = AjaxResult.success();
+        ajax.put("info",info);
+        return ajax;
+    }
+
+    @ApiOperation(value = "列表")
+    @GetMapping(value = "list")
+    public TableDataInfo getList(SecScheduledTool secScheduledTool) {
+        startPage();
+        List<SecScheduledTool> list = secScheduledToolService.getList(secScheduledTool);
+        return getDataTable(list);
+    }
+
+}

+ 60 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/SecScheduled.java

@@ -0,0 +1,60 @@
+package com.railway.business.safetool.domain;
+
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+import java.util.List;
+
+import org.hibernate.validator.constraints.Length;
+import javax.validation.constraints.NotNull;
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划表")
+@EqualsAndHashCode(callSuper = true)
+public class SecScheduled extends BaseEntity{
+
+    @ApiModelProperty(value = "主键", hidden = true)
+    protected Long id;
+
+    @ApiModelProperty(value = "车间id")
+    protected Long deptId;
+
+    @ApiModelProperty(value = "存放处所")
+    @Length(min = 1, max = 100, message = "【存放处所】长度必须介于 {min} 和 {max} 之间")
+    protected String storePlace;
+
+    @ApiModelProperty(value = "实验室id 部门表类型为实验室")
+    protected Long labId;
+
+    @ApiModelProperty(value = "计划送检日期")
+    protected Date scheduledTime;
+
+    @ApiModelProperty(value = "状态,0待送检,1已送检" )
+    @Length(min = 1, max = 1, message = "【状态,0待送检,1已送检】长度必须介于 {min} 和 {max} 之间")
+    protected String state;
+
+    @ApiModelProperty(value = "del_flag", hidden = true)
+    @Length(min = 1, max = 1, message = "【del_flag】长度必须介于 {min} 和 {max} 之间")
+    protected String delFlag;
+
+    @ApiModelProperty(value = "create_by", hidden = true)
+    @Length(min = 1, max = 64, message = "【create_by】长度必须介于 {min} 和 {max} 之间")
+    protected String createBy;
+
+    @ApiModelProperty(value = "update_by", hidden = true)
+    @Length(min = 1, max = 64, message = "【update_by】长度必须介于 {min} 和 {max} 之间")
+    protected String updateBy;
+
+    @ApiModelProperty(value = "update_time", hidden = true)
+    protected Date updateTime;
+
+    public SecScheduled() {
+    }
+
+}

+ 48 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/SecScheduledTool.java

@@ -0,0 +1,48 @@
+package com.railway.business.safetool.domain;
+
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+
+import org.hibernate.validator.constraints.Length;
+import javax.validation.constraints.NotNull;
+/**
+ * 安全计划和工具关系表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全计划和工具关系表")
+@EqualsAndHashCode(callSuper = true)
+public class SecScheduledTool extends BaseEntity{
+
+    @ApiModelProperty(value = "主键", hidden = true)
+    private Long id;
+
+    @ApiModelProperty(value = "计划id")
+    private Long scheduledId;
+
+    @ApiModelProperty(value = "工具id")
+    private Long toolId;
+
+    @ApiModelProperty(value = "del_flag")
+    @Length(min = 1, max = 1, message = "【del_flag】长度必须介于 {min} 和 {max} 之间")
+    private String delFlag;
+
+    @ApiModelProperty(value = "create_by")
+    @Length(min = 1, max = 64, message = "【create_by】长度必须介于 {min} 和 {max} 之间")
+    private String createBy;
+
+    @ApiModelProperty(value = "update_by")
+    @Length(min = 1, max = 64, message = "【update_by】长度必须介于 {min} 和 {max} 之间")
+    private String updateBy;
+
+    @ApiModelProperty(value = "update_time")
+    private Date updateTime;
+
+    public SecScheduledTool() {
+    }
+
+}

+ 32 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledDetailVo.java

@@ -0,0 +1,32 @@
+package com.railway.business.safetool.domain.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划详情 待送检工具")
+public class SecScheduledDetailVo implements Serializable {
+
+
+    @ApiModelProperty(value = "工具名")
+    private String toolName;
+
+    @ApiModelProperty(value = "数量")
+    private String c;
+
+    @ApiModelProperty(value = "单位")
+    private String unit;
+
+
+    @ApiModelProperty(value = "分组数据")
+    private List<SecScheduledToolsVo> baseSafetyTools;
+
+}

+ 35 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListParmVo.java

@@ -0,0 +1,35 @@
+package com.railway.business.safetool.domain.vo;
+
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划查询参数")
+public class SecScheduledListParmVo implements Serializable {
+
+
+    @ApiModelProperty(value = "车间id")
+    protected Long deptId;
+
+    @ApiModelProperty(value = "存放处所")
+    protected String storePlace;
+
+    @ApiModelProperty(value = "排序方式 asc desc")
+    protected String orderby;
+
+
+    public SecScheduledListParmVo() {
+    }
+
+}

+ 37 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo.java

@@ -0,0 +1,37 @@
+package com.railway.business.safetool.domain.vo;
+
+import com.railway.business.safetool.domain.BaseSafetyTool;
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划表")
+@EqualsAndHashCode(callSuper = true)
+public class SecScheduledListVo extends SecScheduled {
+
+    //计划包含的安全工具集合
+    @ApiModelProperty(value = "baseSafetyTools")
+    private List<SecScheduledToolsVo> baseSafetyTools;
+
+    @ApiModelProperty(value = "车间名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "实验室名称")
+    private String labName;
+
+    public SecScheduledListVo() {
+    }
+
+}

+ 34 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo2.java

@@ -0,0 +1,34 @@
+package com.railway.business.safetool.domain.vo;
+
+import com.railway.business.safetool.domain.SecScheduled;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划表")
+@EqualsAndHashCode(callSuper = true)
+public class SecScheduledListVo2 extends SecScheduled {
+
+    //计划包含的安全工具集合
+
+    @ApiModelProperty(value = "车间名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "实验室名称")
+    private String labName;
+
+    @ApiModelProperty(value = "工具总数")
+    private String c;
+
+    public SecScheduledListVo2() {
+    }
+
+}

+ 24 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledToolsAddVo.java

@@ -0,0 +1,24 @@
+package com.railway.business.safetool.domain.vo;
+
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划内显示的工具")
+@EqualsAndHashCode(callSuper = true)
+public class SecScheduledToolsAddVo extends SecScheduledToolsVo{
+
+    @ApiModelProperty(value = "计划ID")
+    protected Long scheduledId;
+
+    public SecScheduledToolsAddVo() {
+    }
+
+}

+ 31 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledToolsVo.java

@@ -0,0 +1,31 @@
+package com.railway.business.safetool.domain.vo;
+
+import com.railway.business.safetool.domain.BaseSafetyTool;
+import com.railway.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.validator.constraints.Length;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 安全工具计划表
+ * @author lijie 2021-12-04
+ */
+@Data
+@ApiModel("安全工具计划内显示的工具")
+public class SecScheduledToolsVo implements Serializable {
+    @ApiModelProperty(value = "主键")
+    protected Long toolId;
+
+    @ApiModelProperty(value = "编号")
+    protected String toolCode;
+
+    public SecScheduledToolsVo() {
+    }
+
+}

+ 51 - 0
railway-business/src/main/java/com/railway/business/safetool/mapper/SecScheduledMapper.java

@@ -0,0 +1,51 @@
+package com.railway.business.safetool.mapper;
+
+import com.github.pagehelper.Page;
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.business.safetool.domain.vo.SecScheduledDetailVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListParmVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo2;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+* 安全工具计划表
+* @author lijie
+* @date 2021/12/04
+*/
+@Mapper
+@Repository
+public interface SecScheduledMapper {
+
+    /**
+    * 新增
+    */
+    int insert(SecScheduled secScheduled);
+
+    /**
+    * 删除
+    */
+    int delete(@Param("id") String id);
+
+    /**
+    * 更新
+    */
+    int update(SecScheduled secScheduled);
+
+    /**
+    * 获取单个
+    */
+    List<SecScheduledDetailVo> getInfo(@Param("id") String id);
+
+    /**
+    * 查询列表
+    */
+    Page<SecScheduledListVo2> getList(SecScheduledListParmVo secScheduled);
+
+//    List<SecScheduledListVo> getList(SecScheduled secScheduled);
+
+}

+ 46 - 0
railway-business/src/main/java/com/railway/business/safetool/mapper/SecScheduledToolMapper.java

@@ -0,0 +1,46 @@
+package com.railway.business.safetool.mapper;
+
+import com.github.pagehelper.Page;
+import com.railway.business.safetool.domain.SecScheduledTool;
+import com.railway.business.safetool.domain.vo.SecScheduledToolsAddVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+/**
+* 安全计划和工具关系表
+* @author lijie
+* @date 2021/12/04
+*/
+@Mapper
+@Repository
+public interface SecScheduledToolMapper {
+
+    /**
+    * 新增
+    */
+    int insert(SecScheduledTool secScheduledTool);
+    int check(SecScheduledTool secScheduledTool);
+    int checkdel(SecScheduledToolsAddVo secScheduledTool);
+
+    /**
+    * 删除
+    */
+    int delete(SecScheduledToolsAddVo secScheduledTool);
+
+    /**
+    * 更新
+    */
+    int update(SecScheduledTool secScheduledTool);
+
+    /**
+    * 获取单个
+    */
+    SecScheduledTool getInfo(@Param("id") String id);
+
+    /**
+    * 查询列表
+    */
+    Page<SecScheduledTool> getList(SecScheduledTool secScheduledTool);
+
+}

+ 47 - 0
railway-business/src/main/java/com/railway/business/safetool/service/ISecScheduledService.java

@@ -0,0 +1,47 @@
+package com.railway.business.safetool.service;
+
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.business.safetool.domain.SecScheduledTool;
+import com.railway.business.safetool.domain.vo.*;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+/**
+* 安全工具计划表
+* @author lijie
+* @date 2021/12/04
+*/
+public interface ISecScheduledService{
+
+    /**
+    * 新增
+    */
+    int create(SecScheduledListVo secScheduled) throws Exception;
+
+    /**
+    * 删除
+    */
+    int delete(String[] ids);
+
+    /**
+    * 更新
+    */
+    int update(SecScheduled secScheduled);
+
+    /**
+    * 获取单个
+    */
+    List<SecScheduledDetailVo> getInfo(String id);
+
+    /**
+    * 查询列表
+    */
+    List<SecScheduledListVo2> getList(SecScheduledListParmVo secScheduled);
+
+
+
+     int delTools(SecScheduledToolsAddVo secScheduled) throws Exception ;
+
+
+     int addTools(SecScheduledToolsAddVo toolsVo) ;
+}

+ 37 - 0
railway-business/src/main/java/com/railway/business/safetool/service/ISecScheduledToolService.java

@@ -0,0 +1,37 @@
+package com.railway.business.safetool.service;
+
+import com.railway.business.safetool.domain.SecScheduledTool;
+import java.util.List;
+/**
+* 安全计划和工具关系表
+* @author lijie
+* @date 2021/12/04
+*/
+public interface ISecScheduledToolService{
+
+    /**
+    * 新增
+    */
+    int create(SecScheduledTool secScheduledTool);
+
+    /**
+    * 删除
+    */
+    int delete(String[] ids);
+
+    /**
+    * 更新
+    */
+    int update(SecScheduledTool secScheduledTool);
+
+    /**
+    * 获取单个
+    */
+    SecScheduledTool getInfo(String id);
+
+    /**
+    * 查询列表
+    */
+    List<SecScheduledTool> getList(SecScheduledTool secScheduledTool);
+
+}

+ 153 - 0
railway-business/src/main/java/com/railway/business/safetool/service/impl/SecScheduledServiceImpl.java

@@ -0,0 +1,153 @@
+package com.railway.business.safetool.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.railway.business.safetool.domain.BaseSafetyTool;
+import com.railway.business.safetool.domain.SecScheduledTool;
+import com.railway.business.safetool.domain.vo.*;
+import com.railway.business.safetool.mapper.SecScheduledMapper;
+import com.railway.business.safetool.domain.SecScheduled;
+import com.railway.business.safetool.mapper.SecScheduledToolMapper;
+import com.railway.business.safetool.service.ISecScheduledService;
+import com.railway.common.core.page.TableDataInfo;
+import com.railway.common.utils.bean.BeanUtils;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.railway.common.utils.SecurityUtils;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Date;
+/**
+* 安全工具计划表
+* @author lijie
+* @date 2021/12/04
+*/
+@Service
+@Transactional(readOnly = true)
+public class SecScheduledServiceImpl implements ISecScheduledService{
+@Autowired
+private SecScheduledMapper secScheduledMapper;
+	@Autowired
+	private SecScheduledToolMapper secScheduledToolMapper;
+	/**
+	* 新增
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int create(SecScheduledListVo secScheduled) throws Exception {
+	    secScheduled.setCreateTime(new Date());
+        secScheduled.setCreateBy(SecurityUtils.getUsername());
+		List<SecScheduledToolsVo> baseSafetyTools = secScheduled.getBaseSafetyTools() ;
+
+		if (CollectionUtils.isEmpty(baseSafetyTools))
+		{
+			throw new Exception("安全工具不能为空");
+		}
+		SecScheduled s = new SecScheduled();
+		BeanUtils.copyBeanProp(s,secScheduled);
+		int r = secScheduledMapper.insert(s);
+		if (r<1){
+			throw new Exception("计划插入失败");
+		}
+		for (SecScheduledToolsVo t:baseSafetyTools) {
+			SecScheduledTool secScheduledTool = new SecScheduledTool();
+			secScheduledTool.setScheduledId(s.getId());
+			secScheduledTool.setToolId(t.getToolId());
+			r = secScheduledToolMapper.insert(secScheduledTool);
+			if (r<1){
+				throw new Exception("计划关系插入失败");
+			}
+		}
+		return  1;
+	}
+
+	/**
+	* 删除
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int delete(String[] ids) {
+		int r =0;
+		for (String id : ids) {
+			int j= secScheduledMapper.delete(id);
+			r = r + j;
+		}
+		return	r;
+	}
+
+	/**
+	* 更新
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int update(SecScheduled secScheduled) {
+		secScheduled.setUpdateTime(new Date());
+    	secScheduled.setUpdateBy(SecurityUtils.getUsername());
+		return secScheduledMapper.update(secScheduled);
+	}
+
+	/**
+	* 获取单个
+	*/
+	@Override
+	public List<SecScheduledDetailVo> getInfo(String id) {
+		List<SecScheduledDetailVo> r = secScheduledMapper.getInfo(id);
+		r.forEach( vo->
+				vo.setC(vo.getBaseSafetyTools().size()+"")
+				);
+		return r;
+	}
+
+	/**
+	* 查询列表
+	*/
+	@Override
+	public List<SecScheduledListVo2> getList(SecScheduledListParmVo secScheduled) {
+		secScheduled.setDeptId(SecurityUtils.getLoginUser().getDeptId());
+		List<SecScheduledListVo2> r = secScheduledMapper.getList(secScheduled);
+		if (!CollectionUtils.isEmpty(r)&&r.size()==1){
+				if ("0件".equals(r.get(0).getC())) {
+					return new ArrayList<>();
+				}
+			}
+		return r;
+	}
+
+
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int delTools(SecScheduledToolsAddVo secScheduled) throws Exception {
+
+		if (secScheduledToolMapper.checkdel(secScheduled)!=1){
+			return secScheduledToolMapper.delete(secScheduled);
+		}else {
+			return 0;
+		}
+
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int addTools(SecScheduledToolsAddVo toolsVo) {
+
+
+		SecScheduledTool secScheduledTool = new SecScheduledTool();
+		secScheduledTool.setScheduledId(toolsVo.getScheduledId());
+		secScheduledTool.setToolId(toolsVo.getToolId());
+
+
+		if (secScheduledToolMapper.check(secScheduledTool)==0){
+			return secScheduledToolMapper.insert(secScheduledTool);
+		}else {
+			return 0;
+		}
+
+	}
+}

+ 77 - 0
railway-business/src/main/java/com/railway/business/safetool/service/impl/SecScheduledToolServiceImpl.java

@@ -0,0 +1,77 @@
+package com.railway.business.safetool.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.railway.business.safetool.mapper.SecScheduledToolMapper;
+import com.railway.business.safetool.domain.SecScheduledTool;
+import com.railway.business.safetool.service.ISecScheduledToolService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.railway.common.utils.SecurityUtils;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+import java.util.Date;
+/**
+* 安全计划和工具关系表
+* @author lijie
+* @date 2021/12/04
+*/
+@Service
+@Transactional(readOnly = true)
+public class SecScheduledToolServiceImpl implements ISecScheduledToolService{
+@Autowired
+private SecScheduledToolMapper secScheduledToolMapper;
+
+	/**
+	* 新增
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int create(SecScheduledTool secScheduledTool) {
+	    secScheduledTool.setCreateTime(new Date());
+        secScheduledTool.setCreateBy(SecurityUtils.getUsername());
+		return secScheduledToolMapper.insert(secScheduledTool);
+	}
+
+	/**
+	* 删除
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int delete(String[] ids) {
+		int r =0;
+		for (String id : ids) {
+//需根据需求进行删除
+//			int j= secScheduledToolMapper.delete(Long.parseLong(id));
+//			r = r + j;
+		}
+		return	r;
+	}
+
+	/**
+	* 更新
+	*/
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int update(SecScheduledTool secScheduledTool) {
+		secScheduledTool.setUpdateTime(new Date());
+    	secScheduledTool.setUpdateBy(SecurityUtils.getUsername());
+		return secScheduledToolMapper.update(secScheduledTool);
+	}
+
+	/**
+	* 获取单个
+	*/
+	@Override
+	public SecScheduledTool getInfo(String id) {
+		return secScheduledToolMapper.getInfo(id);
+	}
+
+	/**
+	* 查询列表
+	*/
+	@Override
+	public List<SecScheduledTool> getList(SecScheduledTool secScheduledTool) {
+		return secScheduledToolMapper.getList(secScheduledTool);
+	}
+}

+ 177 - 0
railway-business/src/main/resources/mapper/safetool/SecScheduledMapper.xml

@@ -0,0 +1,177 @@
+<?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.railway.business.safetool.mapper.SecScheduledMapper">
+
+    <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecScheduledDetailVo">
+                <result column="toolName" property="toolName"/>
+                <result column="unit" property="unit"/>
+        <collection property="baseSafetyTools" ofType="com.railway.business.safetool.domain.vo.SecScheduledToolsVo">
+            <result column="tool_id" property="toolId"/>
+            <result column="tool_code" property="toolCode"/>
+        </collection>
+
+    </resultMap>
+    <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledListVo2">
+        <result column="id" property="id"/>
+        <result column="dept_id" property="deptId"/>
+        <result column="store_place" property="storePlace"/>
+        <result column="lab_id" property="labId"/>
+        <result column="scheduled_time" property="scheduledTime"/>
+        <result column="deptName" property="deptName"/>
+        <result column="labName" property="labName"/>
+        <result column="c" property="c"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+                id,
+                dept_id,
+                store_place,
+                lab_id,
+                scheduled_time,
+                state,
+                del_flag,
+                create_by,
+                create_time,
+                update_by,
+                update_time
+    </sql>
+
+    <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduled">
+
+            <selectKey keyProperty="id" order="AFTER" resultType="Long">
+                select @@IDENTITY as line_id
+            </selectKey>
+
+        INSERT INTO sec_scheduled
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+                    <if test ='null != deptId'>
+                    dept_id,
+                    </if>
+                    <if test ='null != storePlace'>
+                    store_place,
+                    </if>
+                    <if test ='null != labId'>
+                    lab_id,
+                    </if>
+                    <if test ='null != scheduledTime'>
+                    scheduled_time,
+                    </if>
+                    <if test ='null != state'>
+                    state,
+                    </if>
+                    <if test ='null != delFlag'>
+                    del_flag,
+                    </if>
+                    <if test ='null != createBy'>
+                    create_by,
+                    </if>
+                    <if test ='null != createTime'>
+                    create_time,
+                    </if>
+                    <if test ='null != updateBy'>
+                    update_by,
+                    </if>
+                    <if test ='null != updateTime'>
+                    update_time
+                    </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+                    <if test ='null != deptId'>
+                    #{deptId},
+                    </if>
+                    <if test ='null != storePlace'>
+                    #{storePlace},
+                    </if>
+                    <if test ='null != labId'>
+                    #{labId},
+                    </if>
+                    <if test ='null != scheduledTime'>
+                    #{scheduledTime},
+                    </if>
+                    <if test ='null != state'>
+                    #{state},
+                    </if>
+                    <if test ='null != delFlag'>
+                    #{delFlag},
+                    </if>
+                    <if test ='null != createBy'>
+                    #{createBy},
+                    </if>
+                    <if test ='null != createTime'>
+                    #{createTime},
+                    </if>
+                    <if test ='null != updateBy'>
+                    #{updateBy},
+                    </if>
+                    <if test ='null != updateTime'>
+                    #{updateTime}
+                    </if>
+        </trim>
+    </insert>
+
+    <delete id="delete">
+        UPDATE sec_scheduled
+        set del_flag='1'
+        WHERE id = #{id}
+    </delete>
+
+    <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduled">
+        UPDATE sec_scheduled
+        <set>
+                    <if test ='null != deptId'>dept_id = #{deptId},</if>
+                    <if test ='null != storePlace'>store_place = #{storePlace},</if>
+                    <if test ='null != labId'>lab_id = #{labId},</if>
+                    <if test ='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
+                    <if test ='null != state'>state = #{state},</if>
+                    <if test ='null != delFlag'>del_flag = #{delFlag},</if>
+                    <if test ='null != createBy'>create_by = #{createBy},</if>
+                    <if test ='null != createTime'>create_time = #{createTime},</if>
+                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
+                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
+        </set>
+        WHERE id = #{id}
+    </update>
+
+
+    <select id="getInfo" resultMap="BaseResultMap">
+select  d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code
+ FROM sec_scheduled s
+ LEFT JOIN sec_scheduled_tool r
+ ON r.scheduled_id = s.id
+ INNER JOIN base_safety_tool t
+ ON t.tool_id = r.tool_id
+ left join sys_dept d1 on s.dept_id = d1.dept_id
+ left join sys_dept d2 on s.lab_id =  d2.dept_id
+ left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
+ WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
+        and s.id=#{id}
+
+    </select>
+
+    <select id="getList" resultMap="BaseResultMap2">
+
+        select s.id,s.dept_id,s.store_place,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name labName,concat(count(1),'件') c
+         from
+        sec_scheduled s
+        left join  sec_scheduled_tool r
+        on r.scheduled_id = s.id
+        inner join  base_safety_tool t
+        on t.tool_id = r.tool_id
+        left join sys_dept d1 on s.dept_id = d1.dept_id
+        left join sys_dept d2 on s.lab_id =  d2.dept_id
+        where s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
+        <if test="deptId!=null and deptId!=''">
+            and s.dept_id=#{deptId}
+        </if>
+        <if test="storePlace!=null and storePlace!=''">
+            and  s.store_place like concat(#{storePlace},'%')
+        </if>
+
+        <if test="orderby!=null and orderby!=''">
+            order by scheduled_time ${orderby}
+        </if>
+
+    </select>
+
+</mapper>

+ 149 - 0
railway-business/src/main/resources/mapper/safetool/SecScheduledToolMapper.xml

@@ -0,0 +1,149 @@
+<?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.railway.business.safetool.mapper.SecScheduledToolMapper">
+
+    <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.SecScheduledTool">
+                <result column="id" property="id"/>
+                <result column="scheduled_id" property="scheduledId"/>
+                <result column="tool_id" property="toolId"/>
+                <result column="del_flag" property="delFlag"/>
+                <result column="create_by" property="createBy"/>
+                <result column="create_time" property="createTime"/>
+                <result column="update_by" property="updateBy"/>
+                <result column="update_time" property="updateTime"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+                id,
+                scheduled_id,
+                tool_id,
+                del_flag,
+                create_by,
+                create_time,
+                update_by,
+                update_time
+    </sql>
+
+
+
+    <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduledTool">
+        <selectKey keyProperty="id" order="AFTER" resultType="Long">
+            select @@IDENTITY as line_id
+        </selectKey>
+        INSERT INTO sec_scheduled_tool
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+                    <if test ='null != scheduledId'>
+                    scheduled_id,
+                    </if>
+                    <if test ='null != toolId'>
+                    tool_id,
+                    </if>
+                    <if test ='null != delFlag'>
+                    del_flag,
+                    </if>
+                    <if test ='null != createBy'>
+                    create_by,
+                    </if>
+                    <if test ='null != createTime'>
+                    create_time,
+                    </if>
+                    <if test ='null != updateBy'>
+                    update_by,
+                    </if>
+                    <if test ='null != updateTime'>
+                    update_time
+                    </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+                    <if test ='null != scheduledId'>
+                    #{scheduledId},
+                    </if>
+                    <if test ='null != toolId'>
+                    #{toolId},
+                    </if>
+                    <if test ='null != delFlag'>
+                    #{delFlag},
+                    </if>
+                    <if test ='null != createBy'>
+                    #{createBy},
+                    </if>
+                    <if test ='null != createTime'>
+                    #{createTime},
+                    </if>
+                    <if test ='null != updateBy'>
+                    #{updateBy},
+                    </if>
+                    <if test ='null != updateTime'>
+                    #{updateTime}
+                    </if>
+        </trim>
+    </insert>
+
+    <delete id="delete" parameterType="com.railway.business.safetool.domain.vo.SecScheduledToolsAddVo">
+     delete from sec_scheduled_tool  where scheduled_id = #{scheduledId}  and tool_id = #{toolId}
+    </delete>
+
+
+    <select id="checkdel" parameterType="com.railway.business.safetool.domain.vo.SecScheduledToolsAddVo"
+            resultType="int">
+        select count(1) c from sec_scheduled_tool	where   scheduled_id = #{scheduledId}
+    </select>
+    <select id="check" parameterType="com.railway.business.safetool.domain.SecScheduledTool"
+    resultType="int">
+        select count(1) c from sec_scheduled_tool	where   tool_id = #{toolId}
+    </select>
+    <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduledTool">
+        UPDATE sec_scheduled_tool
+        <set>
+                    <if test ='null != scheduledId'>scheduled_id = #{scheduledId},</if>
+                    <if test ='null != toolId'>tool_id = #{toolId},</if>
+                    <if test ='null != delFlag'>del_flag = #{delFlag},</if>
+                    <if test ='null != createBy'>create_by = #{createBy},</if>
+                    <if test ='null != createTime'>create_time = #{createTime},</if>
+                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
+                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
+        </set>
+        WHERE id = #{id}
+    </update>
+
+
+    <select id="getInfo" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM sec_scheduled_tool
+        WHERE del_flag='0' and id = #{id}
+
+    </select>
+
+    <select id="getList" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM sec_scheduled_tool
+        <where>
+            del_flag='0'
+                <if test="scheduledId!=null and scheduledId!=''">
+                    and scheduled_id=#{scheduledId}
+                </if>
+                <if test="toolId!=null and toolId!=''">
+                    and tool_id=#{toolId}
+                </if>
+                <if test="delFlag!=null and delFlag!=''">
+                    and del_flag=#{delFlag}
+                </if>
+                <if test="createBy!=null and createBy!=''">
+                    and create_by=#{createBy}
+                </if>
+                <if test="createTime!=null and createTime!=''">
+                    and create_time=#{createTime}
+                </if>
+                <if test="updateBy!=null and updateBy!=''">
+                    and update_by=#{updateBy}
+                </if>
+                <if test="updateTime!=null and updateTime!=''">
+                    and update_time=#{updateTime}
+                </if>
+        </where>
+    </select>
+
+</mapper>