Commit c242dac1 by MMF

MMF 2026-03-24 新增项目抽检模块

parent d524bf9b
package com.qianhe.common.enums.zqcz;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public enum ZqczRyflEnum {
LINGDAO_BANZI("1", "领导班子"),
SANSHI_YIZHONGXIN("2", "三室一中心"),
BANZHAN("3", "班站");
private final String code;
private final String name;
ZqczRyflEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
/**
* 通过编码找名称
*/
public static String getNameByCode(String code) {
if (code == null || code.trim().isEmpty()) {
return "";
}
for (ZqczRyflEnum e : values()) {
if (e.code.equals(code.trim())) {
return e.name;
}
}
return "";
}
/**
* 通过名称找编码
*/
public static String getCodeByName(String name) {
// 空值校验
if (name == null || name.trim().isEmpty()) {
return "";
}
// 遍历枚举找匹配(忽略大小写,兼容"应急处置"/"应急处置 "等情况)
for (ZqczRyflEnum e : values()) {
if (e.name.equalsIgnoreCase(name.trim())) {
return e.code;
}
}
// 无匹配返回空
return "";
}
/**
* 通过编码找整个枚举对象
*/
public static ZqczRyflEnum getEnumByCode(String code) {
if (code == null || code.trim().isEmpty()) {
return null;
}
for (ZqczRyflEnum e : values()) {
if (e.code.equals(code.trim())) {
return e;
}
}
return null;
}
/**
* 获取所有名称
*/
public static List<String> getAllNames() {
return Arrays.stream(values())
.map(ZqczRyflEnum::getName)
.collect(Collectors.toList());
}
/**
* 获取所有编码
*/
public static List<String> getAllCodes() {
return Arrays.stream(values())
.map(ZqczRyflEnum::getCode)
.collect(Collectors.toList());
}
/**
* 获取所有name-code的映射
*/
public static Map<String, String> getNameToCodeMap() {
return Arrays.stream(values())
.collect(Collectors.toMap(
ZqczRyflEnum::getName, // key = name
ZqczRyflEnum::getCode, // value = code
(oldValue, newValue) -> oldValue // 避免重复name(兜底,实际枚举中name唯一)
));
}
/**
* 获取所有的code-name的映射
*/
public static Map<String, String> getCodeToNameMap() {
return Arrays.stream(values())
.collect(Collectors.toMap(
ZqczRyflEnum::getCode, // key = code
ZqczRyflEnum::getName, // value = name
(oldValue, newValue) -> oldValue // 避免重复code(兜底,实际枚举中code唯一)
));
}
/**
* 将当前枚举转为「编码-名称」格式字符串(如:code-name)
*/
private String toCodeNameStr() {
return String.format("%s-%s", this.code, this.name);
}
/**
* 获取所有「编码-名称」格式的字符串列表 如:["code-name", "code-name", ...]
*/
public static List<String> getAllCodeNameStrs() {
return Arrays.stream(values())
.map(ZqczRyflEnum::toCodeNameStr) // 调用单个拼接方法
.collect(Collectors.toList());
}
/**
* 获取所有「编码-名称」格式的字符串,以竖线分隔 如:"code-name|code-name|code-name"
*/
public static String getAllCodeNameStrWithSeparator() {
return String.join("|", getAllCodeNameStrs());
}
}
......@@ -113,10 +113,13 @@ public class ZqczJcrwController extends BaseController {
/**
* 基层抽检查询
*/
@GetMapping("/jcrwInfo/{zsrwid}")
public AjaxResult jcrwInfo(@PathVariable Long zsrwid) {
@GetMapping("/jcrwInfo")
public AjaxResult jcrwInfo(ZqczJcrwQuery zqczJcrwQuery) {
try {
return success(zqczJcrwService.jcrwInfo(zsrwid));
return success(zqczJcrwService.jcrwInfo(zqczJcrwQuery));
} catch (BusinessException e) {
log.warn("最强操作-基层任务-基层抽检查询" + e.getMessage());
return warn(e.getMessage());
} catch (Exception e) {
log.error(e.getMessage());
return error(e.getMessage());
......
......@@ -17,6 +17,10 @@ import java.util.Date;
public class ZqczJcrwQuery extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 直属任务 zqcz_zsrw.zsrwid
*/
private Long zsrwid;
/**
* 基层单位名称
*/
private String jcdwmc;
......
......@@ -27,6 +27,11 @@ public class ZqczJcrwVo {
private Long jcrwid;
/**
* 基层单位ID
*/
private Long jcdwid;
/**
* 基层单位名称
*/
@Excel(name = "基层单位")
......
......@@ -23,7 +23,7 @@ public interface ZqczJcrwMapper {
/**
* 根据直属任务ID查询
*/
List<ZqczJcrwVo> infoByZsrwId(Long zsrwid);
List<ZqczJcrwVo> infoByZsrwId(ZqczJcrwQuery zqczJcrwQuery);
/**
* 新增
......
......@@ -39,7 +39,7 @@ public interface ZqczJcrwService {
/**
* 基层抽检查询
*/
ZqczJccjVo jcrwInfo(Long zsrwid);
ZqczJccjVo jcrwInfo(ZqczJcrwQuery zqczJcrwQuery);
/**
* 基层任务抽取
......
......@@ -93,17 +93,21 @@ public class ZqczJcrwServiceImpl implements ZqczJcrwService {
* 基层抽检查询
*/
@Override
public ZqczJccjVo jcrwInfo(Long zsrwid) {
public ZqczJccjVo jcrwInfo(ZqczJcrwQuery zqczJcrwQuery) {
Long zsrwid = zqczJcrwQuery.getZsrwid();
if (zsrwid == null) {
throw new BusinessException("直属任务ID不能为空");
}
// 1. 根据直属任务ID 查询直属任务
ZqczZsrwVo zsrwInfo = zqczZsrwMapper.info(zsrwid);
if (zsrwInfo == null) {
log.warn("最强操作 --- 基层抽检查询 --- 直属任务ID:{} --- 暂无直属任务", zsrwid);
return new ZqczJccjVo();
throw new BusinessException(String.format("暂无直属任务,当前直属任务ID:%s", zsrwid));
}
// 2. 根据直属任务ID 查询基层任务
startPage();
List<ZqczJcrwVo> dataList = zqczJcrwMapper.infoByZsrwId(zsrwid);
List<ZqczJcrwVo> dataList = zqczJcrwMapper.infoByZsrwId(zqczJcrwQuery);
// 构建分页结构
TableDataInfo tableDataInfo = new TableDataInfo();
......
......@@ -149,14 +149,14 @@ public class ZqczXmglServiceImpl implements ZqczXmglService {
// 项目专业处理
String xmzyStr = cellValueMap.get("项目专业");
if (!ZqczXmzyEnum.getAllNames().contains(xmzyStr)) {
throw new BusinessException(String.format("项目专业必须为%s, 当前值 %s", ZqczXmzyEnum.getAllCodeNameStrWithSeparator(), xmzyStr));
throw new BusinessException(String.format("第%s行,项目专业必须为%s, 当前值 %s", i + 1, ZqczXmzyEnum.getAllCodeNameStrWithSeparator(), xmzyStr));
}
String xmzy = ZqczXmzyEnum.getCodeByName(xmzyStr);
// 项目类别处理
String xmlbStr = cellValueMap.get("项目类别");
if (!ZqczXmlbEnum.getAllNames().contains(xmlbStr)) {
throw new BusinessException(String.format("项目类别必须为%s, 当前值 %s", ZqczXmlbEnum.getAllCodeNameStrWithSeparator(), xmlbStr));
throw new BusinessException(String.format("第%s行,项目类别必须为%s, 当前值 %s", i + 1, ZqczXmlbEnum.getAllCodeNameStrWithSeparator(), xmlbStr));
}
String xmlb = ZqczXmlbEnum.getCodeByName(xmlbStr);
......@@ -166,13 +166,13 @@ public class ZqczXmglServiceImpl implements ZqczXmglService {
if (MtConstant.ZQCZ_XMZY_CYZY_CODE.equals(xmzy)) {
gzcj = ZqczCyzyGzcjEnum.getCodeByName(gzcjStr);
if (StringUtils.isEmpty(gzcj)) {
throw new BusinessException(String.format("工作场景必须为%s, 当前工作场景 %s", ZqczCyzyGzcjEnum.getAllCodeNameStrWithSeparator(), gzcjStr));
throw new BusinessException(String.format("第%s行,工作场景必须为%s, 当前工作场景 %s", i + 1, ZqczCyzyGzcjEnum.getAllCodeNameStrWithSeparator(), gzcjStr));
}
}
if (MtConstant.ZQCZ_XMZY_JSZY_CODE.equals(xmzy)) {
gzcj = ZqczJszyGzcjEnum.getCodeByName(gzcjStr);
if (gzcj == null) {
throw new BusinessException(String.format("工作场景必须为%s, 当前工作场景 %s", ZqczJszyGzcjEnum.getAllCodeNameStrWithSeparator(), gzcjStr));
throw new BusinessException(String.format("第%s行,工作场景必须为%s, 当前工作场景 %s", i + 1, ZqczJszyGzcjEnum.getAllCodeNameStrWithSeparator(), gzcjStr));
}
}
......@@ -189,6 +189,8 @@ public class ZqczXmglServiceImpl implements ZqczXmglService {
.gzcj(gzcj)
.xmmc(xmmc)
.xmrs(xmrs)
.create_by(username)
.update_by(username)
.build();
return zqczXmgl;
}, dataList -> {
......
package com.qianhe.zqcz.xmrylsjl.controller;
import com.qianhe.common.core.controller.BaseController;
import com.qianhe.common.core.domain.AjaxResult;
import com.qianhe.common.core.page.TableDataInfo;
import com.qianhe.common.exception.BusinessException;
import com.qianhe.common.utils.poi.ExcelUtil;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjl;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlQuery;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlVo;
import com.qianhe.zqcz.xmrylsjl.service.ZqczXmRyLsjlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/zqcz/lsjl")
public class ZqczXmRyLsjlController extends BaseController {
@Autowired
private ZqczXmRyLsjlService zqczXmRyLsjlService;
/**
* 分页查询
*/
@GetMapping("/list")
public AjaxResult list(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
return success(zqczXmRyLsjlService.list(zqczXmRyLsjlQuery));
}
/**
* 项目抽检
*/
@PostMapping("/spotCheckAdd")
public AjaxResult spotCheckAdd(@RequestBody ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
try {
return toAjax(zqczXmRyLsjlService.spotCheckAdd(zqczXmRyLsjlQuery));
} catch (BusinessException e) {
log.warn("最强操作-项目抽检失败:" + e.getMessage());
return warn(e.getMessage());
} catch (Exception e) {
log.error(e.getMessage());
return error(e.getMessage());
}
}
/**
* 导出
*/
@PostMapping("/export")
public void export(HttpServletResponse response, ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
List<ZqczXmRyLsjlVo> dataList = zqczXmRyLsjlService.list(zqczXmRyLsjlQuery);
ExcelUtil<ZqczXmRyLsjlVo> util = new ExcelUtil<>(ZqczXmRyLsjlVo.class);
util.exportExcel(response, dataList, "sheetName");
}
}
package com.qianhe.zqcz.xmrylsjl.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qianhe.common.annotation.Excel;
import com.qianhe.common.core.domain.BaseEntity;
import com.qianhe.common.utils.SecurityUtils;
import com.qianhe.zqcz.ryxx.domain.ZqczRyxxVo;
import com.qianhe.zqcz.xmgl.domain.ZqczXmglVo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 最强操作-项目人员 历史记录 Model
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ZqczXmRyLsjl extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private Long xmryid;
/**
* 基层任务ID:关联zqcz_jcrw.jcrwid
*/
private Long jcrwid;
/**
* 基层单位名称 关联 zqcz_jcdw.jcdwid
*/
private Long jcdwid;
/**
* 项目名称
*/
private String xmmc;
/**
* 项目专业:1-采油专业 2-集输专业
*/
private String xmzy;
/**
* 项目类别:1-个人应急项目 2-团队应急项目 3-单人/双人操作项目 4-团队操作项目 字典:zqcz_xmlb
*/
private String xmlb;
/**
* 工作场景码表:采油zqcz_cyzy_gzcj 集输zqcz_jszy_gzcj
*/
private String gzcj;
/**
* 人员名称
*/
private String rymc;
/**
* 单位名称(存储上传的单位名称,领导班子、三室一中心、班站)
*/
private String dwmc;
/**
* 创建者
*/
private String create_by;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date create_time;
/**
* 修改人
*/
private String update_by;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date update_time;
/**
* 备注
*/
private String remark;
/**
* 预留1
*/
private String yl1;
/**
* 预留2
*/
private String yl2;
/**
* 预留3
*/
private String yl3;
/**
* 预留4
*/
private String yl4;
/**
* 预留5
*/
private String yl5;
public ZqczXmRyLsjl(Long jcrwid, Long jcdwid, ZqczRyxxVo ryxxVo, ZqczXmglVo xmglVo) {
this.jcrwid = jcrwid;
this.jcdwid = jcdwid;
this.xmmc = xmglVo.getXmmc();
this.xmzy = xmglVo.getXmzy();
this.xmlb = xmglVo.getXmlb();
this.gzcj = xmglVo.getGzcj();
this.rymc = ryxxVo.getRymc();
this.dwmc = ryxxVo.getDwmc();
this.create_by = SecurityUtils.getLoginUser().getUsername();
this.update_by = SecurityUtils.getLoginUser().getUsername();
this.create_time = new Date();
}
}
package com.qianhe.zqcz.xmrylsjl.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qianhe.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 最强操作-项目人员 历史记录 Model
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ZqczXmRyLsjlQuery extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 基层任务ID:关联 zqcz_jcrw.jcrwid
*/
private Long jcrwid;
/**
* 基层任务ID:关联 zqcz_jcdw.jcdwid
*/
private Long jcdwid;
/**
* 项目专业:1 - 采油专业,2 - 集输专业 字典:zqcz_xmzy
*/
private String xmzy;
}
package com.qianhe.zqcz.xmrylsjl.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qianhe.common.annotation.Excel;
import com.qianhe.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 最强操作-项目人员 历史记录 Model
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ZqczXmRyLsjlVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private Long xmryid;
/**
* 基层任务ID:关联zqcz_jcrw.jcrwid
*/
private Long jcrwid;
/**
* 基层单位ID: 关联 zqcz_jcdw.jcdwid
*/
private Long jcdwid;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date update_time;
/**
* 基层单位名称
*/
@Excel(name = "基层单位名称")
private String jcdwmc;
/**
* 单位名称(存储上传的单位名称,领导班子、三室一中心、班站)
*/
@Excel(name = "班站名称")
private String dwmc;
/**
* 项目类别:1-个人应急项目 2-团队应急项目 3-单人/双人操作项目 4-团队操作项目 字典 zqcz_xmlb
*/
@Excel(name = "项目类别",dictType = "zqcz_xmlb",type = Excel.Type.EXPORT)
private String xmlb;
/**
* 人员名称
*/
@Excel(name = "盲抽人员名称")
private String rymc;
/**
* 项目名称
*/
@Excel(name = "盲抽项目名称")
private String xmmc;
}
package com.qianhe.zqcz.xmrylsjl.mapper;
import com.qianhe.zqcz.xmgl.domain.ZqczXmgl;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjl;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlQuery;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ZqczXmRyLsjlMapper {
/**
* 条件查询
*/
List<ZqczXmRyLsjlVo> list(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery);
/**
* 查询详情
*/
ZqczXmRyLsjlVo info(Long id);
/**
* 新增
*/
int add(ZqczXmRyLsjl zqczXmRyLsjl);
/**
* 修改
*/
int edit(ZqczXmRyLsjl zqczXmRyLsjl);
/**
* 删除
*/
int delete(Long[] ids);
/**
* 批量新增
*/
int batchAdd(@Param("dataList") List<ZqczXmRyLsjl> dataList);
/**
* 根据基层任务ID 删除
*/
int deleteByJcrwid(@Param("jcrwid") Long jcrwid);
}
package com.qianhe.zqcz.xmrylsjl.service;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjl;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlQuery;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlVo;
import java.util.List;
public interface ZqczXmRyLsjlService {
/**
* 条件查询
*/
List<ZqczXmRyLsjlVo> list(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery);
/**
* 根据基层任务ID 开始项目抽检
*/
int spotCheckAdd(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery);
}
package com.qianhe.zqcz.xmrylsjl.service.impl;
import com.qianhe.common.enums.zqcz.ZqczRyflEnum;
import com.qianhe.common.enums.zqcz.ZqczXmlbEnum;
import com.qianhe.common.enums.zqcz.ZqczXmzyEnum;
import com.qianhe.common.exception.BusinessException;
import com.qianhe.common.utils.MtUtils;
import com.qianhe.common.utils.SecurityUtils;
import com.qianhe.zqcz.pwxx.domain.ZqczPwxxQuery;
import com.qianhe.zqcz.pwxx.domain.ZqczPwxxVo;
import com.qianhe.zqcz.pwxx.mapper.ZqczPwxxMapper;
import com.qianhe.zqcz.ryxx.domain.ZqczRyxxQuery;
import com.qianhe.zqcz.ryxx.domain.ZqczRyxxVo;
import com.qianhe.zqcz.ryxx.mapper.ZqczRyxxMapper;
import com.qianhe.zqcz.xmgl.domain.ZqczXmglQuery;
import com.qianhe.zqcz.xmgl.domain.ZqczXmglVo;
import com.qianhe.zqcz.xmgl.mapper.ZqczXmglMapper;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjl;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlQuery;
import com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlVo;
import com.qianhe.zqcz.xmrylsjl.mapper.ZqczXmRyLsjlMapper;
import com.qianhe.zqcz.xmrylsjl.service.ZqczXmRyLsjlService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ZqczXmRyLsjlServiceImpl implements ZqczXmRyLsjlService {
@Autowired
private ZqczXmRyLsjlMapper zqczXmRyLsjlMapper;
@Autowired
private ZqczXmglMapper zqczXmglMapper;
@Autowired
private ZqczRyxxMapper zqczRyxxMapper;
@Autowired
private ZqczPwxxMapper zqczPwxxMapper;
/**
* 条件查询
*/
@Override
public List<ZqczXmRyLsjlVo> list(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
List<ZqczXmRyLsjlVo> dataList = zqczXmRyLsjlMapper.list(zqczXmRyLsjlQuery);
return dataList;
}
/**
* 开始抽检 参数校验
*
* @param zqczXmRyLsjlQuery
*/
private void spotCheckAddCheck(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
if (zqczXmRyLsjlQuery.getJcrwid() == null) {
throw new BusinessException("基层任务ID不能为空");
}
if (zqczXmRyLsjlQuery.getJcdwid() == null) {
throw new BusinessException("基层单位ID不能为空");
}
if (zqczXmRyLsjlQuery.getXmzy() == null) {
throw new BusinessException("项目专业不能为空");
}
if (!ZqczXmzyEnum.getAllCodes().contains(zqczXmRyLsjlQuery.getXmzy())) {
throw new BusinessException(String.format("项目专业必须为%s, 当前值 %s", ZqczXmzyEnum.getAllCodeNameStrWithSeparator(), zqczXmRyLsjlQuery.getXmzy()));
}
}
/**
* 根据基层任务ID 开始项目抽检
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int spotCheckAdd(ZqczXmRyLsjlQuery zqczXmRyLsjlQuery) {
// 数据校验
spotCheckAddCheck(zqczXmRyLsjlQuery);
// 项目字段
Long jcrwid = zqczXmRyLsjlQuery.getJcrwid(); // 基层任务ID
Long jcdwid = zqczXmRyLsjlQuery.getJcdwid(); // 基层单位ID
String xmzy = zqczXmRyLsjlQuery.getXmzy(); // 项目专业 1-采油 2-集输
// 根据基层任务ID 删除已经抽取的项目
zqczXmRyLsjlMapper.deleteByJcrwid(jcrwid);
// 查询评委信息
List<ZqczPwxxVo> pwxxList = zqczPwxxMapper.list(ZqczPwxxQuery.builder().jcrwid(jcrwid).build());
if (Optional.ofNullable(pwxxList).orElse(Collections.emptyList()).isEmpty()) {
throw new BusinessException("未录入评委信息");
}
// 1. 查询人员信息(姓名、单位、分类)
List<ZqczRyxxVo> ryxxList = zqczRyxxMapper.list(ZqczRyxxQuery.builder().jcrwid(jcrwid).build());
if (Optional.ofNullable(ryxxList).orElse(Collections.emptyList()).isEmpty()) {
throw new BusinessException("未录入在岗人员信息");
}
// 2. 根据项目专业 查询项目信息
List<ZqczXmglVo> xmglList = zqczXmglMapper.list(ZqczXmglQuery.builder().xmzy(xmzy).build());
if (Optional.ofNullable(xmglList).orElse(Collections.emptyList()).isEmpty()) {
throw new BusinessException("未录入项目信息");
}
// 3. 处理人员信息,按照人员分类 分组
Map<String, List<ZqczRyxxVo>> ryxxGroupByRyflMap = ryxxList.stream().collect(Collectors.groupingBy(ZqczRyxxVo::getRyfl));
List<ZqczRyxxVo> ldbzRyxxList = ryxxGroupByRyflMap.get(ZqczRyflEnum.LINGDAO_BANZI.getCode()); // 领导班子 人员信息
List<ZqczRyxxVo> ssyzxRyxxList = ryxxGroupByRyflMap.get(ZqczRyflEnum.SANSHI_YIZHONGXIN.getCode()); // 三室一中心 人员信息
List<ZqczRyxxVo> bzRyxxList = ryxxGroupByRyflMap.get(ZqczRyflEnum.BANZHAN.getCode()); // 班站 人员信息
List<String> bzDistinctList = new ArrayList<>(); // 获取所有班站单位(去重)
if (!Optional.ofNullable(bzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
bzDistinctList = bzRyxxList.stream().map(ZqczRyxxVo::getDwmc).distinct().collect(Collectors.toList());// 获取所有班站单位(去重)
}
// 4. 处理项目信息,按照项目类别 分组
Map<String, List<ZqczXmglVo>> xmglGroupByXmlbMap = xmglList.stream().collect(Collectors.groupingBy(ZqczXmglVo::getXmlb));
List<ZqczXmglVo> gryjXmglList = xmglGroupByXmlbMap.get(ZqczXmlbEnum.GEREN_YINGJI.getCode()); // 个人应急项目
List<ZqczXmglVo> tdyjXmglList = xmglGroupByXmlbMap.get(ZqczXmlbEnum.TUANDUI_YINGJI.getCode()); // 团队应急项目
List<ZqczXmglVo> drsrXmglList = xmglGroupByXmlbMap.get(ZqczXmlbEnum.DANREN_SHUANGREN.getCode()); // 单人/双人操作项目
List<ZqczXmglVo> tdczXmglList = xmglGroupByXmlbMap.get(ZqczXmlbEnum.TUANDUI_CAOZUO.getCode()); // 团队操作项目
List<ZqczRyxxVo> desigRyxxList = new ArrayList<>(); // 抽取指定班站 人员信息
if (!Optional.ofNullable(bzDistinctList).orElse(Collections.emptyList()).isEmpty()) {
if (ZqczXmzyEnum.CAIYOU_ZHUANYE.getCode().equals(xmzy)) {
String lockbzName = MtUtils.getRandomList(bzDistinctList, 1).get(0);
if (!Optional.ofNullable(bzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
desigRyxxList = bzRyxxList.stream().filter(item -> lockbzName.equals(item.getDwmc())).collect(Collectors.toList());// 从指定班站中抽取人员信息
}
} else {
List<String> spotBzList = MtUtils.getRandomList(bzDistinctList, 3);
if (!Optional.ofNullable(bzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
desigRyxxList = bzRyxxList.stream().filter(item -> spotBzList.contains(item.getDwmc())).collect(Collectors.toList());// 从指定班站中抽取人员信息
}
}
}
List<ZqczXmRyLsjl> finalList = new ArrayList<>();
if (ZqczXmzyEnum.CAIYOU_ZHUANYE.getCode().equals(xmzy)) { // 采油专业 项目抽取
// 5. 处理 个人应急项目(从领导班子中抽取一人、抽三室一中心抽取两人、从班站中抽取一人) 先抽人,在抽项目
List<ZqczXmRyLsjl> finalCyGryjxmList = spotCheckCyGryjxm(jcrwid, jcdwid, ldbzRyxxList, ssyzxRyxxList, desigRyxxList, gryjXmglList);
if (!Optional.ofNullable(finalCyGryjxmList).orElse(Collections.emptyList()).isEmpty()) {
finalList.addAll(finalCyGryjxmList);
}
// 6. 处理 标准化操作项目 (根据项目人数从班站中随机抽取指定人数)先抽项目,在抽人
ZqczXmRyLsjl finalCyBzhczxm = spotCheckCyBzhczxm(jcrwid, jcdwid, desigRyxxList, drsrXmglList, tdczXmglList);
if (finalCyBzhczxm != null) {
finalList.add(finalCyBzhczxm);
}
// 7. 处理 团队应急项目(从领导班子中抽取一人、抽三室一中心抽取两人、在根据剩余项目人数从班站中抽取)先抽项目,在抽人
ZqczXmRyLsjl finalCjTdyjxm = spotCheckCyTdyjxm(jcrwid, jcdwid, ldbzRyxxList, ssyzxRyxxList, desigRyxxList, tdyjXmglList);
if (finalCjTdyjxm != null) {
finalList.add(finalCjTdyjxm);
}
} else { // 集输专业 项目抽取
// 1. 抽检个人应急项目(从领导班子中抽取一人、抽三室一中心抽取两人、从选中的3个班站中各抽取一人) 先抽人,在抽项目
List<ZqczXmRyLsjl> finalJsGryjxmList = spotCheckJsGryjxm(jcrwid, jcdwid, ldbzRyxxList, ssyzxRyxxList, desigRyxxList, gryjXmglList);
if (!Optional.ofNullable(finalJsGryjxmList).orElse(Collections.emptyList()).isEmpty()) {
finalList.addAll(finalJsGryjxmList);
}
// 2. 抽检 标准化操作项目(从选中的3个班站中各抽取2人) 先抽人,在抽项目
List<ZqczXmRyLsjl> finalJsBzhczxmList = spotCheckJsBzhczxm(jcrwid, jcdwid, desigRyxxList, drsrXmglList, tdczXmglList);
if (!Optional.ofNullable(finalJsBzhczxmList).orElse(Collections.emptyList()).isEmpty()) {
finalList.addAll(finalJsBzhczxmList);
}
// 3. 抽检 团队应急项目 (第一个班站从领导班子中抽取一人、抽三室一中心抽取一人、班站成员自行选择,默认情况下选择所有的班站成员,其余班站随机抽取项目,班站人员默认全部)
List<ZqczXmRyLsjl> finalJsTdyjxmList = spotCheckJsTdyjxm(jcrwid, jcdwid, ldbzRyxxList, ssyzxRyxxList, desigRyxxList, tdyjXmglList);
if (!Optional.ofNullable(finalJsTdyjxmList).orElse(Collections.emptyList()).isEmpty()) {
finalList.addAll(finalJsTdyjxmList);
}
}
return zqczXmRyLsjlMapper.batchAdd(finalList);
}
/**
* 抽检 个人应急项目(采油)
*/
private List<ZqczXmRyLsjl> spotCheckCyGryjxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> ldbzRyxxList, List<ZqczRyxxVo> ssyzxRyxxList, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> gryjXmglList) {
List<ZqczXmRyLsjl> dataList = new ArrayList<>();
ZqczRyxxVo lockldbzRyxxVo = null; // 锁定 领导班子
if (!Optional.ofNullable(ldbzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
List<ZqczRyxxVo> spotLdbzList = MtUtils.getRandomList(ldbzRyxxList, 1); // 抽取 领导班子 人员信息
lockldbzRyxxVo = spotLdbzList.get(0);
}
List<ZqczRyxxVo> spotLdbzList = new ArrayList<>(); // 锁定 三室一中心
if (!Optional.ofNullable(ssyzxRyxxList).orElse(Collections.emptyList()).isEmpty()) {
if (ssyzxRyxxList.size() >= 2) { // 这里判断主要是为了判断 如果 三室一中心中的人数不够2个人
spotLdbzList = MtUtils.getRandomList(ssyzxRyxxList, 2); // 抽取 三室一中心 人员信息
} else {
spotLdbzList = MtUtils.getRandomList(ssyzxRyxxList, 1); // 抽取 三室一中心 人员信息
}
}
ZqczRyxxVo lockbzRyxxVo = null; // 锁定 班站
if (!Optional.ofNullable(desigRyxxList).orElse(Collections.emptyList()).isEmpty()) {
List<ZqczRyxxVo> spotbzList = MtUtils.getRandomList(desigRyxxList, 1); // 抽取 班站 人员信息
lockbzRyxxVo = spotbzList.get(0);
}
// 需要处理个人应急项目为空的情况
if (!Optional.ofNullable(gryjXmglList).orElse(Collections.emptyList()).isEmpty()) {
if (lockldbzRyxxVo != null) {
ZqczXmglVo lockldbzXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 领导班子 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, lockldbzRyxxVo, lockldbzXmgl));
}
if (!Optional.ofNullable(spotLdbzList).orElse(Collections.emptyList()).isEmpty()) {
for (ZqczRyxxVo zqczRyxxVo : spotLdbzList) {
ZqczXmglVo lockssyzxXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 三室一中心 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, zqczRyxxVo, lockssyzxXmgl));
}
}
if (lockbzRyxxVo != null) {
ZqczXmglVo lockbzXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 班站 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, lockbzRyxxVo, lockbzXmgl));
}
}
return dataList;
}
/**
* 抽检 标准化操作项目(采油)
*/
private ZqczXmRyLsjl spotCheckCyBzhczxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> drsrXmglList, List<ZqczXmglVo> tdczXmglList) {
// 合并单人/双人操作项目,团队操作项目
List<ZqczXmglVo> bzhczXmglList = new ArrayList<>();
if (!Optional.ofNullable(drsrXmglList).orElse(Collections.emptyList()).isEmpty()) {
bzhczXmglList.addAll(drsrXmglList);
}
if (!Optional.ofNullable(tdczXmglList).orElse(Collections.emptyList()).isEmpty()) {
bzhczXmglList.addAll(tdczXmglList);
}
// 抽检项目
if (Optional.ofNullable(bzhczXmglList).orElse(Collections.emptyList()).isEmpty()) {
return null;
}
// 判断班站人员信息是否为空
if (Optional.ofNullable(desigRyxxList).orElse(Collections.emptyList()).isEmpty()) {
return null;
}
ZqczXmglVo bzhczXmglVo = MtUtils.getRandomList(bzhczXmglList, 1).get(0);
Integer xmrs = bzhczXmglVo.getXmrs();// 获取项目所需要的人数
// 最终的人员信息列表
List<ZqczRyxxVo> finalList = desigRyxxList.size() <= xmrs ? desigRyxxList : MtUtils.getRandomList(desigRyxxList, xmrs);
String dwmc = finalList.stream().map(ZqczRyxxVo::getDwmc).distinct().collect(Collectors.joining(","));
String rymc = finalList.stream().map(ZqczRyxxVo::getRymc).distinct().collect(Collectors.joining(","));
ZqczXmRyLsjl xmRyLsjl = ZqczXmRyLsjl.builder()
.jcrwid(jcrwid)
.jcdwid(jcdwid)
.xmmc(bzhczXmglVo.getXmmc())
.xmzy(bzhczXmglVo.getXmzy())
.xmlb(bzhczXmglVo.getXmlb())
.gzcj(bzhczXmglVo.getGzcj())
.rymc(rymc)
.dwmc(dwmc)
.create_by(SecurityUtils.getLoginUser().getUsername())
.update_by(SecurityUtils.getLoginUser().getUsername())
.create_time(new Date())
.build();
return xmRyLsjl;
}
/**
* 抽检 团队应急项目(采油)
*/
private ZqczXmRyLsjl spotCheckCyTdyjxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> ldbzRyxxList, List<ZqczRyxxVo> ssyzxRyxxList, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> tdyjXmglList) {
// 抽检项目
if (Optional.ofNullable(tdyjXmglList).orElse(Collections.emptyList()).isEmpty()) {
return null;
}
// 获取项目所需要的人数
ZqczXmglVo bzhczXmglVo = MtUtils.getRandomList(tdyjXmglList, 1).get(0);
Integer xmrs = bzhczXmglVo.getXmrs();
if (xmrs == null) {
return null;
}
List<ZqczRyxxVo> finalList = new ArrayList<>();
// 始终锁定领导班子(xmrs >= 1)
if (!Optional.ofNullable(ldbzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
finalList.add(MtUtils.getRandomList(ldbzRyxxList, 1).get(0));
}
// xmrs >= 2 时叠加三室一中心
if (xmrs >= 2 && !Optional.ofNullable(ssyzxRyxxList).orElse(Collections.emptyList()).isEmpty()) {
finalList.add(MtUtils.getRandomList(ssyzxRyxxList, 1).get(0));
}
// xmrs >= 3 时叠加班站人员
if (xmrs >= 3 && !Optional.ofNullable(desigRyxxList).orElse(Collections.emptyList()).isEmpty()) {
int bzNum = xmrs - 2;
finalList.addAll(MtUtils.getRandomList(desigRyxxList, bzNum));
}
String dwmc = finalList.stream().map(ZqczRyxxVo::getDwmc).distinct().collect(Collectors.joining(","));
String rymc = finalList.stream().map(ZqczRyxxVo::getRymc).distinct().collect(Collectors.joining(","));
ZqczXmRyLsjl xmRyLsjl = ZqczXmRyLsjl.builder()
.jcrwid(jcrwid)
.jcdwid(jcdwid)
.xmmc(bzhczXmglVo.getXmmc())
.xmzy(bzhczXmglVo.getXmzy())
.xmlb(bzhczXmglVo.getXmlb())
.gzcj(bzhczXmglVo.getGzcj())
.rymc(rymc)
.dwmc(dwmc)
.create_by(SecurityUtils.getLoginUser().getUsername())
.update_by(SecurityUtils.getLoginUser().getUsername())
.create_time(new Date())
.build();
return xmRyLsjl;
}
/**
* 抽检 个人应急项目(集输)
*/
private List<ZqczXmRyLsjl> spotCheckJsGryjxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> ldbzRyxxList, List<ZqczRyxxVo> ssyzxRyxxList, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> gryjXmglList) {
List<ZqczXmRyLsjl> dataList = new ArrayList<>();
ZqczRyxxVo lockldbzRyxxVo = null; // 锁定 领导班子
if (!Optional.ofNullable(ldbzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
List<ZqczRyxxVo> spotLdbzList = MtUtils.getRandomList(ldbzRyxxList, 1); // 抽取 领导班子 人员信息
lockldbzRyxxVo = spotLdbzList.get(0);
}
List<ZqczRyxxVo> spotLdbzList = new ArrayList<>(); // 锁定 三室一中心
if (!Optional.ofNullable(ssyzxRyxxList).orElse(Collections.emptyList()).isEmpty()) {
if (ssyzxRyxxList.size() >= 2) { // 这里判断主要是为了判断 如果 三室一中心中的人数不够2个人
spotLdbzList = MtUtils.getRandomList(ssyzxRyxxList, 2); // 抽取 三室一中心 人员信息
} else {
spotLdbzList = MtUtils.getRandomList(ssyzxRyxxList, 1); // 抽取 三室一中心 人员信息
}
}
List<ZqczRyxxVo> spotbzList = new ArrayList<>(); // 锁定 班站
Map<String, List<ZqczRyxxVo>> spotbzGroupMap = desigRyxxList.stream().collect(Collectors.groupingBy(ZqczRyxxVo::getDwmc)); // 根据班站名称分组
spotbzGroupMap.forEach((key, value) -> {
if (!Optional.ofNullable(value).orElse(Collections.emptyList()).isEmpty()) {
spotbzList.add(MtUtils.getRandomList(value, 1).get(0));
}
});
// 需要处理个人应急项目为空的情况
if (!Optional.ofNullable(gryjXmglList).orElse(Collections.emptyList()).isEmpty()) {
if (lockldbzRyxxVo != null) {
ZqczXmglVo lockldbzXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 领导班子 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, lockldbzRyxxVo, lockldbzXmgl));
}
if (!Optional.ofNullable(spotLdbzList).orElse(Collections.emptyList()).isEmpty()) {
for (ZqczRyxxVo zqczRyxxVo : spotLdbzList) {
ZqczXmglVo lockssyzxXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 三室一中心 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, zqczRyxxVo, lockssyzxXmgl));
}
}
if (!Optional.ofNullable(spotbzList).orElse(Collections.emptyList()).isEmpty()) {
for (ZqczRyxxVo zqczRyxxVo : spotbzList) {
ZqczXmglVo lockbzXmgl = MtUtils.getRandomList(gryjXmglList, 1).get(0); // 班站 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, zqczRyxxVo, lockbzXmgl));
}
}
}
return dataList;
}
/**
* 抽检 标准化操作项目(集输)
*/
private List<ZqczXmRyLsjl> spotCheckJsBzhczxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> drsrXmglList, List<ZqczXmglVo> tdczXmglList) {
List<ZqczXmRyLsjl> dataList = new ArrayList<>();
// 合并单人/双人操作项目,团队操作项目
List<ZqczXmglVo> bzhczXmglList = new ArrayList<>();
if (!Optional.ofNullable(drsrXmglList).orElse(Collections.emptyList()).isEmpty()) {
bzhczXmglList.addAll(drsrXmglList);
}
if (!Optional.ofNullable(tdczXmglList).orElse(Collections.emptyList()).isEmpty()) {
bzhczXmglList.addAll(tdczXmglList);
}
// 抽检项目
if (Optional.ofNullable(bzhczXmglList).orElse(Collections.emptyList()).isEmpty()) {
return dataList;
}
// 判断班站人员信息是否为空
if (Optional.ofNullable(desigRyxxList).orElse(Collections.emptyList()).isEmpty()) {
return dataList;
}
// 抽人
List<ZqczRyxxVo> spotbzList = new ArrayList<>(); // 锁定 班站
Map<String, List<ZqczRyxxVo>> spotbzGroupMap = desigRyxxList.stream().collect(Collectors.groupingBy(ZqczRyxxVo::getDwmc)); // 根据班站名称分组
spotbzGroupMap.forEach((key, value) -> { // 每一组抽取两个人
if (!Optional.ofNullable(value).orElse(Collections.emptyList()).isEmpty()) {
List<ZqczRyxxVo> randomList = MtUtils.getRandomList(value, 2);
if (!Optional.ofNullable(randomList).orElse(Collections.emptyList()).isEmpty()) {
spotbzList.addAll(randomList);
}
}
});
// 需要处理 标准化操作项目 为空的情况
if (!Optional.ofNullable(bzhczXmglList).orElse(Collections.emptyList()).isEmpty()) {
if (!Optional.ofNullable(spotbzList).orElse(Collections.emptyList()).isEmpty()) {
for (ZqczRyxxVo zqczRyxxVo : spotbzList) {
ZqczXmglVo lockbzXmgl = MtUtils.getRandomList(bzhczXmglList, 1).get(0); // 班站 锁定项目
dataList.add(new ZqczXmRyLsjl(jcrwid, jcdwid, zqczRyxxVo, lockbzXmgl));
}
}
}
return dataList;
}
/**
* 抽检 团队应急项目(集输)
*
* @param jcrwid 基层任务ID
* @param jcdwid 基层单位ID
* @param ldbzRyxxList 领导班子 人员信息
* @param ssyzxRyxxList 三室一中心 人员信息
* @param desigRyxxList 指定班站 人员信息
* @param tdyjXmglList 团队应急项目
* @return
*/
private List<ZqczXmRyLsjl> spotCheckJsTdyjxm(Long jcrwid, Long jcdwid, List<ZqczRyxxVo> ldbzRyxxList, List<ZqczRyxxVo> ssyzxRyxxList, List<ZqczRyxxVo> desigRyxxList, List<ZqczXmglVo> tdyjXmglList) {
List<ZqczXmRyLsjl> dataList = new ArrayList<>();
// 抽检项目
if (Optional.ofNullable(tdyjXmglList).orElse(Collections.emptyList()).isEmpty()) {
return null;
}
// 查询班站列表
List<String> spotCheckBzNameList = desigRyxxList.stream().map(ZqczRyxxVo::getDwmc).distinct().collect(Collectors.toList());
if (Optional.ofNullable(spotCheckBzNameList).orElse(Collections.emptyList()).isEmpty()) {
return null;
}
// 分组
Map<String, List<ZqczRyxxVo>> spotCheckBzGroupMap = desigRyxxList.stream().collect(Collectors.groupingBy(ZqczRyxxVo::getDwmc));
for (int i = 0; i < spotCheckBzNameList.size(); i++) {
ZqczXmglVo spotCheckTdyjXmgl = MtUtils.getRandomList(tdyjXmglList, 1).get(0); // 当前班站抽取的项目
String groupField = spotCheckBzNameList.get(i);
List<ZqczRyxxVo> currentRyxxList = spotCheckBzGroupMap.get(groupField); // 获取当前选中班站的人员信息
if (Optional.ofNullable(currentRyxxList).orElse(Collections.emptyList()).isEmpty()) { // 如果人员信息为空则跳过此次循环
continue;
}
ZqczRyxxVo lockldbzRyxxVo = null; // 锁定 领导班子 人员信息(抽一个人)
ZqczRyxxVo lockSpotCheckSsyzxRyxx = null; // 锁定 三室一中心 人员信息(抽一个人)
if (i == 0) { // 第一个班站坐特殊处理
if (!Optional.ofNullable(ldbzRyxxList).orElse(Collections.emptyList()).isEmpty()) {
List<ZqczRyxxVo> spotLdbzList = MtUtils.getRandomList(ldbzRyxxList, 1); // 抽取 领导班子 人员信息
lockldbzRyxxVo = spotLdbzList.get(0);
}
if (!Optional.ofNullable(ssyzxRyxxList).orElse(Collections.emptyList()).isEmpty()) {
lockSpotCheckSsyzxRyxx = MtUtils.getRandomList(ldbzRyxxList, 1).get(0); // 抽取 三室一中心 人员信息
}
}
// 锁定 班站 人员信息(所有人)
List<String> dwmcList = currentRyxxList.stream().map(ZqczRyxxVo::getDwmc).collect(Collectors.toList());
List<String> rymcList = currentRyxxList.stream().map(ZqczRyxxVo::getRymc).distinct().collect(Collectors.toList());
// 拼接数据单位名称、人员名称
if (lockldbzRyxxVo != null) {
dwmcList.add(lockldbzRyxxVo.getDwmc());
rymcList.add(lockldbzRyxxVo.getRymc());
}
if (lockSpotCheckSsyzxRyxx != null) {
dwmcList.add(lockSpotCheckSsyzxRyxx.getDwmc());
rymcList.add(lockSpotCheckSsyzxRyxx.getRymc());
}
String dwmc = dwmcList.stream().distinct().collect(Collectors.joining(","));
String rymc = rymcList.stream().distinct().collect(Collectors.joining(","));
ZqczXmRyLsjl spotCheckXmRyLsjl = ZqczXmRyLsjl.builder()
.jcrwid(jcrwid)
.jcdwid(jcdwid)
.xmmc(spotCheckTdyjXmgl.getXmmc())
.xmzy(spotCheckTdyjXmgl.getXmzy())
.xmlb(spotCheckTdyjXmgl.getXmlb())
.gzcj(spotCheckTdyjXmgl.getGzcj())
.rymc(rymc)
.dwmc(dwmc)
.create_by(SecurityUtils.getLoginUser().getUsername())
.update_by(SecurityUtils.getLoginUser().getUsername())
.create_time(new Date())
.build();
dataList.add(spotCheckXmRyLsjl);
}
return dataList;
}
}
......@@ -7,6 +7,7 @@
<resultMap id="ZqczJcrwResult" type="com.qianhe.zqcz.jcrw.domain.ZqczJcrwVo">
<id property="jcrwid" column="jcrwid"/>
<result property="zsrwid" column="zsrwid"/>
<result property="jcdwid" column="jcdwid"/>
<result property="jcdwmc" column="jcdwmc"/>
<result property="jczzlx" column="jczzlx"/>
<result property="cjlx" column="cjlx"/>
......@@ -17,6 +18,7 @@
SELECT
jcrw.zsrwid,
jcrw.jcrwid,
jcrw.jcdwid,
jcdw.jcdwmc,
jcrw.cjlx,
jcdw.jczzlx,
......@@ -39,7 +41,7 @@
<include refid="selectCommon"></include> WHERE jcrw.jcrwid = #{jcrwid}
</select>
<!-- 根据直属任务ID查询 -->
<select id="infoByZsrwId" parameterType="long" resultMap="ZqczJcrwResult">
<select id="infoByZsrwId" parameterType="com.qianhe.zqcz.jcrw.domain.ZqczJcrwQuery" resultMap="ZqczJcrwResult">
<include refid="selectCommon"></include> WHERE jcrw.zsrwid = #{zsrwid}
</select>
<!-- 新增 -->
......
......@@ -123,9 +123,9 @@
<if test="dataList[0].gzcj != null and dataList[0].gzcj != ''">GZCJ,</if>
<if test="dataList[0].xmrs != null">XMRS,</if>
<if test="dataList[0].xmzt != null and dataList[0].xmzt != ''">XMZT,</if>
<if test="dataList[0].createBy != null and dataList[0].createBy != ''">CREATE_BY,</if>
<if test="dataList[0].createTime != null">CREATE_TIME,</if>
<if test="dataList[0].updateBy != null and dataList[0].updateBy != ''">UPDATE_BY,</if>
<if test="dataList[0].create_by != null and dataList[0].create_by != ''">CREATE_BY,</if>
<if test="dataList[0].create_time != null">CREATE_TIME,</if>
<if test="dataList[0].update_by != null and dataList[0].update_by != ''">UPDATE_BY,</if>
<if test="dataList[0].remark != null and dataList[0].remark != ''">REMARK,</if>
<if test="dataList[0].yl1 != null and dataList[0].yl1 != ''">YL1,</if>
<if test="dataList[0].yl2 != null and dataList[0].yl2 != ''">YL2,</if>
......@@ -143,9 +143,9 @@
<if test="item.gzcj != null and item.gzcj != ''">#{item.gzcj},</if>
<if test="item.xmrs != null">#{item.xmrs},</if>
<if test="item.xmzt != null and item.xmzt != ''">#{item.xmzt},</if>
<if test="item.createBy != null and item.createBy != ''">#{item.createBy},</if>
<if test="item.createTime != null">#{item.createTime},</if>
<if test="item.updateBy != null and item.updateBy != ''">#{item.updateBy},</if>
<if test="item.create_by != null and item.create_by != ''">#{item.create_by},</if>
<if test="item.create_time != null">#{item.create_time},</if>
<if test="item.update_by != null and item.update_by != ''">#{item.update_by},</if>
<if test="item.remark != null and item.remark != ''">#{item.remark},</if>
<if test="item.yl1 != null and item.yl1 != ''">#{item.yl1},</if>
<if test="item.yl2 != null and item.yl2 != ''">#{item.yl2},</if>
......
<?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.qianhe.zqcz.xmrylsjl.mapper.ZqczXmRyLsjlMapper">
<!-- 返回实体 -->
<resultMap id="ZqczXmRyLsjlResult" type="com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlVo">
<result property="xmryid" column="XMRYID"/>
<result property="jcrwid" column="JCRWID"/>
<result property="xmmc" column="XMMC"/>
<result property="xmlb" column="XMLB"/>
<result property="rymc" column="RYMC"/>
<result property="dwmc" column="DWMC"/>
<result property="update_time" column="UPDATE_TIME"/>
<result property="jcdwmc" column="JCDWMC"/>
</resultMap>
<!-- 通用查询 -->
<sql id="selectCommon">
SELECT
lsjl.XMRYID,
lsjl.JCRWID,
lsjl.XMMC,
lsjl.XMLB,
lsjl.RYMC,
lsjl.DWMC,
lsjl.JCDWID,
jcdw.jcdwmc AS JCDWMC,
lsjl.UPDATE_TIME
FROM
zqcz_xm_ry_lsjl lsjl
LEFT JOIN zqcz_jcdw jcdw ON lsjl.jcdwid = jcdw.jcdwid
</sql>
<!-- 条件查询 -->
<select id="list" parameterType="com.qianhe.zqcz.xmrylsjl.domain.ZqczXmRyLsjlQuery" resultMap="ZqczXmRyLsjlResult">
<include refid="selectCommon"></include>
<where>
<if test="jcrwid != null ">AND lsjl.JCRWID = #{jcrwid}</if>
</where>
ORDER BY lsjl.xmlb
</select>
<!-- 查询详情 -->
<select id="info" parameterType="long" resultMap="ZqczXmRyLsjlResult">
<include refid="selectCommon"></include> WHERE lsjl.XMRYID = #{xmryid}
</select>
<!-- 新增 -->
<insert id="add" parameterType="ZqczXmRyLsjl">
INSERT INTO zqcz_xm_ry_lsjl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="xmryid != null ">XMRYID,</if>
<if test="jcrwid != null ">JCRWID,</if>
<if test="jcdwid != null">JCDWID,</if>
<if test="xmmc != null and xmmc != ''">XMMC,</if>
<if test="xmzy != null and xmzy != ''">XMZY,</if>
<if test="xmlb != null and xmlb != ''">XMLB,</if>
<if test="gzcj != null and gzcj != ''">GZCJ,</if>
<if test="rymc != null and rymc != ''">RYMC,</if>
<if test="dwmc != null and dwmc != ''">DWMC,</if>
<if test="create_by != null and create_by != ''">CREATE_BY,</if>
<if test="create_time != null ">CREATE_TIME,</if>
<if test="update_by != null and update_by != ''">UPDATE_BY,</if>
<if test="remark != null and remark != ''">REMARK,</if>
<if test="yl1 != null and yl1 != ''">YL1,</if>
<if test="yl2 != null and yl2 != ''">YL2,</if>
<if test="yl3 != null and yl3 != ''">YL3,</if>
<if test="yl4 != null and yl4 != ''">YL4,</if>
<if test="yl5 != null and yl5 != ''">YL5,</if>
UPDATE_TIME
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="xmryid != null">#{xmryid},</if>
<if test="jcrwid != null">#{jcrwid},</if>
<if test="jcdwid != null">#{jcdwid},</if>
<if test="xmmc != null and xmmc != ''">#{xmmc},</if>
<if test="xmzy != null and xmzy != ''">#{xmzy},</if>
<if test="xmlb != null and xmlb != ''">#{xmlb},</if>
<if test="gzcj != null and gzcj != ''">#{gzcj},</if>
<if test="rymc != null and rymc != ''">#{rymc},</if>
<if test="dwmc != null and dwmc != ''">#{dwmc},</if>
<if test="create_by != null">#{create_by},</if>
<if test="create_time != null">#{create_time},</if>
<if test="update_by != null">#{update_by},</if>
<if test="remark != null">#{remark},</if>
<if test="yl1 != null">#{yl1},</if>
<if test="yl2 != null">#{yl2},</if>
<if test="yl3 != null">#{yl3},</if>
<if test="yl4 != null">#{yl4},</if>
<if test="yl5 != null">#{yl5},</if>
now()
</trim>
</insert>
<!-- 修改 -->
<update id="edit" parameterType="ZqczXmRyLsjl">
UPDATE zqcz_xm_ry_lsjl
<trim prefix="SET" suffixOverrides=",">
<if test="jcrwid != null">JCRWID = #{jcrwid},</if>
<if test="jcdwid != null">JCDWID = #{jcdwid},</if>
<if test="xmmc != null and xmmc != ''">XMMC = #{xmmc},</if>
<if test="xmzy != null and xmzy != ''">XMZY = #{xmzy},</if>
<if test="xmlb != null and xmlb != ''">XMLB = #{xmlb},</if>
<if test="gzcj != null and gzcj != ''">GZCJ = #{gzcj},</if>
<if test="rymc != null and rymc != ''">RYMC = #{rymc},</if>
<if test="dwmc != null and dwmc != ''">DWMC = #{dwmc},</if>
<if test="create_by != null">CREATE_BY = #{create_by},</if>
<if test="create_time != null">CREATE_TIME = #{create_time},</if>
<if test="update_by != null">UPDATE_BY = #{update_by},</if>
<if test="remark != null">REMARK = #{remark},</if>
<if test="yl1 != null">YL1 = #{yl1},</if>
<if test="yl2 != null">YL2 = #{yl2},</if>
<if test="yl3 != null">YL3 = #{yl3},</if>
<if test="yl4 != null">YL4 = #{yl4},</if>
<if test="yl5 != null">YL5 = #{yl5},</if>
UPDATE_TIME = now()
</trim>
WHERE XMRYID = #{xmryid}
</update>
<!-- 删除 -->
<delete id="delete" parameterType="long">
DELETE FROM zqcz_xm_ry_lsjl WHERE XMRYID IN
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 批量新增 -->
<insert id="batchAdd" parameterType="java.util.List">
<choose>
<when test="dataList != null and dataList.size() > 0 and !dataList.isEmpty()">
INSERT INTO zqcz_xm_ry_lsjl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dataList[0].jcrwid != null">JCRWID,</if>
<if test="dataList[0].jcdwid != null">JCDWID,</if>
<if test="dataList[0].xmmc != null and dataList[0].xmmc != ''">XMMC,</if>
<if test="dataList[0].xmzy != null and dataList[0].xmzy != ''">XMZY,</if>
<if test="dataList[0].xmlb != null and dataList[0].xmlb != ''">XMLB,</if>
<if test="dataList[0].gzcj != null and dataList[0].gzcj != ''">GZCJ,</if>
<if test="dataList[0].rymc != null and dataList[0].rymc != ''">RYMC,</if>
<if test="dataList[0].dwmc != null and dataList[0].dwmc != ''">DWMC,</if>
<if test="dataList[0].create_by != null and dataList[0].create_by != ''">CREATE_BY,</if>
<if test="dataList[0].create_time != null">CREATE_TIME,</if>
<if test="dataList[0].update_by != null and dataList[0].update_by != ''">UPDATE_BY,</if>
<if test="dataList[0].remark != null and dataList[0].remark != ''">REMARK,</if>
<if test="dataList[0].yl1 != null and dataList[0].yl1 != ''">YL1,</if>
<if test="dataList[0].yl2 != null and dataList[0].yl2 != ''">YL2,</if>
<if test="dataList[0].yl3 != null and dataList[0].yl3 != ''">YL3,</if>
<if test="dataList[0].yl4 != null and dataList[0].yl4 != ''">YL4,</if>
<if test="dataList[0].yl5 != null and dataList[0].yl5 != ''">YL5,</if>
UPDATE_TIME
</trim>
VALUES
<foreach collection="dataList" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.jcrwid != null">#{item.jcrwid},</if>
<if test="item.jcdwid != null">#{item.jcdwid},</if>
<if test="item.xmmc != null and item.xmmc != ''">#{item.xmmc},</if>
<if test="item.xmzy != null and item.xmzy != ''">#{item.xmzy},</if>
<if test="item.xmlb != null and item.xmlb != ''">#{item.xmlb},</if>
<if test="item.gzcj != null and item.gzcj != ''">#{item.gzcj},</if>
<if test="item.rymc != null and item.rymc != ''">#{item.rymc},</if>
<if test="item.dwmc != null and item.dwmc != ''">#{item.dwmc},</if>
<if test="item.create_by != null and item.create_by != ''">#{item.create_by},</if>
<if test="item.create_time != null">#{item.create_time},</if>
<if test="item.update_by != null and item.update_by != ''">#{item.update_by},</if>
<if test="item.remark != null and item.remark != ''">#{item.remark},</if>
<if test="item.yl1 != null and item.yl1 != ''">#{item.yl1},</if>
<if test="item.yl2 != null and item.yl2 != ''">#{item.yl2},</if>
<if test="item.yl3 != null and item.yl3 != ''">#{item.yl3},</if>
<if test="item.yl4 != null and item.yl4 != ''">#{item.yl4},</if>
<if test="item.yl5 != null and item.yl5 != ''">#{item.yl5},</if>
now()
</trim>
</foreach>
</when>
<otherwise>
SELECT 0 FROM DUAL
</otherwise>
</choose>
</insert>
<!-- 根据基层任务ID删除 -->
<delete id="deleteByJcrwid" parameterType="long">
DELETE FROM zqcz_xm_ry_lsjl WHERE JCRWID = #{jcrwid}
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment