领料审批流

This commit is contained in:
syruan 2024-03-18 15:30:37 +08:00
parent 5b4914da1d
commit 78b6f03bb3
18 changed files with 2051 additions and 14 deletions

View File

@ -0,0 +1,56 @@
package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 流程实体类
* @author syruan
*/
@ApiModel(description="bm_flow")
@Data
public class BmFlow implements Serializable {
private static final long serialVersionUID = -5222289413162493784L;
/**
* 主键
*/
@ApiModelProperty(value = "id")
private Integer id;
/**
* 父节点
*/
@ApiModelProperty(value = "父节点")
private Integer pId;
/**
* 子流程名称
*/
@ApiModelProperty(value = "子流程名称")
private String name;
/**
* 子流程标识
*/
@ApiModelProperty(value = "子流程标识")
private String tag;
/**
* 是否开启 0:关闭 1:开启
*/
@ApiModelProperty(value = "是否开启")
private String status;
/**
* 任务类型
*/
@ApiModelProperty(value = "任务类型")
private String taskType;
}

View File

@ -0,0 +1,63 @@
package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 流程记录
* @author syruan
*/
@Data
@ApiModel(description="bm_flow_record")
public class BmFlowRecord implements Serializable {
private static final long serialVersionUID = 1897734004905597207L;
/**
*
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 任务id
*/
@ApiModelProperty(value = "任务id")
private Integer taskId;
/**
* 实例id
*/
@ApiModelProperty(value = "实例id")
private Integer flowId;
/**
* 上个流程
*/
@ApiModelProperty(value = "上个流程")
private Integer preFlowId;
/**
* 下个流程
*/
@ApiModelProperty(value = "下个流程")
private Integer nextFlowId;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String creator;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
}

View File

@ -0,0 +1,64 @@
package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* Description: 流程配置
* @Author 阮世耀
* @Create 2024/3/16 13:03
* @Version 1.0
*/
@Data
@ApiModel(description="bm_flow_relation")
public class BmFlowRelation implements Serializable {
private static final long serialVersionUID = 3306826714431115622L;
/**
*
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 父节点
*/
@ApiModelProperty(value = "父节点")
private Integer flowId;
/**
* 组织机构
*/
@ApiModelProperty(value = "组织机构")
private Integer companyId;
/**
* 是否开启
*/
@ApiModelProperty(value = "是否开启")
private String status;
/**
* 流执行顺序
*/
@ApiModelProperty(value = "流执行顺序")
private Integer order;
/**
* 任务类型
*/
@ApiModelProperty(value = "任务类型")
private Integer taskType;
/**
* 任务状态
*/
@ApiModelProperty(value = "任务状态")
private String taskStatus;
}

View File

@ -6,10 +6,9 @@ import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.app.domain.TmTaskDto;
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
import com.bonus.sgzb.app.service.LeaseApplyInfoService;
import com.bonus.sgzb.app.service.LeaseUserBookService;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.app.service.*;
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import com.bonus.sgzb.common.core.utils.ListPagingUtil;
import com.bonus.sgzb.common.core.utils.ServletUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
@ -28,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
@ -58,12 +58,17 @@ public class TmTaskController extends BaseController {
@Resource
private LeaseApplyDetailsService leaseApplyDetailsService;
@Resource
private BmFlowRelationService bmFlowRelationService;
@Resource
private BmFlowRecordService bmFlowRecordService;
@Autowired
private LeaseUserBookService leaseUserBookService;
private final static String STRING_ADMIN = "admin";
/**
* 领料审核通过分公司分管机具分公司统一接口
*
@ -137,9 +142,125 @@ public class TmTaskController extends BaseController {
}
/**
* 创建领料申请任务 --- New 审批流
*/
@Log(title = "创建领料申请任务", businessType = BusinessType.INSERT)
@PostMapping("createFlowLeaseApply")
public AjaxResult createFlowLeaseApply(@RequestBody TmTask task) {
// ------参数校验---------
if (StringUtils.isNull(task) || StringUtils.isNull(task.getCompanyId())) {
return AjaxResult.error("参数错误,请求参数为空或申请人组织ID为空请重试");
}
if (StringUtils.isNull(task.getLeaseApplyInfo())) {
return AjaxResult.error("领料任务信息为空,请重试");
}
if (CollUtil.isEmpty(task.getLeaseApplyDetails())) {
return AjaxResult.error("领料设备明细为空,请重新选择后上传!");
}
// ---------审批流校验---------
// 查询当前任务类型的审批流配置
BmFlowRelation bmFlowRelation = new BmFlowRelation();
// 赋值任务类型
bmFlowRelation.setTaskType(29);
// 赋值组织机构
bmFlowRelation.setCompanyId(task.getCompanyId());
List<BmFlowRelation> bmFlowRelationList = bmFlowRelationService.selectAllByPrimaryKey(bmFlowRelation);
// 校验审批流配置
if (CollUtil.isEmpty(bmFlowRelationList)) {
return AjaxResult.error("当前任务类型审批流配置为空,请联系管理员");
}
// -----------开始处理审批流 -------------
// 使用lambda表达式 按order字段从小到大进行排序
try {
bmFlowRelationList.sort(Comparator.comparingInt(BmFlowRelation::getOrder));
} catch (Exception e) {
return AjaxResult.error("处理审批流排序失败,请联系运维人员:" + e.getMessage());
}
// 获取起始节点状态
String flowStartTaskStatus = bmFlowRelationList.get(0).getTaskStatus();
// 设置任务状态为审批流的起点状态
task.setTaskStatus(Integer.valueOf(flowStartTaskStatus));
// -----------审批流处理结束 -------------
// 生成领料编码
String code = tmTaskService.genderLeaseCode();
if (StringUtils.isEmpty(code)) { return AjaxResult.error("后台生成CODE编号异常请重试!"); }
task.setCode(code);
// 创建任务
if (tmTaskService.insertSelective(task) < 1) { return AjaxResult.error("创建领料任务失败,请重试!"); }
//任务与协议建立关联关系
if (tmTaskService.insertAgreement(task) < 1) { return AjaxResult.error("领料任务与协议建立关联关系失败,请重试!"); }
// 获取任务编号
String taskId = task.getId();
if (StringUtils.isEmpty(taskId)) {return AjaxResult.error("任务编号为空,创建失败");}
// -----------数据处理开始start ---------------
// 根据设备所属分公司拆分集合
List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.groupByField(task.getLeaseApplyDetails(), "companyId");
// 对拆分后的集合进行each遍历
for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
// 判断拆分后的集合内是否有数据
if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
// 对领料任务表的对象做数据处理
LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
leaseApplyInfo.setCode(code);
leaseApplyInfo.setTaskId(Integer.valueOf(taskId));
// 设置设备所属分公司,用于交给哪家审核
leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId());
// 设置审批层级根据已启用的审批流进行赋值层数
leaseApplyInfo.setType(String.valueOf(bmFlowRelationList.size()));
// 创建领料任务返回领料任务编号
if (leaseApplyInfoService.genderLeaseCode(leaseApplyInfo) < 1) { return AjaxResult.error("创建领料任务失败,或领料明细为空"); }
// 领料任务创建完成进行领料任务明细插入
ArrayList<Integer> ids = new ArrayList<>();
if (StringUtils.isNotNull(leaseApplyInfo.getId())) {
for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
// 设置领料任务ID
leaseApplyDetails.setParenntId(leaseApplyInfo.getId());
ids.add(leaseApplyDetails.getId());
}
// 插入领料任务明细
if (leaseApplyDetailsService.batchInsert(leaseApplyDetailsList) > 0) {
leaseUserBookService.batchDel(ids);
} else {
System.out.println(("领料任务明细插入失败,请重试"));
}
} else {
return AjaxResult.error("领料任务编号为空");
}
}
}
// -----------数据处理结束end ---------------
// 数据处理成功后增加审批流记录
BmFlowRecord bmFlowRecord = new BmFlowRecord();
try {
bmFlowRecord.setTaskId(Integer.valueOf(taskId));
bmFlowRecord.setFlowId(bmFlowRelationList.get(0).getFlowId());
if (bmFlowRelationList.size() > 1) { bmFlowRecord.setNextFlowId(bmFlowRelationList.get(1).getFlowId());}
// String loginUserName = SecurityUtils.getLoginUser().getSysUser().getUserName();
// bmFlowRecord.setCreator(loginUserName == null ? "" : loginUserName);
bmFlowRecordService.insertSelective(bmFlowRecord);
} catch (Exception e) {
return AjaxResult.error("数据处理完成,但审批流记录失败,请联系运维人员:" + e.getMessage());
}
return AjaxResult.success("任务创建成功,已完成");
}
/**
* 往来单位提交工程领用机具信息
*
* @return 结果
*/
@Log(title = "往来单位提交领料申请", businessType = BusinessType.INSERT)
@ -161,7 +282,6 @@ public class TmTaskController extends BaseController {
//任务与协议建立关联关系
boolean i = tmTaskService.insertAgreement(task) > 0;
if (addTaskResult && task.getLeaseApplyInfo() != null) {
if (CollUtil.isEmpty(task.getLeaseApplyDetails())) {
return AjaxResult.error("领料设备明细为空,请重新选择后上传!");

View File

@ -0,0 +1,75 @@
package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.base.api.domain.BmFlow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:43
* @Version 1.0
*/
@Mapper
public interface BmFlowMapper {
/**
* delete by primary key
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Integer id);
/**
* insert record to table
* @param record the record
* @return insert count
*/
int insert(BmFlow record);
int insertOrUpdate(BmFlow record);
int insertOrUpdateSelective(BmFlow record);
/**
* insert record to table selective
* @param record the record
* @return insert count
*/
int insertSelective(BmFlow record);
/**
* select by primary key
* @param id primary key
* @return object by primary key
*/
BmFlow selectByPrimaryKey(Integer id);
/**
* 查询全部
* @return 集合
*/
List<BmFlow> selectAll();
/**
* update record selective
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(BmFlow record);
/**
* update record
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(BmFlow record);
int updateBatch(List<BmFlow> list);
int updateBatchSelective(List<BmFlow> list);
int batchInsert(@Param("list") List<BmFlow> list);
}

View File

@ -0,0 +1,69 @@
package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:59
* @Version 1.0
*/
@Mapper
public interface BmFlowRecordMapper {
/**
* delete by primary key
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Integer id);
/**
* insert record to table
* @param record the record
* @return insert count
*/
int insert(BmFlowRecord record);
int insertOrUpdate(BmFlowRecord record);
int insertOrUpdateSelective(BmFlowRecord record);
/**
* insert record to table selective
* @param record the record
* @return insert count
*/
int insertSelective(BmFlowRecord record);
/**
* select by primary key
* @param id primary key
* @return object by primary key
*/
BmFlowRecord selectByPrimaryKey(Integer id);
/**
* update record selective
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(BmFlowRecord record);
/**
* update record
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(BmFlowRecord record);
int updateBatch(List<BmFlowRecord> list);
int updateBatchSelective(List<BmFlowRecord> list);
int batchInsert(@Param("list") List<BmFlowRecord> list);
}

View File

@ -0,0 +1,76 @@
package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 13:03
* @Version 1.0
*/
@Mapper
public interface BmFlowRelationMapper {
/**
* delete by primary key
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Integer id);
/**
* insert record to table
* @param record the record
* @return insert count
*/
int insert(BmFlowRelation record);
int insertOrUpdate(BmFlowRelation record);
int insertOrUpdateSelective(BmFlowRelation record);
/**
* insert record to table selective
* @param record the record
* @return insert count
*/
int insertSelective(BmFlowRelation record);
/**
* select by primary key
* @param id primary key
* @return object by primary key
*/
BmFlowRelation selectByPrimaryKey(Integer id);
/**
* 自动注入参数筛选查询
* @param record 注入参数
* @return 集合
*/
List<BmFlowRelation> selectAllByPrimaryKeys(BmFlowRelation record);
/**
* update record selective
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(BmFlowRelation record);
/**
* update record
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(BmFlowRelation record);
int updateBatch(List<BmFlowRelation> list);
int updateBatchSelective(List<BmFlowRelation> list);
int batchInsert(@Param("list") List<BmFlowRelation> list);
}

View File

@ -0,0 +1,37 @@
package com.bonus.sgzb.app.service;
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:59
* @Version 1.0
*/
public interface BmFlowRecordService{
int deleteByPrimaryKey(Integer id);
int insert(BmFlowRecord record);
int insertOrUpdate(BmFlowRecord record);
int insertOrUpdateSelective(BmFlowRecord record);
int insertSelective(BmFlowRecord record);
BmFlowRecord selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(BmFlowRecord record);
int updateByPrimaryKey(BmFlowRecord record);
int updateBatch(List<BmFlowRecord> list);
int updateBatchSelective(List<BmFlowRecord> list);
int batchInsert(List<BmFlowRecord> list);
}

View File

@ -0,0 +1,40 @@
package com.bonus.sgzb.app.service;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 13:03
* @Version 1.0
*/
public interface BmFlowRelationService{
int deleteByPrimaryKey(Integer id);
int insert(BmFlowRelation record);
int insertOrUpdate(BmFlowRelation record);
int insertOrUpdateSelective(BmFlowRelation record);
int insertSelective(BmFlowRelation record);
BmFlowRelation selectByPrimaryKey(Integer id);
List<BmFlowRelation> selectAllByPrimaryKey(BmFlowRelation record);
int updateByPrimaryKeySelective(BmFlowRelation record);
int updateByPrimaryKey(BmFlowRelation record);
int updateBatch(List<BmFlowRelation> list);
int updateBatchSelective(List<BmFlowRelation> list);
int batchInsert(List<BmFlowRelation> list);
}

View File

@ -0,0 +1,40 @@
package com.bonus.sgzb.app.service;
import com.bonus.sgzb.base.api.domain.BmFlow;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:43
* @Version 1.0
*/
public interface BmFlowService{
int deleteByPrimaryKey(Integer id);
int insert(BmFlow record);
int insertOrUpdate(BmFlow record);
int insertOrUpdateSelective(BmFlow record);
int insertSelective(BmFlow record);
BmFlow selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(BmFlow record);
int updateByPrimaryKey(BmFlow record);
int updateBatch(List<BmFlow> list);
int updateBatchSelective(List<BmFlow> list);
int batchInsert(List<BmFlow> list);
}

View File

@ -17,6 +17,13 @@ import java.util.List;
public interface TmTaskService{
/**
* 审批流领料申请
* @param task
* @return
*/
AjaxResult createFlowLeaseApply(TmTask task);
List<TmTask> getLeaseAuditList(TmTask record);
List<TmTask> getLeaseAuditListByOne(TmTask record);

View File

@ -0,0 +1,78 @@
package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.mapper.BmFlowRecordMapper;
import com.bonus.sgzb.app.service.BmFlowRecordService;
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:59
* @Version 1.0
*/
@Service
public class BmFlowRecordServiceImpl implements BmFlowRecordService{
@Autowired
private BmFlowRecordMapper bmFlowRecordMapper;
@Override
public int deleteByPrimaryKey(Integer id) {
return bmFlowRecordMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(BmFlowRecord record) {
return bmFlowRecordMapper.insert(record);
}
@Override
public int insertOrUpdate(BmFlowRecord record) {
return bmFlowRecordMapper.insertOrUpdate(record);
}
@Override
public int insertOrUpdateSelective(BmFlowRecord record) {
return bmFlowRecordMapper.insertOrUpdateSelective(record);
}
@Override
public int insertSelective(BmFlowRecord record) {
return bmFlowRecordMapper.insertSelective(record);
}
@Override
public BmFlowRecord selectByPrimaryKey(Integer id) {
return bmFlowRecordMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(BmFlowRecord record) {
return bmFlowRecordMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(BmFlowRecord record) {
return bmFlowRecordMapper.updateByPrimaryKey(record);
}
@Override
public int updateBatch(List<BmFlowRecord> list) {
return bmFlowRecordMapper.updateBatch(list);
}
@Override
public int updateBatchSelective(List<BmFlowRecord> list) {
return bmFlowRecordMapper.updateBatchSelective(list);
}
@Override
public int batchInsert(List<BmFlowRecord> list) {
return bmFlowRecordMapper.batchInsert(list);
}
}

View File

@ -0,0 +1,83 @@
package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.mapper.BmFlowRelationMapper;
import com.bonus.sgzb.app.service.BmFlowRelationService;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 13:03
* @Version 1.0
*/
@Service
public class BmFlowRelationServiceImpl implements BmFlowRelationService{
@Autowired
private BmFlowRelationMapper bmFlowRelationMapper;
@Override
public int deleteByPrimaryKey(Integer id) {
return bmFlowRelationMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(BmFlowRelation record) {
return bmFlowRelationMapper.insert(record);
}
@Override
public int insertOrUpdate(BmFlowRelation record) {
return bmFlowRelationMapper.insertOrUpdate(record);
}
@Override
public int insertOrUpdateSelective(BmFlowRelation record) {
return bmFlowRelationMapper.insertOrUpdateSelective(record);
}
@Override
public int insertSelective(BmFlowRelation record) {
return bmFlowRelationMapper.insertSelective(record);
}
@Override
public BmFlowRelation selectByPrimaryKey(Integer id) {
return bmFlowRelationMapper.selectByPrimaryKey(id);
}
@Override
public List<BmFlowRelation> selectAllByPrimaryKey(BmFlowRelation record) {
return bmFlowRelationMapper.selectAllByPrimaryKeys(record);
}
@Override
public int updateByPrimaryKeySelective(BmFlowRelation record) {
return bmFlowRelationMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(BmFlowRelation record) {
return bmFlowRelationMapper.updateByPrimaryKey(record);
}
@Override
public int updateBatch(List<BmFlowRelation> list) {
return bmFlowRelationMapper.updateBatch(list);
}
@Override
public int updateBatchSelective(List<BmFlowRelation> list) {
return bmFlowRelationMapper.updateBatchSelective(list);
}
@Override
public int batchInsert(List<BmFlowRelation> list) {
return bmFlowRelationMapper.batchInsert(list);
}
}

View File

@ -0,0 +1,78 @@
package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.mapper.BmFlowMapper;
import com.bonus.sgzb.app.service.BmFlowService;
import com.bonus.sgzb.base.api.domain.BmFlow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Description:
* @Author 阮世耀
* @Create 2024/3/16 12:43
* @Version 1.0
*/
@Service
public class BmFlowServiceImpl implements BmFlowService{
@Autowired
private BmFlowMapper bmFlowMapper;
@Override
public int deleteByPrimaryKey(Integer id) {
return bmFlowMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(BmFlow record) {
return bmFlowMapper.insert(record);
}
@Override
public int insertOrUpdate(BmFlow record) {
return bmFlowMapper.insertOrUpdate(record);
}
@Override
public int insertOrUpdateSelective(BmFlow record) {
return bmFlowMapper.insertOrUpdateSelective(record);
}
@Override
public int insertSelective(BmFlow record) {
return bmFlowMapper.insertSelective(record);
}
@Override
public BmFlow selectByPrimaryKey(Integer id) {
return bmFlowMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(BmFlow record) {
return bmFlowMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(BmFlow record) {
return bmFlowMapper.updateByPrimaryKey(record);
}
@Override
public int updateBatch(List<BmFlow> list) {
return bmFlowMapper.updateBatch(list);
}
@Override
public int updateBatchSelective(List<BmFlow> list) {
return bmFlowMapper.updateBatchSelective(list);
}
@Override
public int batchInsert(List<BmFlow> list) {
return bmFlowMapper.batchInsert(list);
}
}

View File

@ -7,7 +7,11 @@ import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
import com.bonus.sgzb.app.mapper.LeaseApplyInfoMapper;
import com.bonus.sgzb.app.mapper.TmTaskMapper;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.app.service.*;
import com.bonus.sgzb.base.api.domain.BmFlowRecord;
import com.bonus.sgzb.base.api.domain.BmFlowRelation;
import com.bonus.sgzb.common.core.constant.Constants;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
@ -18,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -45,13 +46,33 @@ public class TmTaskServiceImpl implements TmTaskService {
@Resource
private LeaseApplyDetailsMapper leaseApplyDetailsMapper;
@Resource
private BmFlowRelationService bmFlowRelationService;
@Resource
private TmTaskService tmTaskService;
// 领料申请表Service
@Resource
private LeaseApplyInfoService leaseApplyInfoService;
// 领料申请明细表Service
@Resource
private LeaseApplyDetailsService leaseApplyDetailsService;
@Resource
private LeaseUserBookService leaseUserBookService;
@Resource
private BmFlowRecordService bmFlowRecordService;
/**
* 领料任务审核状态
*
* @param record 审核数据及信息
*/
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public int updateLeaseTaskAuditInfo(TmTask record) {
int result = 0;
int taskId = 0;
@ -210,6 +231,158 @@ public class TmTaskServiceImpl implements TmTaskService {
return tmTaskList;
}
/**
* 创建审批流领料申请
* @param task 任务信息
* @return 执行结果
*/
@Override
public AjaxResult createFlowLeaseApply(TmTask task) {
// ---------审批流校验---------
List<BmFlowRelation> bmFlowRelationList = leaseExamFlowParamCheck(task);
// 校验审批流配置
if (CollUtil.isEmpty(bmFlowRelationList)) {
return AjaxResult.error("当前任务类型审批流配置为空,请联系管理员");
}
// 审批流排序
if (!copeOrderByField(bmFlowRelationList)) { return AjaxResult.error("审批流排序失败,请联系管理员"); }
// 获取起始节点状态
String flowStartTaskStatus = bmFlowRelationList.get(0).getTaskStatus();
// 设置任务状态为审批流的起点状态
task.setTaskStatus(Integer.valueOf(flowStartTaskStatus));
// -----------审批流处理结束 -------------
// 生成领料编码
String code = tmTaskService.genderLeaseCode();
if (StringUtils.isEmpty(code)) { return AjaxResult.error("后台生成CODE编号异常请重试!"); }
task.setCode(code);
// 创建任务
if (tmTaskService.insertSelective(task) < 1) { return AjaxResult.error("创建领料任务失败,请重试!"); }
//任务与协议建立关联关系
if (tmTaskService.insertAgreement(task) < 1) { return AjaxResult.error("领料任务与协议建立关联关系失败,请重试!"); }
// 获取任务编号
String taskId = task.getId();
if (StringUtils.isEmpty(taskId)) {return AjaxResult.error("任务编号为空,创建失败");}
// 处理任务数据实例化至DB
R<String> taskDataCopeResult = leaseTaskDataCope(task, code, taskId, bmFlowRelationList.size());
if (taskDataCopeResult.getCode() != Constants.SUCCESS) {
return AjaxResult.error(taskDataCopeResult.getMsg());
}
// 数据处理成功后增加审批流记录
R<?> addLeaseTaskFlowRecordResult = addLeaseTaskFlowRecord(taskId, bmFlowRelationList);
if (addLeaseTaskFlowRecordResult.getCode() != Constants.SUCCESS) {
return AjaxResult.error(addLeaseTaskFlowRecordResult.getMsg());
}
return AjaxResult.success("执行成功,领料任务已添加");
}
private R<?> addLeaseTaskFlowRecord(String taskId, List<BmFlowRelation> bmFlowRelationList) {
BmFlowRecord bmFlowRecord = new BmFlowRecord();
try {
bmFlowRecord.setTaskId(Integer.valueOf(taskId));
bmFlowRecord.setFlowId(bmFlowRelationList.get(0).getFlowId());
if (bmFlowRelationList.size() > 1) { bmFlowRecord.setNextFlowId(bmFlowRelationList.get(1).getFlowId());}
// String loginUserName = SecurityUtils.getLoginUser().getSysUser().getUserName();
// bmFlowRecord.setCreator(loginUserName == null ? "" : loginUserName);
bmFlowRecordService.insertSelective(bmFlowRecord);
} catch (Exception e) {
return R.fail("数据处理完成,但审批流记录失败,请联系运维人员:{}", e.getMessage());
}
return R.ok(Constants.LOGIN_SUCCESS);
}
private R<String> leaseTaskDataCope(TmTask task, String code, String taskId, Integer bmFlowRelationListSize) {
// -----------数据处理开始start ---------------
// 根据设备所属分公司--拆分集合
List<List<LeaseApplyDetails>> deviceByCompanyList;
try {
deviceByCompanyList = CollUtil.groupByField(task.getLeaseApplyDetails(), "companyId");
} catch (RuntimeException e) {
log.error("领料任务数据拆分集合处理异常,请重试:{}", e.getMessage());
return R.fail("领料任务数据拆分集合处理异常,请重试");
}
ArrayList<Integer> ids = new ArrayList<>();
// 对拆分后的集合进行each遍历
for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
// 判断拆分后的集合内是否有数据
if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
// 对领料任务表的对象做数据处理
LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
leaseApplyInfo.setCode(code);
leaseApplyInfo.setTaskId(Integer.valueOf(taskId));
// 设置设备所属分公司,用于交给哪家审核
leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId());
// 设置审批层级根据已启用的审批流进行赋值层数
leaseApplyInfo.setType(String.valueOf(bmFlowRelationListSize));
// 创建领料任务返回领料任务编号
if (leaseApplyInfoService.genderLeaseCode(leaseApplyInfo) < 1) {
return R.fail("创建领料任务失败,或领料明细为空");
}
// 领料任务创建完成进行领料任务明细插入
ids.clear();
if (StringUtils.isNotNull(leaseApplyInfo.getId())) {
for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
// 设置领料任务ID
leaseApplyDetails.setParenntId(leaseApplyInfo.getId());
ids.add(leaseApplyDetails.getId());
}
// 插入领料任务明细
if (leaseApplyDetailsService.batchInsert(leaseApplyDetailsList) > 0) {
leaseUserBookService.batchDel(ids);
} else {
log.error("领料任务明细插入失败:{}", task.getTaskId());
System.out.println(("领料任务明细插入失败,请重试"));
}
} else {
return R.fail("领料任务编号为空");
}
}
}
// -----------数据处理结束end ---------------
return R.ok(null, "领料任务数据插入成功");
}
/**
* 审批流排序
* @param bmFlowRelationList 审批流数据集合
* @return 排序结果
*/
public static boolean copeOrderByField(List<BmFlowRelation> bmFlowRelationList) {
// 使用lambda表达式 按order字段从小到大进行排序
try {
bmFlowRelationList.sort(Comparator.comparingInt(BmFlowRelation::getOrder));
} catch (Exception e) {
log.error("审批流排序处理异常:{}", e.getMessage());
return false;
}
return true;
}
/**
* 根据任务入参查询审批流信息
* @param task 任务
* @return 审批流数据集合
*/
private List<BmFlowRelation> leaseExamFlowParamCheck(TmTask task) {
// ---------审批流校验---------
// 查询当前任务类型的审批流配置
BmFlowRelation bmFlowRelation = new BmFlowRelation();
// 赋值任务类型
bmFlowRelation.setTaskType(29);
// 赋值组织机构
bmFlowRelation.setCompanyId(task.getCompanyId());
return bmFlowRelationService.selectAllByPrimaryKey(bmFlowRelation);
}
/**
* 获取单个申请列表
*/
@ -705,7 +878,7 @@ public class TmTaskServiceImpl implements TmTaskService {
String result = format.replace("-", "");
int num = tmTaskMapper.selectNumByMonth(nowDate);
num = num + 1;
String code = "";
String code;
if (num > 9 && num < 100) {
code = "L" + result + "-00" + num;
} else if (num > 99 && num < 1000) {

View File

@ -0,0 +1,318 @@
<?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.bonus.sgzb.app.mapper.BmFlowMapper">
<resultMap id="BaseResultMap" type="com.bonus.sgzb.base.api.domain.BmFlow">
<!--@mbg.generated-->
<!--@Table bm_flow-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="p_id" jdbcType="INTEGER" property="pId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="tag" jdbcType="VARCHAR" property="tag" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, p_id, `name`, tag, `status`, task_type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from bm_flow
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from bm_flow
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete from bm_flow
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow (p_id, `name`, tag,
`status`, task_type)
values (#{pId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{tag,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="pId != null">
p_id,
</if>
<if test="name != null and name != ''">
`name`,
</if>
<if test="tag != null and tag != ''">
tag,
</if>
<if test="status != null and status != ''">
`status`,
</if>
<if test="taskType != null and taskType != ''">
task_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="pId != null">
#{pId,jdbcType=INTEGER},
</if>
<if test="name != null and name != ''">
#{name,jdbcType=VARCHAR},
</if>
<if test="tag != null and tag != ''">
#{tag,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
#{status,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
#{taskType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlow">
<!--@mbg.generated-->
update bm_flow
<set>
<if test="pId != null">
p_id = #{pId,jdbcType=INTEGER},
</if>
<if test="name != null and name != ''">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="tag != null and tag != ''">
tag = #{tag,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
task_type = #{taskType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.base.api.domain.BmFlow">
<!--@mbg.generated-->
update bm_flow
set p_id = #{pId,jdbcType=INTEGER},
`name` = #{name,jdbcType=VARCHAR},
tag = #{tag,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow
<trim prefix="set" suffixOverrides=",">
<trim prefix="p_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.pId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="`name` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.name,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="tag = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.tag,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="task_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow
<trim prefix="set" suffixOverrides=",">
<trim prefix="p_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.pId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.pId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="`name` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.name != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.name,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="tag = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.tag != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.tag,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.status != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="task_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taskType != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow
(p_id, `name`, tag, `status`, task_type)
values
<foreach collection="list" item="item" separator=",">
(#{item.pId,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR}, #{item.tag,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
p_id,
`name`,
tag,
`status`,
task_type,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{pId,jdbcType=INTEGER},
#{name,jdbcType=VARCHAR},
#{tag,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
p_id = #{pId,jdbcType=INTEGER},
`name` = #{name,jdbcType=VARCHAR},
tag = #{tag,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlow" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="pId != null">
p_id,
</if>
<if test="name != null and name != ''">
`name`,
</if>
<if test="tag != null and tag != ''">
tag,
</if>
<if test="status != null and status != ''">
`status`,
</if>
<if test="taskType != null and taskType != ''">
task_type,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="pId != null">
#{pId,jdbcType=INTEGER},
</if>
<if test="name != null and name != ''">
#{name,jdbcType=VARCHAR},
</if>
<if test="tag != null and tag != ''">
#{tag,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
#{status,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
#{taskType,jdbcType=VARCHAR},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="pId != null">
p_id = #{pId,jdbcType=INTEGER},
</if>
<if test="name != null and name != ''">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="tag != null and tag != ''">
tag = #{tag,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
task_type = #{taskType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper>

View File

@ -0,0 +1,332 @@
<?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.bonus.sgzb.app.mapper.BmFlowRecordMapper">
<resultMap id="BaseResultMap" type="com.bonus.sgzb.base.api.domain.BmFlowRecord">
<!--@mbg.generated-->
<!--@Table bm_flow_record-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="task_id" jdbcType="INTEGER" property="taskId" />
<result column="flow_id" jdbcType="INTEGER" property="flowId" />
<result column="pre_flow_id" jdbcType="INTEGER" property="preFlowId" />
<result column="next_flow_id" jdbcType="INTEGER" property="nextFlowId" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, task_id, flow_id, pre_flow_id, next_flow_id, creator, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from bm_flow_record
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete from bm_flow_record
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_record (task_id, flow_id, pre_flow_id,
next_flow_id, creator, create_time
)
values (#{taskId,jdbcType=INTEGER}, #{flowId,jdbcType=INTEGER}, #{preFlowId,jdbcType=INTEGER},
#{nextFlowId,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
insert into bm_flow_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">
task_id,
</if>
<if test="flowId != null">
flow_id,
</if>
<if test="preFlowId != null">
pre_flow_id,
</if>
<if test="nextFlowId != null">
next_flow_id,
</if>
<if test="creator != null and creator != ''">
creator,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">
#{taskId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
#{flowId,jdbcType=INTEGER},
</if>
<if test="preFlowId != null">
#{preFlowId,jdbcType=INTEGER},
</if>
<if test="nextFlowId != null">
#{nextFlowId,jdbcType=INTEGER},
</if>
<if test="creator != null and creator != ''">
#{creator,jdbcType=VARCHAR}
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
<!--@mbg.generated-->
update bm_flow_record
<set>
<if test="taskId != null">
task_id = #{taskId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
flow_id = #{flowId,jdbcType=INTEGER},
</if>
<if test="preFlowId != null">
pre_flow_id = #{preFlowId,jdbcType=INTEGER},
</if>
<if test="nextFlowId != null">
next_flow_id = #{nextFlowId,jdbcType=INTEGER},
</if>
<if test="creator != null and creator != ''">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord">
<!--@mbg.generated-->
update bm_flow_record
set task_id = #{taskId,jdbcType=INTEGER},
flow_id = #{flowId,jdbcType=INTEGER},
pre_flow_id = #{preFlowId,jdbcType=INTEGER},
next_flow_id = #{nextFlowId,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow_record
<trim prefix="set" suffixOverrides=",">
<trim prefix="task_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="pre_flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.preFlowId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="next_flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.nextFlowId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="creator = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.creator,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="create_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow_record
<trim prefix="set" suffixOverrides=",">
<trim prefix="task_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taskId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.flowId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="pre_flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.preFlowId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.preFlowId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="next_flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.nextFlowId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.nextFlowId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="creator = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.creator != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.creator,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="create_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createTime != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_record
(task_id, flow_id, pre_flow_id, next_flow_id, creator, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.taskId,jdbcType=INTEGER}, #{item.flowId,jdbcType=INTEGER}, #{item.preFlowId,jdbcType=INTEGER},
#{item.nextFlowId,jdbcType=INTEGER}, #{item.creator,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
task_id,
flow_id,
pre_flow_id,
next_flow_id,
creator,
create_time,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{taskId,jdbcType=INTEGER},
#{flowId,jdbcType=INTEGER},
#{preFlowId,jdbcType=INTEGER},
#{nextFlowId,jdbcType=INTEGER},
#{creator,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
task_id = #{taskId,jdbcType=INTEGER},
flow_id = #{flowId,jdbcType=INTEGER},
pre_flow_id = #{preFlowId,jdbcType=INTEGER},
next_flow_id = #{nextFlowId,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRecord" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="taskId != null">
task_id,
</if>
<if test="flowId != null">
flow_id,
</if>
<if test="preFlowId != null">
pre_flow_id,
</if>
<if test="nextFlowId != null">
next_flow_id,
</if>
<if test="creator != null and creator != ''">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="taskId != null">
#{taskId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
#{flowId,jdbcType=INTEGER},
</if>
<if test="preFlowId != null">
#{preFlowId,jdbcType=INTEGER},
</if>
<if test="nextFlowId != null">
#{nextFlowId,jdbcType=INTEGER},
</if>
<if test="creator != null and creator != ''">
#{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="taskId != null">
task_id = #{taskId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
flow_id = #{flowId,jdbcType=INTEGER},
</if>
<if test="preFlowId != null">
pre_flow_id = #{preFlowId,jdbcType=INTEGER},
</if>
<if test="nextFlowId != null">
next_flow_id = #{nextFlowId,jdbcType=INTEGER},
</if>
<if test="creator != null and creator != ''">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
</mapper>

View File

@ -0,0 +1,328 @@
<?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.bonus.sgzb.app.mapper.BmFlowRelationMapper">
<resultMap id="BaseResultMap" type="com.bonus.sgzb.base.api.domain.BmFlowRelation">
<!--@Table bm_flow_relation-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="flow_id" jdbcType="INTEGER" property="flowId" />
<result column="company_id" jdbcType="INTEGER" property="companyId" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="order" jdbcType="INTEGER" property="order" />
<result column="task_type" jdbcType="INTEGER" property="taskType" />
<result column="task_status" jdbcType="VARCHAR" property="taskStatus" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, flow_id, company_id, `status`, `order`, task_type, task_status
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from bm_flow_relation
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllByPrimaryKeys" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from bm_flow_relation
<where>
`status` = '1'
<if test="flowId != null">
and flow_id = #{flowId,jdbcType=INTEGER}
</if>
<if test="companyId != null">
and company_id = #{companyId,jdbcType=INTEGER}
</if>
<if test="taskType != null and taskType != ''">
and task_type = #{taskType,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete from bm_flow_relation
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_relation (flow_id, company_id, `status`,
`order`, task_type)
values (#{flowId,jdbcType=INTEGER}, #{companyId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{order,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="flowId != null">
flow_id,
</if>
<if test="companyId != null and companyId != ''">
company_id,
</if>
<if test="status != null and status != ''">
`status`,
</if>
<if test="order != null and order != ''">
`order`,
</if>
<if test="taskType != null and taskType != ''">
task_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="flowId != null">
#{flowId,jdbcType=INTEGER},
</if>
<if test="companyId != null and companyId != ''">
#{companyId,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
#{status,jdbcType=VARCHAR},
</if>
<if test="order != null and order != ''">
#{order,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
#{taskType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation">
<!--@mbg.generated-->
update bm_flow_relation
<set>
<if test="flowId != null">
flow_id = #{flowId,jdbcType=INTEGER},
</if>
<if test="companyId != null and companyId != ''">
company_id = #{companyId,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="order != null and order != ''">
`order` = #{order,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
task_type = #{taskType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation">
<!--@mbg.generated-->
update bm_flow_relation
set flow_id = #{flowId,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
`order` = #{order,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow_relation
<trim prefix="set" suffixOverrides=",">
<trim prefix="flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="company_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.companyId,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`order` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.order,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="task_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update bm_flow_relation
<trim prefix="set" suffixOverrides=",">
<trim prefix="flow_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.flowId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.flowId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="company_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.companyId != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.companyId,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.status != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="`order` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.order != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.order,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="task_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taskType != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.taskType,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into bm_flow_relation
(flow_id, company_id, `status`, `order`, task_type)
values
<foreach collection="list" item="item" separator=",">
(#{item.flowId,jdbcType=INTEGER}, #{item.companyId,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR},
#{item.order,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation" useGeneratedKeys="true">
insert into bm_flow_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
flow_id,
company_id,
`status`,
`order`,
task_type,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{flowId,jdbcType=INTEGER},
#{companyId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
#{order,jdbcType=VARCHAR},
#{taskType,jdbcType=VARCHAR},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
flow_id = #{flowId,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
`order` = #{order,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.base.api.domain.BmFlowRelation" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_flow_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="flowId != null">
flow_id,
</if>
<if test="companyId != null and companyId != ''">
company_id,
</if>
<if test="status != null and status != ''">
`status`,
</if>
<if test="order != null and order != ''">
`order`,
</if>
<if test="taskType != null and taskType != ''">
task_type,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="flowId != null">
#{flowId,jdbcType=INTEGER},
</if>
<if test="companyId != null and companyId != ''">
#{companyId,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
#{status,jdbcType=VARCHAR},
</if>
<if test="order != null and order != ''">
#{order,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
#{taskType,jdbcType=VARCHAR},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="flowId != null">
flow_id = #{flowId,jdbcType=INTEGER},
</if>
<if test="companyId != null and companyId != ''">
company_id = #{companyId,jdbcType=VARCHAR},
</if>
<if test="status != null and status != ''">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="order != null and order != ''">
`order` = #{order,jdbcType=VARCHAR},
</if>
<if test="taskType != null and taskType != ''">
task_type = #{taskType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper>