Commit 83faf830 by shenweidong

解决冲突

parents 2c21ca29 e79c4c38
...@@ -61,4 +61,3 @@ Thumbs.db ...@@ -61,4 +61,3 @@ Thumbs.db
/jyzb-boot/pom.xml /jyzb-boot/pom.xml
/.idea/encodings.xml /.idea/encodings.xml
/jyzb-api/jyzb-api.iml /jyzb-api/jyzb-api.iml
/jyzb-api/jyzb-api.iml
...@@ -47,5 +47,12 @@ public class CabinetBoxReq extends BaseRequest { ...@@ -47,5 +47,12 @@ public class CabinetBoxReq extends BaseRequest {
@ApiModelProperty(value = "使用日志存储位置信息") @ApiModelProperty(value = "使用日志存储位置信息")
private String logMap; private String logMap;
/**
* 警员id
*/
@ApiModelProperty(value = "警员id")
private String policeId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -76,6 +76,12 @@ public class CabinetReq extends BaseRequest { ...@@ -76,6 +76,12 @@ public class CabinetReq extends BaseRequest {
@ApiModelProperty(value = "更新人员") @ApiModelProperty(value = "更新人员")
private String updateUser; private String updateUser;
/**
* 是否包含本级及下级,true为包含,false为不包含,只显示本级
*/
@ApiModelProperty(value = "本机及下级")
private String includeLowerLevel;
// /** // /**
// * 单警柜与箱门一对多关系 // * 单警柜与箱门一对多关系
// */ // */
......
package com.junmp.jyzb.Dto;
import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class CabinetDto extends BaseRequest {
/**
* 单警柜ID
*/
@NotNull(message = "单警柜ID主键不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "单警柜ID")
private String id;
/**
* 单警柜编号
*/
@NotNull(message = "单警柜编号不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "单警柜编号")
private String cabinetNum;
/**
* 箱数
*/
@ApiModelProperty(value = "箱数")
private Integer num;
/**
* 单警柜名称
*/
@NotNull(message = "单警柜名称不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "单警柜名称")
private String name;
/**
* 组织机构号
*/
@NotNull(message = "组织机构号不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "组织机构号")
private String orgId;
/**
* 位置信息
*/
@ApiModelProperty(value = "位置信息")
private String location;
/**
* 单警柜当前状态,0正常,1异常
*/
@ApiModelProperty(value = "单警柜当前状态,0正常,1异常")
private Integer state;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 更新人员
*/
@ApiModelProperty(value = "更新人员")
private String updateUser;
/**
* 是否包含本级及下级,true为包含,false为不包含,只显示本级
*/
@ApiModelProperty(value = "本机及下级")
private String includeLowerLevel;
/**
* 单警柜与箱门一对多关系
*/
private List<CabinetBox> list ;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import com.junmp.jyzb.Dto.CabinetDto;
import com.junmp.jyzb.api.bean.req.CabinetBoxReq; import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq; import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
...@@ -46,14 +47,14 @@ public class CabinetController { ...@@ -46,14 +47,14 @@ public class CabinetController {
} }
@PostMapping("/DeleteCabinet") @PostMapping("/DeleteCabinet")
@ApiOperation("删除单警柜信息") @ApiOperation("删除单警柜")
public ResponseResult deleteCabinet(@RequestBody Map<String,Object> msg) { public ResponseResult deleteCabinet(@RequestBody Map<String,Object> msg) {
ResponseResult returnMsg = cabinetService.deleteCabinet(msg); ResponseResult returnMsg = cabinetService.deleteCabinet(msg);
return returnMsg; return returnMsg;
} }
@PostMapping("/ShowCabinet") @PostMapping("/ShowCabinet")
@ApiOperation("查询单警柜列表") @ApiOperation("查询单警柜")
public ResponseResult showCabinet(@RequestBody Map<String, Object> msg){ public ResponseResult showCabinet(@RequestBody Map<String, Object> msg){
ResponseResult returnMsg = cabinetService.getAllCabinet(msg); ResponseResult returnMsg = cabinetService.getAllCabinet(msg);
return returnMsg; return returnMsg;
...@@ -88,7 +89,7 @@ public class CabinetController { ...@@ -88,7 +89,7 @@ public class CabinetController {
} }
@PostMapping("/AddCabinetInfo") @PostMapping("/AddCabinetInfo")
@ApiOperation("添加单警柜") @ApiOperation("添加单警柜信息(新)")
public ApiRes<Boolean> addCabinetInfo(@RequestBody CabinetReq req){ public ApiRes<Boolean> addCabinetInfo(@RequestBody CabinetReq req){
boolean result = cabinetService.addCabinetInfo(req); boolean result = cabinetService.addCabinetInfo(req);
if (!result){ if (!result){
...@@ -98,37 +99,39 @@ public class CabinetController { ...@@ -98,37 +99,39 @@ public class CabinetController {
} }
@PostMapping("/DeleteCabinetInfo") @PostMapping("/DeleteCabinetInfo")
@ApiOperation("删除单警柜信息") @ApiOperation("删除单警柜信息(新)")
public ApiRes<Boolean> deleteCabinetInfo(@RequestBody CabinetReq req) { public ApiRes<Boolean> deleteCabinetInfo(@RequestBody CabinetReq req) {
return ApiRes.success(cabinetService.deleteCabinetInfo(req)); return ApiRes.success(cabinetService.deleteCabinetInfo(req));
} }
@PostMapping("/ShowCabinetList") @PostMapping("/ShowCabinetList")
@ApiOperation("查询单警柜列表") @ApiOperation("查询单警柜列表(新)")
public ApiRes<List<Cabinet>> showCabinetList(@RequestBody CabinetReq req,@RequestBody String includeLowerLevel){ public ApiRes<List<Cabinet>> showCabinetList(@RequestBody CabinetReq req){
List<Cabinet> allCabinetList = cabinetService.getAllCabinetList(req, includeLowerLevel); List<Cabinet> allCabinetList = cabinetService.getAllCabinetList(req);
if (allCabinetList.size()<=0){ if (allCabinetList.size()<=0){
return ApiRes.failure("查询失败,列表为null"); return ApiRes.failure("查询失败,列表为null");
} }
return ApiRes.success(cabinetService.getAllCabinetList(req,includeLowerLevel)); return ApiRes.success(allCabinetList);
} }
//通过单警柜id查询单个箱门及其箱门信息 //通过单警柜id查询单个箱门及其箱门信息
@PostMapping("/ShowOneCabinet") @PostMapping("/ShowOneCabinet")
@ApiOperation("查询单个单警柜及其箱门信息") @ApiOperation("查询单个单警柜及其箱门信息(新)")
public ApiRes<Cabinet> showOneCabinet(@RequestBody CabinetReq req){ public ApiRes<CabinetDto> showOneCabinet(@RequestBody CabinetReq req){
return ApiRes.success(cabinetService.showOneCabinet(req)); return ApiRes.success(cabinetService.showOneCabinet(req));
} }
@PostMapping("/getCabinetBoxList") @PostMapping("/getCabinetBoxList")
@ApiOperation("通过单警柜id获取箱门列表") @ApiOperation("通过单警柜id获取箱门列表(新)")
public ApiRes<List<CabinetBox>> getCabinetBoxList(@RequestBody CabinetReq req){ public ApiRes<List<CabinetBox>> getCabinetBoxList(@RequestBody CabinetReq req){
return ApiRes.success(cabinetBoxService.getCabinetBoxList(req)); return ApiRes.success(cabinetBoxService.getCabinetBoxList(req));
} }
@PostMapping("/UpdateCabinetInfo") @PostMapping("/UpdateCabinetInfo")
@ApiOperation("修改单警柜信息") @ApiOperation("修改单警柜信息(新)")
public ApiRes<Boolean> updateCabinetInfo(@RequestBody CabinetReq req) { public ApiRes<Boolean> updateCabinetInfo(@RequestBody CabinetReq req) {
boolean result = cabinetService.updateCabinetInfo(req); boolean result = cabinetService.updateCabinetInfo(req);
if (!result){ if (!result){
...@@ -138,9 +141,9 @@ public class CabinetController { ...@@ -138,9 +141,9 @@ public class CabinetController {
} }
@PostMapping("/boxBindPolice") @PostMapping("/boxBindPolice")
@ApiOperation("箱门绑定人员") @ApiOperation("箱门绑定人员(新)")
public ApiRes<Boolean> boxBindPolice(@RequestBody CabinetBoxReq req,@RequestBody String policeId) { public ApiRes<Boolean> boxBindPolice(@RequestBody CabinetBoxReq req) {
boolean result = cabinetService.boxBindPolice(req,policeId); boolean result = cabinetService.boxBindPolice(req);
if (!result){ if (!result){
return ApiRes.failure("操作失败"); return ApiRes.failure("操作失败");
} }
......
...@@ -124,7 +124,6 @@ public class Cabinet implements Serializable { ...@@ -124,7 +124,6 @@ public class Cabinet implements Serializable {
@ApiModelProperty(value = "箱数") @ApiModelProperty(value = "箱数")
private Integer num; private Integer num;
private List<CabinetBox> list;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ public class Policeman implements Serializable { ...@@ -28,7 +28,7 @@ public class Policeman implements Serializable {
@TableField(value = "name") @TableField(value = "name")
private String name; private String name;
@TableField(value = "cabinet_box_id") @TableField(value = "cabinet_box_id",updateStrategy = FieldStrategy.IGNORED)
private String cabinetBoxId; private String cabinetBoxId;
@TableField(value = "org_id_int") @TableField(value = "org_id_int")
......
package com.junmp.jyzb.mapper; package com.junmp.jyzb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.junmp.jyzb.Dto.CabinetDto;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -14,6 +15,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> { ...@@ -14,6 +15,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
public int addCabinet(Cabinet cabinet); public int addCabinet(Cabinet cabinet);
public List<Cabinet> getAllCabinet(); public List<Cabinet> getAllCabinet();
public List<Cabinet> getAllCabinetList(); public List<Cabinet> getAllCabinetList();
Map<String, Object> getOneCabinet(String id); Map<String, Object> getOneCabinet(String id);
...@@ -35,6 +37,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> { ...@@ -35,6 +37,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
String getCabinetNumById(String id); String getCabinetNumById(String id);
List<Cabinet> getAllCabinetByOrgList(List<String> allOrgId); List<Cabinet> getAllCabinetByOrgList(List<String> allOrgId);
List<CabinetDto> getAllCabinetByOrgList111(List<String> allOrgId);
void setCabinetSumInventory(@Param("updateId") String id); void setCabinetSumInventory(@Param("updateId") String id);
......
package com.junmp.jyzb.service; package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.Dto.CabinetDto;
import com.junmp.jyzb.api.bean.req.CabinetBoxReq; import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq; import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
...@@ -50,7 +51,8 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -50,7 +51,8 @@ public interface CabinetService extends IService<Cabinet> {
* @param req * @param req
* @return * @return
*/ */
List<Cabinet> getAllCabinetList(CabinetReq req, String includeLowerLevel); List<Cabinet> getAllCabinetList(CabinetReq req);
/** /**
...@@ -58,7 +60,7 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -58,7 +60,7 @@ public interface CabinetService extends IService<Cabinet> {
* @param req * @param req
* @return * @return
*/ */
Cabinet showOneCabinet(CabinetReq req); CabinetDto showOneCabinet(CabinetReq req);
/** /**
* 修改单警柜信息 * 修改单警柜信息
...@@ -72,7 +74,7 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -72,7 +74,7 @@ public interface CabinetService extends IService<Cabinet> {
* @param req * @param req
* @return * @return
*/ */
boolean boxBindPolice(CabinetBoxReq req,String policeId); boolean boxBindPolice(CabinetBoxReq req);
/** /**
* 根据组织机构获取单警柜及箱号信息 * 根据组织机构获取单警柜及箱号信息
......
...@@ -3,6 +3,7 @@ package com.junmp.jyzb.service.impl; ...@@ -3,6 +3,7 @@ package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.Dto.CabinetDto;
import com.junmp.jyzb.api.bean.req.CabinetBoxReq; import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq; import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
...@@ -17,10 +18,8 @@ import com.junmp.jyzb.service.CabinetService; ...@@ -17,10 +18,8 @@ import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.service.PolicemanService; import com.junmp.jyzb.service.PolicemanService;
import com.junmp.jyzb.service.PubOrgService; import com.junmp.jyzb.service.PubOrgService;
import com.junmp.jyzb.utils.*; import com.junmp.jyzb.utils.*;
import com.junmp.v2.common.constant.CommonConstant;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -342,6 +341,11 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -342,6 +341,11 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId); allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId);
return allCabinet; return allCabinet;
} }
private List<CabinetDto> getAllCabinetByOrg111( List<String> allOrgId) {
List<CabinetDto> allCabinet = new ArrayList<>();
allCabinet = cabinetMapper.getAllCabinetByOrgList111(allOrgId);
return allCabinet;
}
@Override @Override
public List<String> getAllCabinetId(Map<String, Object> msg) { public List<String> getAllCabinetId(Map<String, Object> msg) {
...@@ -489,6 +493,13 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -489,6 +493,13 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
.eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId()); .eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId());
List<CabinetBox> list = cabinetBoxService.list(eq); List<CabinetBox> list = cabinetBoxService.list(eq);
for (CabinetBox cabinetBox: list) { for (CabinetBox cabinetBox: list) {
//删除箱门信息的同时需要去判断箱门是否绑定警员,如果有,则解除绑定
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(cabinetBox.getId()),Policeman::getCabinetBoxId,cabinetBox.getId()));
if (!ObjectUtil.isNull(one)){
one.setCabinetBoxId(null);
policemanService.updateById(one);
}
cabinetBoxService.removeById(cabinetBox.getId()); cabinetBoxService.removeById(cabinetBox.getId());
} }
//删除单警柜id //删除单警柜id
...@@ -499,20 +510,20 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -499,20 +510,20 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
* 获取单警柜列表 * 获取单警柜列表
*通过机构id进行查询 *通过机构id进行查询
* @param req 单警柜信息 * @param req 单警柜信息
* @param includeLowerLevel true:查询本级及下级 false:查询本级 * @param req getIncludeLowerLevel true:查询本级及下级 false:查询本级
* @return * @return
*/ */
@Override @Override
public List<Cabinet> getAllCabinetList(CabinetReq req, String includeLowerLevel) { public List<Cabinet> getAllCabinetList(CabinetReq req) {
List<Cabinet> cabinets = new ArrayList<>(); List<Cabinet> cabinets = new ArrayList<>();
//如果组织机构时浙江省公安厅 //如果组织机构时浙江省公安厅
if (req.getOrgId().equals("1369509498032808905") && includeLowerLevel.equals("true")) { if (req.getOrgId().equals("1369509498032808905") && req.getIncludeLowerLevel().equals("true")) {
cabinets = cabinetMapper.getAllCabinet(); cabinets = cabinetMapper.getAllCabinet();
return cabinets; return cabinets;
} }
//分两种情况,如果说是本级及下级(全部)所有的单警柜信息,则incluLowerLevel为true,如果是查询本级的单警柜信息则为false //分两种情况,如果说是本级及下级(全部)所有的单警柜信息,则incluLowerLevel为true,如果是查询本级的单警柜信息则为false
if (includeLowerLevel.equals("true") || includeLowerLevel.equals("false")) { if (req.getIncludeLowerLevel().equals("true") || req.getIncludeLowerLevel().equals("false")) {
List<String> allOrgId = getAllOrgId(req, includeLowerLevel); List<String> allOrgId = getAllOrgId(req, req.getIncludeLowerLevel());
if (allOrgId.isEmpty()) { if (allOrgId.isEmpty()) {
//抛出组织机构不存在异常 //抛出组织机构不存在异常
throw new ServiceException(CabinetExceptionEnum.PUBORG_NOT_EXIST); throw new ServiceException(CabinetExceptionEnum.PUBORG_NOT_EXIST);
...@@ -525,24 +536,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -525,24 +536,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
} }
} }
/** /**
* 通过单警柜id查询单个单警柜及其箱门信息 * 通过单警柜id查询单个单警柜及其箱门信息
* @param req * @param req
* @return * @return
*/ */
@Override @Override
public Cabinet showOneCabinet(CabinetReq req) { public CabinetDto showOneCabinet(CabinetReq req) {
//查询单警柜信息
LambdaQueryWrapper<Cabinet> eq = CabinetWrapper(req) LambdaQueryWrapper<Cabinet> eq = CabinetWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId()); .eq(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId());
Cabinet one = getOne(eq); Cabinet one = getOne(eq);
if (ObjectUtil.isNull(one)){ if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
} }
//查询单警柜的箱门信息
LambdaQueryWrapper<CabinetBox> eq1 = CabinetboxWrapper(req) LambdaQueryWrapper<CabinetBox> eq1 = CabinetboxWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), CabinetBox::getCabinetId, req.getOrgId()); .eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId());
List<CabinetBox> list = cabinetBoxService.list(eq1); List<CabinetBox> list = cabinetBoxService.list(eq1);
one.setList(list); //将单警柜的信息和它的箱门信息返回
return one; CabinetDto cabinetDto = new CabinetDto();
BeanPlusUtil.copyProperties(one,cabinetDto);
cabinetDto.setList(list);
return cabinetDto;
} }
/** /**
...@@ -601,7 +618,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -601,7 +618,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
* @return * @return
*/ */
@Override @Override
public boolean boxBindPolice(CabinetBoxReq req,String policeId) { public boolean boxBindPolice(CabinetBoxReq req) {
//通过箱门id查询出箱门信息 //通过箱门id查询出箱门信息
CabinetBox one = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>() CabinetBox one = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getId, req.getId())); .eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getId, req.getId()));
...@@ -621,18 +638,18 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -621,18 +638,18 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
long orgId = one1.getOrgId(); long orgId = one1.getOrgId();
//通过警员id获取警员所在的机构id //通过警员id获取警员所在的机构id
Policeman one2 = policemanService.getOne(new LambdaQueryWrapper<Policeman>() Policeman one2 = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(policeId), Policeman::getId, policeId)); .eq(ObjectUtil.isNotEmpty(req.getPoliceId()), Policeman::getId, req.getPoliceId()));
if (ObjectUtil.isEmpty(one2)){ if (ObjectUtil.isEmpty(one2)){
//警员不存在异常 //警员不存在异常
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST); throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
} }
Long orgId1 = one2.getOrgId(); Long orgId1 = one2.getOrgId();
//判断两个机构id是否相同,相同则可以绑定,不相同则绑定失败 //判断两个机构id是否相同,相同则可以绑定,不相同则绑定失败
if (!orgId1.equals(orgId)){ if (!(orgId1==orgId)){
return false; return false;
} }
one2.setCabinetBoxId(one.getId()); one2.setCabinetBoxId(one.getId());
return policemanService.save(one2); return policemanService.updateById(one2);
} }
@Override @Override
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
<result property="createUser" column="create_user" /> <result property="createUser" column="create_user" />
<result property="updateUser" column="update_user" /> <result property="updateUser" column="update_user" />
<collection property="list" ofType="com.junmp.jyzb.entity.CabinetBox" column="cabinet_id" <!-- <collection property="list" ofType="com.junmp.jyzb.entity.CabinetBox" column="cabinet_id"-->
select="com.junmp.jyzb.mapper.CabinetBoxMapper.selectById"> <!-- select="com.junmp.jyzb.mapper.CabinetBoxMapper.selectById">-->
</collection> <!-- </collection>-->
</resultMap> </resultMap>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
where p.id =#{id} where p.id =#{id}
</update> </update>
<select id="getAllCabinet" resultType="com.junmp.jyzb.entity.Cabinet"> <select id="getAllCabinet" resultMap="BaseCabinetResultMap" >
select select
c.id, c.id,
c.cabinet_num as cabinetNum, c.cabinet_num as cabinetNum,
...@@ -155,6 +155,27 @@ ...@@ -155,6 +155,27 @@
#{item} #{item}
</foreach> </foreach>
</select> </select>
<select id="getAllCabinetByOrgList111" resultType="com.junmp.jyzb.Dto.CabinetDto">
select
c.id,
c.cabinet_num as cabinetNum,
c.name,
o.org_id as orgId,
o.org_name as orgName,
c.location,
c.state,
c.update_time as updateTime,
c.sum as sum,
c.in_sum as inSum,
c.out_sum as outSum
from base_cabinet c
left join pub_org o on c.org_id_int =o.org_id
where c.org_id_int in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="setCabinetSumInventory"> <update id="setCabinetSumInventory">
UPDATE base_cabinet AS c UPDATE base_cabinet AS c
......
...@@ -5,7 +5,7 @@ package com.junmp.junmpProcess.common; ...@@ -5,7 +5,7 @@ package com.junmp.junmpProcess.common;
* @create 2022-10-10 17:40 * @create 2022-10-10 17:40
*/ */
public interface WorkFlowConstants { public interface WorkFlowConstants {
String PROCESS_PREFIX = "Flowable"; String PROCESS_PREFIX = "Process_";
String START_EVENT_ID = "startEventNode"; String START_EVENT_ID = "startEventNode";
String END_EVENT_ID = "endEventNode"; String END_EVENT_ID = "endEventNode";
String EXPRESSION_CLASS = "exUtils."; String EXPRESSION_CLASS = "exUtils.";
......
...@@ -121,11 +121,11 @@ public class BpmnController { ...@@ -121,11 +121,11 @@ public class BpmnController {
public ApiRes<Boolean> createForm(@RequestBody FormReq formReq) { public ApiRes<Boolean> createForm(@RequestBody FormReq formReq) {
return ApiRes.success(WorkProcessService.createNewForm(formReq)); return ApiRes.success(WorkProcessService.createNewForm(formReq));
} }
// @ApiOperation("终止流程") @ApiOperation("终止流程")
// @PostMapping("StopProcessInstanceById") @PostMapping("StopProcessInstanceById")
// public ApiRes<Boolean> stopProcessInstanceById(@RequestBody HandleDataDTO handleDataDTO) { public ApiRes<Boolean> stopProcessInstanceById(@RequestBody HandleDataDTO handleDataDTO) {
// return ApiRes.success(WorkProcessService.suspendOrActivateProcessDefinitionById(req)); return WorkProcessService.stopProcessInstanceById(handleDataDTO);
// } }
@ApiOperation("挂起流程实例") @ApiOperation("挂起流程实例")
@PostMapping("SuspendOrActivateDefinition") @PostMapping("SuspendOrActivateDefinition")
public ApiRes<Boolean> SuspendOrActivateDefinition(@RequestBody SuspendOrActivateDefinitionReq req) { public ApiRes<Boolean> SuspendOrActivateDefinition(@RequestBody SuspendOrActivateDefinitionReq req) {
...@@ -136,6 +136,11 @@ public class BpmnController { ...@@ -136,6 +136,11 @@ public class BpmnController {
public ApiRes<Boolean> start(@RequestBody StartProcessInstanceDTO startProcessInstanceDTO) { public ApiRes<Boolean> start(@RequestBody StartProcessInstanceDTO startProcessInstanceDTO) {
return WorkProcessService.start(startProcessInstanceDTO); return WorkProcessService.start(startProcessInstanceDTO);
} }
@ApiOperation("通过流程定义查看详情")
@PostMapping("instanceInfo")
public ApiRes<HandleDataVO> instanceInfo(@RequestBody HandleDataDTO handleDataDTO) {
return WorkProcessService.instanceInfo(handleDataDTO);
}
@ApiOperation("查看我发起的流程") @ApiOperation("查看我发起的流程")
@PostMapping("applyList") @PostMapping("applyList")
public ApiRes<PageResult<HistoryProcessInstanceVO>> applyList(@RequestBody ApplyDTO ApplyDTO) { public ApiRes<PageResult<HistoryProcessInstanceVO>> applyList(@RequestBody ApplyDTO ApplyDTO) {
...@@ -151,6 +156,11 @@ public class BpmnController { ...@@ -151,6 +156,11 @@ public class BpmnController {
public ResponseResult agree(@RequestBody HandleDataDTO handleDataDTO){ public ResponseResult agree(@RequestBody HandleDataDTO handleDataDTO){
return WorkProcessService.agree(handleDataDTO); return WorkProcessService.agree(handleDataDTO);
} }
@ApiOperation("查看我的已办")
@PostMapping("doneList")
public ApiRes<PageResult<TaskVO>> doneList(@RequestBody TaskDTO taskDTO){
return ApiRes.success(WorkProcessService.doneList(taskDTO));
}
@ApiOperation("撤销按钮") @ApiOperation("撤销按钮")
@PostMapping("revoke") @PostMapping("revoke")
public ResponseResult revoke(@RequestBody HandleDataDTO handleDataDTO){ public ResponseResult revoke(@RequestBody HandleDataDTO handleDataDTO){
......
...@@ -17,6 +17,7 @@ import com.junmp.v2.sys.api.bean.user.vo.QueryUserInfoVo; ...@@ -17,6 +17,7 @@ import com.junmp.v2.sys.api.bean.user.vo.QueryUserInfoVo;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener; import org.flowable.engine.delegate.ExecutionListener;
import com.junmp.junmpProcess.enums.AssigneeTypeEnums; import com.junmp.junmpProcess.enums.AssigneeTypeEnums;
...@@ -38,12 +39,15 @@ import static com.junmp.junmpProcess.utils.BpmnModelUtils.getChildNode; ...@@ -38,12 +39,15 @@ import static com.junmp.junmpProcess.utils.BpmnModelUtils.getChildNode;
@Component @Component
public class CounterSignListener implements ExecutionListener { public class CounterSignListener implements ExecutionListener {
@Resource @Resource
private TaskService taskService;
@Resource
private RepositoryService repositoryService; private RepositoryService repositoryService;
@Resource @Resource
private OrgUserMapper orgUserMapper; private OrgUserMapper orgUserMapper;
@Override @Override
public void notify(DelegateExecution execution) { public void notify(DelegateExecution execution) {
String currentActivityId = execution.getCurrentActivityId(); String currentActivityId = execution.getCurrentActivityId();
Process mainProcess = repositoryService.getBpmnModel(execution.getProcessDefinitionId()).getMainProcess(); Process mainProcess = repositoryService.getBpmnModel(execution.getProcessDefinitionId()).getMainProcess();
UserTask userTask = (UserTask) mainProcess.getFlowElement(currentActivityId); UserTask userTask = (UserTask) mainProcess.getFlowElement(currentActivityId);
String flowJson = mainProcess.getAttributeValue("http://flowable.org/bpmn", "Junmp"); String flowJson = mainProcess.getAttributeValue("http://flowable.org/bpmn", "Junmp");
...@@ -65,6 +69,7 @@ public class CounterSignListener implements ExecutionListener { ...@@ -65,6 +69,7 @@ public class CounterSignListener implements ExecutionListener {
String Type=group.getApproverType(); String Type=group.getApproverType();
if (Type.equals("1"))//指定人员,不处理 if (Type.equals("1"))//指定人员,不处理
{ {
List<String> assignedUser = group.getApproverIds(); List<String> assignedUser = group.getApproverIds();
for (String userInfo : assignedUser) { for (String userInfo : assignedUser) {
assigneeList.add(userInfo); assigneeList.add(userInfo);
...@@ -136,7 +141,7 @@ public class CounterSignListener implements ExecutionListener { ...@@ -136,7 +141,7 @@ public class CounterSignListener implements ExecutionListener {
else if (Type.equals("5"))//上级审批 else if (Type.equals("5"))//上级审批
{ {
LoginUser StartUser= LoginContext.getContext().getLoginUser(); LoginUser StartUser= LoginContext.getContext().getLoginUser();
List<UserListDTO> userList= orgUserMapper.QueryUserParentOrg(StartUser.getUserId().toString()); List<UserListDTO> userList= orgUserMapper.QueryUserWithParentOrg(StartUser.getUserId().toString());
if (userList.size()<=0)//没有上级则本身已是上级 if (userList.size()<=0)//没有上级则本身已是上级
{ {
...@@ -147,14 +152,18 @@ public class CounterSignListener implements ExecutionListener { ...@@ -147,14 +152,18 @@ public class CounterSignListener implements ExecutionListener {
{ {
for (UserListDTO userId :userList) for (UserListDTO userId :userList)
{ {
assigneeList.add(userId.getUserID()); assigneeList.add("1");
// assigneeList.add(userId.getUserID());
} }
} }
} }
if (assigneeList.size()!=0) if (assigneeList.size()!=0)
{execution.setVariable(variable, assigneeList);} {
execution.setVariable(variable, assigneeList);
}
} else { } else {
} }
......
...@@ -32,6 +32,7 @@ public class GlobalEndListener extends AbstractFlowableEngineEventListener { ...@@ -32,6 +32,7 @@ public class GlobalEndListener extends AbstractFlowableEngineEventListener {
//流程结束后工作在这里写 //流程结束后工作在这里写
//得到流程定义id //得到流程定义id
String processDefinitionId = event.getProcessDefinitionId(); String processDefinitionId = event.getProcessDefinitionId();
//得到流程实例id //得到流程实例id
String processInstanceId = event.getProcessInstanceId(); String processInstanceId = event.getProcessInstanceId();
/** /**
......
...@@ -21,6 +21,7 @@ public class ProcessListener implements ExecutionListener { ...@@ -21,6 +21,7 @@ public class ProcessListener implements ExecutionListener {
@Override @Override
public void notify(DelegateExecution execution) { public void notify(DelegateExecution execution) {
execution.setVariable(PROCESS_STATUS, BUSINESS_STATUS_4); execution.setVariable(PROCESS_STATUS, BUSINESS_STATUS_4);
} }
} }
//package com.junmp.junmpProcess.listener; package com.junmp.junmpProcess.listener;
//
//import org.flowable.engine.RepositoryService; import org.flowable.engine.RepositoryService;
//import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
//import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
//import org.flowable.engine.delegate.TaskListener; import org.flowable.engine.delegate.TaskListener;
//import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
//import com.junmp.junmpProcess.utils.SpringContextHolder; import com.junmp.junmpProcess.utils.SpringContextHolder;
//import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource; import javax.annotation.Resource;
//
///** /**
// * @author LoveMyOrange * @author LoveMyOrange
// * @create 2022-10-15 14:51 * @create 2022-10-15 14:51
// */ */
//@Component @Component
//public class TaskCreatedListener implements TaskListener { public class TaskCreatedListener implements TaskListener {
// @Resource @Resource
// private TaskService taskService; private TaskService taskService;
// @Resource @Resource
// private RepositoryService repositoryService; private RepositoryService repositoryService;
//
// @Override @Override
// public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
// String taskDefinitionKey = delegateTask.getTaskDefinitionKey(); String taskDefinitionKey = delegateTask.getTaskDefinitionKey();
// if ("root".equalsIgnoreCase(taskDefinitionKey)) { if ("root".equalsIgnoreCase(taskDefinitionKey)) {
// taskService.complete(delegateTask.getId()); taskService.complete(delegateTask.getId());
// } else { } else {
// if ("100000".equals(delegateTask.getAssignee())) { if ("100000".equals(delegateTask.getAssignee())) {
// Object autoRefuse = delegateTask.getVariable("autoRefuse"); Object autoRefuse = delegateTask.getVariable("autoRefuse");
// if (autoRefuse == null) { if (autoRefuse == null) {
// taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "opinion", "审批人为空,自动通过"); taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "opinion", "审批人为空,自动通过");
// taskService.complete(delegateTask.getId()); taskService.complete(delegateTask.getId());
// } else { } else {
// taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "opinion", "审批人为空,自动驳回"); taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "opinion", "审批人为空,自动驳回");
// RuntimeService runtimeService = SpringContextHolder.getBean(RuntimeService.class); RuntimeService runtimeService = SpringContextHolder.getBean(RuntimeService.class);
// runtimeService.deleteProcessInstance(delegateTask.getProcessInstanceId(), "审批人为空,自动驳回"); runtimeService.deleteProcessInstance(delegateTask.getProcessInstanceId(), "审批人为空,自动驳回");
// } }
// } }
// } }
// } }
//} }
...@@ -23,5 +23,5 @@ public interface OrgUserMapper { ...@@ -23,5 +23,5 @@ public interface OrgUserMapper {
*/ */
public List<UserListDTO> QueryUserByRoleIdAndOrg(String roleId,String orgId); public List<UserListDTO> QueryUserByRoleIdAndOrg(String roleId,String orgId);
public List<UserListDTO> QueryUserParentOrg(String userId); public List<UserListDTO> QueryUserWithParentOrg(String userId);
} }
...@@ -29,12 +29,12 @@ public interface WorkProcessService { ...@@ -29,12 +29,12 @@ public interface WorkProcessService {
*/ */
Boolean createNewForm(FormReq processVO) ; Boolean createNewForm(FormReq processVO) ;
// /** /**
// * 挂起流程定义 * 终止流程实例
// * *
// * @return * @return
// */ */
// Boolean stopProcessInstanceById(SuspendOrActivateDefinitionReq req) ; ApiRes<Boolean> stopProcessInstanceById(HandleDataDTO handleDataDTO) ;
/** /**
* 挂起流程定义 * 挂起流程定义
...@@ -101,6 +101,9 @@ public interface WorkProcessService { ...@@ -101,6 +101,9 @@ public interface WorkProcessService {
*/ */
ApiRes<Boolean> start(StartProcessInstanceDTO startProcessInstanceDTO); ApiRes<Boolean> start(StartProcessInstanceDTO startProcessInstanceDTO);
/** /**
* 查看我发起的流程 * 查看我发起的流程
* *
...@@ -120,7 +123,7 @@ public interface WorkProcessService { ...@@ -120,7 +123,7 @@ public interface WorkProcessService {
* *
* @return * @return
*/ */
Result<Page<TaskVO>> doneList(@RequestBody TaskDTO taskDTO); PageResult<TaskVO> doneList(@RequestBody TaskDTO taskDTO);
/** /**
* 同意 * 同意
...@@ -205,7 +208,7 @@ public interface WorkProcessService { ...@@ -205,7 +208,7 @@ public interface WorkProcessService {
* *
* @return * @return
*/ */
Result<HandleDataVO> instanceInfo(HandleDataDTO HandleDataDTO); ApiRes<HandleDataVO> instanceInfo(HandleDataDTO HandleDataDTO);
// /** // /**
// * 上传文件 // * 上传文件
// * @return // * @return
......
...@@ -212,6 +212,46 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -212,6 +212,46 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
return pageResult; return pageResult;
} }
public List<EndEvent> findEndFlowElement(String processDefId) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefId);
if (bpmnModel != null) {
Process process = bpmnModel.getMainProcess();
return process.findFlowElementsOfType(EndEvent.class);
} else {
return null;
}
}
// /**
// * @Author: Zhaojw
// * @Description: 终止流程实例
// * @DateTime: 2023/7/24 15:17
// * @Params:
// * @Return
// */
public ApiRes<Boolean> stopProcessInstanceById(HandleDataDTO handleDataDTO)
{
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(handleDataDTO.getProcessInstanceId()).singleResult();
if (processInstance != null) {
//2、执行终止
List<Execution> executions = runtimeService.createExecutionQuery().parentId(handleDataDTO.getProcessInstanceId()).list();
List<String> executionIds = new ArrayList<>();
List<EndEvent> endNodes = this.findEndFlowElement(processInstance.getProcessDefinitionId());
String endId = endNodes.get(0).getId();
executions.forEach(execution -> executionIds.add(execution.getId()));
runtimeService.createChangeActivityStateBuilder()
.moveExecutionsToSingleActivityId(executionIds, endId)
.changeState();
return ApiRes.success(true);
}else {
return ApiRes.failure("不存在运行的流程实例,请确认!");
}
}
/** /**
* @Author: Zhaojw * @Author: Zhaojw
* @Description: 创建新表单 * @Description: 创建新表单
...@@ -241,7 +281,6 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -241,7 +281,6 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
if (req.getIsStop() == true){ if (req.getIsStop() == true){
repositoryService.suspendProcessDefinitionById(req.getProcessDefinitionId(), true, null); repositoryService.suspendProcessDefinitionById(req.getProcessDefinitionId(), true, null);
processTemplates.setIsStop(true); processTemplates.setIsStop(true);
}else { }else {
processTemplates.setIsStop(false); processTemplates.setIsStop(false);
repositoryService.activateProcessDefinitionById(req.getProcessDefinitionId(), true, null); repositoryService.activateProcessDefinitionById(req.getProcessDefinitionId(), true, null);
...@@ -274,8 +313,8 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -274,8 +313,8 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
BpmnModel bpmnModel = toBpmn(processJsonNode,formJsonNode,formName,templateId); BpmnModel bpmnModel = toBpmn(processJsonNode,formJsonNode,formName,templateId);
Deployment deploy = repositoryService.createDeployment() Deployment deploy = repositoryService.createDeployment()
.addBpmnModel(templateId+".bpmn20.xml", bpmnModel) .addBpmnModel(formName+".bpmn20.xml", bpmnModel)
.name(templateId) .name(formName)
.category(templateId) .category(templateId)
.deploy(); .deploy();
...@@ -376,8 +415,8 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -376,8 +415,8 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
Deployment deploy = repositoryService.createDeployment() Deployment deploy = repositoryService.createDeployment()
.addBpmnModel(process.getTemplateId()+".bpmn20.xml", bpmnModel) .addBpmnModel(formName+".bpmn20.xml", bpmnModel)
.name(process.getTemplateId()) .name(formName)
.category(process.getTemplateId()) .category(process.getTemplateId())
.deploy(); .deploy();
return true; return true;
...@@ -554,11 +593,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -554,11 +593,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
userTask.setId(id); userTask.setId(id);
userTask.setName(node.get("name").toString()); userTask.setName(node.get("name").toString());
// 设置多实例 // 设置多实例
// userTask.setAssignee("${user}");
MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics(); MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
// if (node.getAssignee().getMultiMode().equals("顺序审批")) {
// multiInstanceLoopCharacteristics.setSequential(true);
// }
multiInstanceLoopCharacteristics.setElementVariable("user"); multiInstanceLoopCharacteristics.setElementVariable("user");
// 完成条件 // 完成条件
multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfInstances == nrOfCompletedInstances}"); multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfInstances == nrOfCompletedInstances}");
...@@ -639,15 +674,11 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -639,15 +674,11 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
processVariables.put(FORM_VAR,formData); processVariables.put(FORM_VAR,formData);
processVariables.put(START_USER_INFO,JSONObject.toJSONString(StartUser)); processVariables.put(START_USER_INFO,JSONObject.toJSONString(StartUser));
processVariables.put(PROCESS_STATUS,BUSINESS_STATUS_1); processVariables.put(PROCESS_STATUS,BUSINESS_STATUS_1);
// processVariables.put("initiator",JSONObject.toJSONString(startUserInfo)); // processVariables.put("initiator",JSONObject.toJSONString(startUserInfo));
ArrayList<LoginUser> userInfos = CollUtil.newArrayList(StartUser); ArrayList<LoginUser> userInfos = CollUtil.newArrayList(StartUser);
Map formValue = JSONObject.parseObject(formData.toJSONString(), new TypeReference<Map>() { Map formValue = JSONObject.parseObject(formData.toJSONString(), new TypeReference<Map>() {
}); });
processVariables.putAll(formValue); processVariables.putAll(formValue);
ProcessInstanceBuilder processInstanceBuilder = runtimeService.createProcessInstanceBuilder(); ProcessInstanceBuilder processInstanceBuilder = runtimeService.createProcessInstanceBuilder();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processInstanceDto.getProcessDefinitionId()) ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processInstanceDto.getProcessDefinitionId())
.latestVersion().singleResult(); .latestVersion().singleResult();
...@@ -667,12 +698,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -667,12 +698,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
.businessStatus(BUSINESS_STATUS_1) .businessStatus(BUSINESS_STATUS_1)
.start(); .start();
//手动完成第一个任务 //手动完成第一个任务
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); // Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
Object ts=new Object(); // Object ts=new Object();
if(task!=null){ // if(task!=null){
taskService.complete(task.getId()); // taskService.complete(task.getId());
//
} // }
return ApiRes.success(true); return ApiRes.success(true);
} }
catch (Exception e){ catch (Exception e){
...@@ -711,6 +742,11 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -711,6 +742,11 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
Map<String, Object> processVariables = historicProcessInstance.getProcessVariables(); Map<String, Object> processVariables = historicProcessInstance.getProcessVariables();
HistoryProcessInstanceVO historyProcessInstanceVO = new HistoryProcessInstanceVO(); HistoryProcessInstanceVO historyProcessInstanceVO = new HistoryProcessInstanceVO();
historyProcessInstanceVO.setProcessInstanceId(historicProcessInstance.getId()); historyProcessInstanceVO.setProcessInstanceId(historicProcessInstance.getId());
BpmnModel bpmnModel = repositoryService.getBpmnModel(historicProcessInstance.getProcessDefinitionId());
String Name= bpmnModel.getMainProcess().getName();
historyProcessInstanceVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName()); historyProcessInstanceVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName());
historyProcessInstanceVO.setStartUser(JSONObject.parseObject(MapUtil.getStr(processVariables, START_USER_INFO), new TypeReference<UserInfo>() { historyProcessInstanceVO.setStartUser(JSONObject.parseObject(MapUtil.getStr(processVariables, START_USER_INFO), new TypeReference<UserInfo>() {
})); }));
...@@ -792,7 +828,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -792,7 +828,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
* @return * @return
*/ */
@Override @Override
public Result<Page<TaskVO>> doneList(TaskDTO taskDTO) { public PageResult<TaskVO> doneList(TaskDTO taskDTO) {
LoginUser StartUser= LoginContext.getContext().getLoginUser(); LoginUser StartUser= LoginContext.getContext().getLoginUser();
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery() List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
.taskAssignee(StartUser.getUserId().toString()) .taskAssignee(StartUser.getUserId().toString())
...@@ -837,7 +873,9 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -837,7 +873,9 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
page.setCurrent(taskDTO.getPageNo()); page.setCurrent(taskDTO.getPageNo());
page.setSize(taskDTO.getPageSize()); page.setSize(taskDTO.getPageSize());
page.setTotal(count); page.setTotal(count);
return Result.OK(page);
return PageResultFactory.createPageResult(page);
} }
...@@ -907,9 +945,9 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -907,9 +945,9 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
} }
} }
if (StringUtils.isNotBlank(handleDataDTO.getSignInfo())) { // if (StringUtils.isNotBlank(handleDataDTO.getSignInfo())) {
taskService.addComment(task.getId(), task.getProcessInstanceId(), "sign", handleDataDTO.getSignInfo()); // taskService.addComment(task.getId(), task.getProcessInstanceId(), "sign", handleDataDTO.getSignInfo());
} // }
taskService.complete(task.getId()); taskService.complete(task.getId());
...@@ -1237,11 +1275,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -1237,11 +1275,12 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
} }
@Override @Override
public Result<HandleDataVO> instanceInfo(HandleDataDTO HandleDataDTO) { public ApiRes<HandleDataVO> instanceInfo(HandleDataDTO HandleDataDTO) {
String processInstanceId = HandleDataDTO.getProcessInstanceId(); String processInstanceId = HandleDataDTO.getProcessInstanceId();
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId) HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId)
.includeProcessVariables().singleResult(); .includeProcessVariables().singleResult();
String processDefinitionKey = historicProcessInstance.getProcessDefinitionKey(); String processDefinitionKey = historicProcessInstance.getProcessDefinitionKey();
String pro=processDefinitionKey.replace(PROCESS_PREFIX, "");
ProcessTemplates processTemplates = processTemplateService.getById(processDefinitionKey.replace(PROCESS_PREFIX, "")); ProcessTemplates processTemplates = processTemplateService.getById(processDefinitionKey.replace(PROCESS_PREFIX, ""));
// processTemplates.setLogo(processTemplates.getIcon()); // processTemplates.setLogo(processTemplates.getIcon());
processTemplates.setFormId(processTemplates.getTemplateId()); processTemplates.setFormId(processTemplates.getTemplateId());
...@@ -1259,40 +1298,40 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -1259,40 +1298,40 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
}); });
SettingsInfo settingsInfo = JSONObject.parseObject(processTemplates.getSettings(), new TypeReference<SettingsInfo>() { SettingsInfo settingsInfo = JSONObject.parseObject(processTemplates.getSettings(), new TypeReference<SettingsInfo>() {
}); });
Boolean sign = settingsInfo.getSign(); // Boolean sign = settingsInfo.getSign();
ChildNode currentNode = null; ChildNode currentNode = null;
if (StringUtils.isNotBlank(HandleDataDTO.getTaskId())) { if (StringUtils.isNotBlank(HandleDataDTO.getTaskId())) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(HandleDataDTO.getTaskId()).singleResult(); HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(HandleDataDTO.getTaskId()).singleResult();
currentNode = getChildNode(childNode, historicTaskInstance.getTaskDefinitionKey()); currentNode = getChildNode(childNode, historicTaskInstance.getTaskDefinitionKey());
List<FormOperates> formPerms = currentNode.getProps().getFormPerms(); // List<FormOperates> formPerms = currentNode.getProps().getFormPerms();
if (CollUtil.isNotEmpty(formPerms)) { // if (CollUtil.isNotEmpty(formPerms)) {
Iterator<FormOperates> iterator = formPerms.iterator(); // Iterator<FormOperates> iterator = formPerms.iterator();
while (iterator.hasNext()) { // while (iterator.hasNext()) {
FormOperates next = iterator.next(); // FormOperates next = iterator.next();
if ("H".equals(next.getPerm())) { // if ("H".equals(next.getPerm())) {
iterator.remove(); // iterator.remove();
if (jsonObject != null) { // if (jsonObject != null) {
jsonObject.remove(next.getId()); // jsonObject.remove(next.getId());
} // }
} // }
} // }
} // }
handleDataVO.setCurrentNode(currentNode); handleDataVO.setCurrentNode(currentNode);
handleDataVO.setTaskId(HandleDataDTO.getTaskId()); handleDataVO.setTaskId(HandleDataDTO.getTaskId());
} }
if (sign) { // if (sign) {
handleDataVO.setSignFlag(true); // handleDataVO.setSignFlag(true);
} // }
if (StringUtils.isNotBlank(HandleDataDTO.getTaskId())) { // if (StringUtils.isNotBlank(HandleDataDTO.getTaskId())) {
if (currentNode != null) { // if (currentNode != null) {
if (currentNode.getProps().getSign()) { // if (currentNode.getProps().getSign()) {
handleDataVO.setSignFlag(true); // handleDataVO.setSignFlag(true);
} else { // } else {
handleDataVO.setSignFlag(false); // handleDataVO.setSignFlag(false);
} // }
} // }
} // }
List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.getId()).list(); List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.getId()).list();
Map<String, List<HistoricActivityInstance>> historicActivityInstanceMap = new HashMap<>(); Map<String, List<HistoricActivityInstance>> historicActivityInstanceMap = new HashMap<>();
...@@ -1377,7 +1416,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper, ...@@ -1377,7 +1416,7 @@ public class WorkProcessServiceImpl extends ServiceImpl<ProcessTemplatesMapper,
} }
handleDataVO.setProcessTemplates(processTemplates); handleDataVO.setProcessTemplates(processTemplates);
handleDataVO.setDetailVOList(deatailMap); handleDataVO.setDetailVOList(deatailMap);
return Result.OK(handleDataVO); return ApiRes.success(handleDataVO);
} }
private void collectUserTaskInfo(List<Comment> processInstanceComments, private void collectUserTaskInfo(List<Comment> processInstanceComments,
......
...@@ -11,6 +11,7 @@ import org.flowable.bpmn.model.*; ...@@ -11,6 +11,7 @@ import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.Process;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.ExecutionListener; import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -62,7 +63,7 @@ public class BpmnConvert { ...@@ -62,7 +63,7 @@ public class BpmnConvert {
process.addFlowElement(endEvent); process.addFlowElement(endEvent);
// 三.递归绘制节点 // 三.递归绘制节点
drawNode("root",process, processNode,formNode, "_start", "_end", null); drawNode("0",process, processNode,formNode, "_start", "_end", null);
// 四.自动布局 // 四.自动布局
new BpmnAutoLayout(bpmnModel).execute(); new BpmnAutoLayout(bpmnModel).execute();
// 五.转xml // 五.转xml
...@@ -119,8 +120,9 @@ public class BpmnConvert { ...@@ -119,8 +120,9 @@ public class BpmnConvert {
* @return Inout * @return Inout
*/ */
private static Inout drawBzNode(Process process, JsonNode node,JsonNode formJson,String typeNode) { private static Inout drawBzNode(Process process, JsonNode node,JsonNode formJson,String typeNode) {
// String id= "Node_"+UUID.randomUUID();
String id="Node_"+ node.get("id").asText(); // String id= "Node_"+UUID.randomUUID();
String id="root";
//创建发起人结点 //创建发起人结点
UserTask task = new UserTask(); UserTask task = new UserTask();
//设置结点ID //设置结点ID
...@@ -129,11 +131,23 @@ public class BpmnConvert { ...@@ -129,11 +131,23 @@ public class BpmnConvert {
task.setName(node.get("name").asText()); task.setName(node.get("name").asText());
//通过将 ${initiator} 作为指派人的值,可以将用户任务分配给流程的发起人。当流程实例启动时,${initiator} 会被替换为实际的发起人信息。 //通过将 ${initiator} 作为指派人的值,可以将用户任务分配给流程的发起人。当流程实例启动时,${initiator} 会被替换为实际的发起人信息。
//需要注意的是,在使用表达式时,需要确保流程引擎的配置中启用了表达式语言(例如使用 Flowable 的默认配置,会启用表达式语言)。 //需要注意的是,在使用表达式时,需要确保流程引擎的配置中启用了表达式语言(例如使用 Flowable 的默认配置,会启用表达式语言)。
task.setAssignee("${initiator}"); // task.setAssignee("${initiator}");
List<FormProperty> formProperties = formJsonToFormProperty(formJson); List<FormProperty> formProperties = formJsonToFormProperty(formJson);
task.setFormProperties(formProperties); task.setFormProperties(formProperties);
ArrayList<FlowableListener> taskListeners = new ArrayList<>();
FlowableListener taskListener = new FlowableListener();
// 事件类型,
taskListener.setEvent(TaskListener.EVENTNAME_CREATE);
// 监听器类型
taskListener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
// 设置实现了,这里设置监听器的类型是delegateExpression,这样可以在实现类注入Spring bean.
taskListener.setImplementation("${taskCreatedListener}");
taskListeners.add(taskListener);
task.setTaskListeners(taskListeners);
//添加连线 //添加连线
process.addFlowElement(task); process.addFlowElement(task);
return new Inout(id, id); return new Inout(id, id);
} }
...@@ -175,11 +189,11 @@ public class BpmnConvert { ...@@ -175,11 +189,11 @@ public class BpmnConvert {
multiInstanceLoopCharacteristics.setInputDataItem(userTask.getId()+"assigneeList"); multiInstanceLoopCharacteristics.setInputDataItem(userTask.getId()+"assigneeList");
// 迭代集合 // 迭代集合
multiInstanceLoopCharacteristics.setElementVariable("assigneeName"); multiInstanceLoopCharacteristics.setElementVariable("assigneeName");
// //
multiInstanceLoopCharacteristics.setSequential(false); multiInstanceLoopCharacteristics.setSequential(false);
multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfCompletedInstances/nrOfInstances > 0}"); multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfCompletedInstances/nrOfInstances > 0}");
userTask.setAssignee("${assigneeName}"); userTask.setAssignee("${assigneeName}");
// 设置多实例属性 // 设置多实例属性
userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics); userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);
process.addFlowElement(userTask); process.addFlowElement(userTask);
return new Inout(id, id); return new Inout(id, id);
...@@ -197,7 +211,12 @@ public class BpmnConvert { ...@@ -197,7 +211,12 @@ public class BpmnConvert {
listener.setEvent(ExecutionListener.EVENTNAME_START);//监听任务启动 listener.setEvent(ExecutionListener.EVENTNAME_START);//监听任务启动
listener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); listener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
listener.setImplementation("${counterSignListener}");//启动角色分配监听事件 listener.setImplementation("${counterSignListener}");//启动角色分配监听事件
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation("${processListener}");
taskListeners.add(listener); taskListeners.add(listener);
taskListeners.add(flowableListener);
return taskListeners; return taskListeners;
} }
......
...@@ -200,507 +200,14 @@ public class BpmnModelUtils { ...@@ -200,507 +200,14 @@ public class BpmnModelUtils {
return endEvent; return endEvent;
} }
// public static String FlowCreate(String fromId, FlowChildNode flowNode, Process process, BpmnModel bpmnModel, List<SequenceFlow> sequenceFlows, Map<String,ChildNode> childNodeMap) throws InvocationTargetException, IllegalAccessException {
// Integer nodeType = flowNode.getType();
// if (FlowType.CONCURRENTS.isEqual(nodeType)) {
// return createParallelGatewayBuilder(fromId, flowNode,process,bpmnModel,sequenceFlows,childNodeMap);
// } else if (FlowType.CONDITIONS.isEqual(nodeType)) {
// return createExclusiveGatewayBuilder(fromId, flowNode,process,bpmnModel,sequenceFlows,childNodeMap);
// } else if (FlowType.USER_TASK.isEqual(nodeType)) {
// childNodeMap.put(flowNode.getId(),flowNode);
// JSONObject incoming = flowNode.getIncoming();
// incoming.put("incoming", Collections.singletonList(fromId));
// String id = createTask(process,flowNode,sequenceFlows,childNodeMap);
// // 如果当前任务还有后续任务,则遍历创建后续任务
// ChildNode children = flowNode.getChildren();
// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
// } else {
// return id;
// }
// }
// else if(Type.ROOT.isEqual(nodeType)){
// childNodeMap.put(flowNode.getId(),flowNode);
// JSONObject incoming = flowNode.getIncoming();
// incoming.put("incoming", Collections.singletonList(fromId));
// String id = createTask(process,flowNode,sequenceFlows,childNodeMap);
// // 如果当前任务还有后续任务,则遍历创建后续任务
// ChildNode children = flowNode.getChildren();
// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
// } else {
// return id;
// }
// }
// else if(Type.DELAY.isEqual(nodeType)){
// throw new WorkFlowException("还不想写这个功能");
//// childNodeMap.put(flowNode.getId(),flowNode);
//// JSONObject incoming = flowNode.getIncoming();
//// incoming.put("incoming", Collections.singletonList(fromId));
//// String id = createTask(process,flowNode,sequenceFlows,childNodeMap);
//// // 如果当前任务还有后续任务,则遍历创建后续任务
//// ChildNode children = flowNode.getChildren();
//// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
//// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
//// } else {
//// return id;
//// }
// }
// else if(Type.TRIGGER.isEqual(nodeType)){
// throw new WorkFlowException("还不想写这个功能");
// }
// else if(Type.CC.isEqual(nodeType)){
// throw new WorkFlowException("代码呗回滚了 丢了,暂时先不做");
//// childNodeMap.put(flowNode.getId(),flowNode);
//// JSONObject incoming = flowNode.getIncoming();
//// incoming.put("incoming", Collections.singletonList(fromId));
//// String id = createServiceTask(process,flowNode,sequenceFlows,childNodeMap);
//// // 如果当前任务还有后续任务,则遍历创建后续任务
//// ChildNode children = flowNode.getChildren();
//// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
//// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
//// } else {
//// return id;
//// }
// }
// else {
// throw new RuntimeException("未知节点类型: nodeType=" + nodeType);
// }
// }
public static String create(String fromId, ChildNode flowNode, Process process, BpmnModel bpmnModel, List<SequenceFlow> sequenceFlows, Map<String, ChildNode> childNodeMap) throws InvocationTargetException, IllegalAccessException {
String nodeType = flowNode.getType();
if (Type.CONCURRENTS.isEqual(nodeType)) {
return createParallelGatewayBuilder(fromId, flowNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else if (Type.CONDITIONS.isEqual(nodeType)) {
return createExclusiveGatewayBuilder(fromId, flowNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else if (Type.USER_TASK.isEqual(nodeType)) {
childNodeMap.put(flowNode.getId(), flowNode);
JSONObject incoming = flowNode.getIncoming();
incoming.put("incoming", Collections.singletonList(fromId));
String id = createTask(process, flowNode, sequenceFlows, childNodeMap);
// 如果当前任务还有后续任务,则遍历创建后续任务
ChildNode children = flowNode.getChildNode();
if (Objects.nonNull(children) && StringUtils.isNotBlank(children.getId())) {
return create(id, children, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
return id;
}
} else if (Type.ROOT.isEqual(nodeType)) {
childNodeMap.put(flowNode.getId(), flowNode);
JSONObject incoming = flowNode.getIncoming();
incoming.put("incoming", Collections.singletonList(fromId));
String id = createTask(process, flowNode, sequenceFlows, childNodeMap);
// 如果当前任务还有后续任务,则遍历创建后续任务
ChildNode children = flowNode.getChildNode();
if (Objects.nonNull(children) && StringUtils.isNotBlank(children.getId())) {
return create(id, children, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
return id;
}
} else if (Type.DELAY.isEqual(nodeType)) {
throw new WorkFlowException("还不想写这个功能");
// childNodeMap.put(flowNode.getId(),flowNode);
// JSONObject incoming = flowNode.getIncoming();
// incoming.put("incoming", Collections.singletonList(fromId));
// String id = createTask(process,flowNode,sequenceFlows,childNodeMap);
// // 如果当前任务还有后续任务,则遍历创建后续任务
// ChildNode children = flowNode.getChildren();
// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
// } else {
// return id;
// }
} else if (Type.TRIGGER.isEqual(nodeType)) {
throw new WorkFlowException("还不想写这个功能");
} else if (Type.CC.isEqual(nodeType)) {
throw new WorkFlowException("代码呗回滚了 丢了,暂时先不做");
// childNodeMap.put(flowNode.getId(),flowNode);
// JSONObject incoming = flowNode.getIncoming();
// incoming.put("incoming", Collections.singletonList(fromId));
// String id = createServiceTask(process,flowNode,sequenceFlows,childNodeMap);
// // 如果当前任务还有后续任务,则遍历创建后续任务
// ChildNode children = flowNode.getChildren();
// if (Objects.nonNull(children) &&StringUtils.isNotBlank(children.getId())) {
// return create(id, children,process,bpmnModel,sequenceFlows,childNodeMap);
// } else {
// return id;
// }
} else {
throw new RuntimeException("未知节点类型: nodeType=" + nodeType);
}
}
private static String createExclusiveGatewayBuilder(String formId, ChildNode flowNode, Process process, BpmnModel bpmnModel, List<SequenceFlow> sequenceFlows, Map<String, ChildNode> childNodeMap) throws InvocationTargetException, IllegalAccessException {
childNodeMap.put(flowNode.getId(), flowNode);
String name = flowNode.getName();
String exclusiveGatewayId = flowNode.getId();
ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
exclusiveGateway.setId(exclusiveGatewayId);
exclusiveGateway.setName(name);
process.addFlowElement(exclusiveGateway);
process.addFlowElement(connect(formId, exclusiveGatewayId, sequenceFlows, childNodeMap, process));
if (Objects.isNull(flowNode.getConditionNodes()) && Objects.isNull(flowNode.getChildNode())) {
return exclusiveGatewayId;
}
List<ChildNode> flowNodes = flowNode.getConditionNodes();
List<String> incoming = Lists.newArrayListWithCapacity(flowNodes.size());
List<JSONObject> conditions = Lists.newCopyOnWriteArrayList();
for (ChildNode element : flowNodes) {
Boolean typeElse = element.getTypeElse();
if (Boolean.TRUE.equals(typeElse)) {
exclusiveGateway.setDefaultFlow(element.getId());
}
childNodeMap.put(element.getId(), element);
ChildNode childNode = element.getChildNode();
String nodeName = element.getName();
Properties props = element.getProps();
String expression = props.getExpression();
if (Objects.isNull(childNode) || StringUtils.isBlank(childNode.getId())) {
incoming.add(exclusiveGatewayId);
JSONObject condition = new JSONObject();
condition.fluentPut("nodeName", nodeName)
.fluentPut("expression", expression)
.fluentPut("groups", props.getGroups())
.fluentPut("groupsType", props.getGroupsType()
)
.fluentPut("elseSequenceFlowId", element.getId());
conditions.add(condition);
continue;
}
// 只生成一个任务,同时设置当前任务的条件
JSONObject incomingObj = childNode.getIncoming();
incomingObj.put("incoming", Collections.singletonList(exclusiveGatewayId));
String identifier = create(exclusiveGatewayId, childNode, process, bpmnModel, sequenceFlows, childNodeMap);
List<SequenceFlow> flows = sequenceFlows.stream().filter(flow -> StringUtils.equals(exclusiveGatewayId, flow.getSourceRef()))
.collect(Collectors.toList());
flows.stream().forEach(
e -> {
if (StringUtils.isBlank(e.getName()) && StringUtils.isNotBlank(nodeName)) {
e.setName(nodeName);
}
// 设置条件表达式
if (Objects.isNull(e.getConditionExpression()) && StringUtils.isNotBlank(expression)) {
e.setConditionExpression(expression);
}
}
);
if (Objects.nonNull(identifier)) {
incoming.add(identifier);
}
}
ChildNode childNode = flowNode.getChildNode();
if (Objects.nonNull(childNode) && StringUtils.isNotBlank(childNode.getId())) {
String parentId = childNode.getParentId();
ChildNode parentChildNode = childNodeMap.get(parentId);
boolean conFlag = Type.CONCURRENTS.type
.equals(parentChildNode.getType());
if (!conFlag) {
String type = childNode.getType();
if (!Type.EMPTY.type.equals(type)) {
} else {
if (Type.CONDITIONS.type.equals(parentChildNode.getType())) {
String endExId = parentChildNode.getId() + "end";
process.addFlowElement(createExclusiveGateWayEnd(endExId));
if (incoming == null || incoming.isEmpty()) {
return create(exclusiveGatewayId, childNode, process, bpmnModel, sequenceFlows,
childNodeMap);
} else {
JSONObject incomingObj = childNode.getIncoming();
// 所有 service task 连接 end exclusive gateway
incomingObj.put("incoming", incoming);
FlowElement flowElement = bpmnModel.getFlowElement(incoming.get(0));
// 1.0 先进行边连接, 暂存 nextNode
ChildNode nextNode = childNode.getChildNode();
childNode.setChildNode(null);
String identifier = endExId;
for (int i = 0; i < incoming.size(); i++) {
process.addFlowElement(connect(incoming.get(i), identifier, sequenceFlows, childNodeMap, process));
}
// 针对 gateway 空任务分支 添加条件表达式
if (!conditions.isEmpty()) {
FlowElement flowElement1 = bpmnModel.getFlowElement(identifier);
// 获取从 gateway 到目标节点 未设置条件表达式的节点
List<SequenceFlow> flows = sequenceFlows.stream().filter(
flow -> StringUtils.equals(flowElement1.getId(), flow.getTargetRef()))
.filter(
flow -> StringUtils.equals(flow.getSourceRef(), exclusiveGatewayId))
.collect(Collectors.toList());
flows.stream().forEach(sequenceFlow -> {
if (!conditions.isEmpty()) {
JSONObject condition = conditions.get(0);
String nodeName = condition.getString("nodeName");
String expression = condition.getString("expression");
if (StringUtils.isBlank(sequenceFlow.getName()) && StringUtils
.isNotBlank(nodeName)) {
sequenceFlow.setName(nodeName);
}
// 设置条件表达式
if (Objects.isNull(sequenceFlow.getConditionExpression())
&& StringUtils.isNotBlank(expression)) {
sequenceFlow.setConditionExpression(expression);
}
FlowElement flowElement2 = process.getFlowElement(sequenceFlow.getId());
if (flowElement2 != null) {
flowElement2.setId(condition.getString("elseSequenceFlowId"));
exclusiveGateway.setDefaultFlow(flowElement2.getId());
;
}
conditions.remove(0);
}
});
}
// 1.1 边连接完成后,在进行 nextNode 创建
if (Objects.nonNull(nextNode) && StringUtils.isNotBlank(nextNode.getId())) {
return create(identifier, nextNode, process, bpmnModel, sequenceFlows,
childNodeMap);
} else {
return identifier;
}
}
}
}
} else {
System.err.println("-");
}
}
return exclusiveGatewayId;
}
public static ExclusiveGateway createExclusiveGateWayEnd(String id) {
ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
exclusiveGateway.setId(id);
return exclusiveGateway;
}
private static ParallelGateway createParallelGateWayEnd(String id) {
ParallelGateway parallelGateway = new ParallelGateway();
parallelGateway.setId(id);
return parallelGateway;
}
private static String createParallelGatewayBuilder(String formId, ChildNode flowNode, Process process, BpmnModel bpmnModel, List<SequenceFlow> sequenceFlows, Map<String, ChildNode> childNodeMap) throws InvocationTargetException, IllegalAccessException {
childNodeMap.put(flowNode.getId(), flowNode);
String name = flowNode.getName();
ParallelGateway parallelGateway = new ParallelGateway();
String parallelGatewayId = flowNode.getId();
parallelGateway.setId(parallelGatewayId);
parallelGateway.setName(name);
process.addFlowElement(parallelGateway);
process.addFlowElement(connect(formId, parallelGatewayId, sequenceFlows, childNodeMap, process));
if (Objects.isNull(flowNode.getConditionNodes()) && Objects.isNull(flowNode.getChildNode())) {
return parallelGatewayId;
}
List<ChildNode> flowNodes = flowNode.getConditionNodes();
List<String> incoming = Lists.newArrayListWithCapacity(flowNodes.size());
for (ChildNode element : flowNodes) {
childNodeMap.put(element.getId(), element);
ChildNode childNode = element.getChildNode();
if (Objects.isNull(childNode) || StringUtils.isBlank(childNode.getId())) {
incoming.add(parallelGatewayId);
continue;
}
String identifier = create(parallelGatewayId, childNode, process, bpmnModel, sequenceFlows, childNodeMap);
if (Objects.nonNull(identifier)) {
incoming.add(identifier);
}
}
ChildNode childNode = flowNode.getChildNode();
if (Objects.nonNull(childNode) && StringUtils.isNotBlank(childNode.getId())) {
String parentId = childNode.getParentId();
ChildNode parentChildNode = childNodeMap.get(parentId);
boolean conFlag = Type.CONCURRENTS.type
.equals(parentChildNode.getType());
if (!conFlag) {
String type = childNode.getType();
if (!Type.EMPTY.type.equals(type)) {
} else {
if (Type.CONCURRENTS.type.equals(parentChildNode.getType())) {
String endExId = parentChildNode.getId() + "end";
process.addFlowElement(createParallelGateWayEnd(endExId));
// 普通结束网关
if (CollectionUtils.isEmpty(incoming)) {
return create(parallelGatewayId, childNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
JSONObject incomingObj = childNode.getIncoming();
// 所有 service task 连接 end parallel gateway
incomingObj.put("incoming", incoming);
FlowElement flowElement = bpmnModel.getFlowElement(incoming.get(0));
// 1.0 先进行边连接, 暂存 nextNode
ChildNode nextNode = childNode.getChildNode();
childNode.setChildNode(null);
String identifier = endExId;
for (int i = 0; i < incoming.size(); i++) {
FlowElement flowElement1 = bpmnModel.getFlowElement(incoming.get(i));
process.addFlowElement(connect(flowElement1.getId(), identifier, sequenceFlows, childNodeMap, process));
}
// 1.1 边连接完成后,在进行 nextNode 创建
if (Objects.nonNull(nextNode) && StringUtils.isNotBlank(nextNode.getId())) {
return create(identifier, nextNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
return identifier;
}
}
}
}
} else {
String type = childNode.getType();
if (!Type.EMPTY.type.equals(type)) {
} else {
if (Type.CONCURRENTS.type.equals(parentChildNode.getType())) {
String endExId = parentChildNode.getId() + "end";
process.addFlowElement(createParallelGateWayEnd(endExId));
// 普通结束网关
if (CollectionUtils.isEmpty(incoming)) {
return create(parallelGatewayId, childNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
JSONObject incomingObj = childNode.getIncoming();
// 所有 service task 连接 end parallel gateway
incomingObj.put("incoming", incoming);
FlowElement flowElement = bpmnModel.getFlowElement(incoming.get(0));
// 1.0 先进行边连接, 暂存 nextNode
ChildNode nextNode = childNode.getChildNode();
childNode.setChildNode(null);
String identifier = endExId;
for (int i = 0; i < incoming.size(); i++) {
FlowElement flowElement1 = bpmnModel.getFlowElement(incoming.get(i));
process.addFlowElement(connect(flowElement1.getId(), identifier, sequenceFlows, childNodeMap, process));
}
// 1.1 边连接完成后,在进行 nextNode 创建
if (Objects.nonNull(nextNode) && StringUtils.isNotBlank(nextNode.getId())) {
return create(identifier, nextNode, process, bpmnModel, sequenceFlows, childNodeMap);
} else {
return identifier;
}
}
}
}
}
}
return parallelGatewayId;
}
private static String createTask(Process process, ChildNode flowNode, List<SequenceFlow> sequenceFlows, Map<String, ChildNode> childNodeMap) {
JSONObject incomingJson = flowNode.getIncoming();
List<String> incoming = incomingJson.getJSONArray("incoming").toJavaList(String.class);
// 自动生成id
// String id = id("serviceTask");
String id = flowNode.getId();
if (incoming != null && !incoming.isEmpty()) {
UserTask userTask = new UserTask();
userTask.setName(flowNode.getName());
userTask.setId(id);
process.addFlowElement(userTask);
process.addFlowElement(connect(incoming.get(0), id, sequenceFlows, childNodeMap, process));
ArrayList<FlowableListener> taskListeners = new ArrayList<>();
FlowableListener taskListener = new FlowableListener();
// 事件类型,
taskListener.setEvent(TaskListener.EVENTNAME_CREATE);
// 监听器类型
taskListener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
// 设置实现了,这里设置监听器的类型是delegateExpression,这样可以在实现类注入Spring bean.
taskListener.setImplementation("${taskCreatedListener}");
taskListeners.add(taskListener);
userTask.setTaskListeners(taskListeners);
if ("root".equalsIgnoreCase(id)) {
} else {
ArrayList<FlowableListener> listeners = new ArrayList<>();
FlowableListener activitiListener = new FlowableListener();
// 事件类型,
activitiListener.setEvent(ExecutionListener.EVENTNAME_START);
// 监听器类型
activitiListener.setImplementationType(IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
// 设置实现了,这里设置监听器的类型是delegateExpression,这样可以在实现类注入Spring bean.
activitiListener.setImplementation("${counterSignListener}");
listeners.add(activitiListener);
userTask.setExecutionListeners(listeners);
Properties props = flowNode.getProps();
String mode = props.getMode();
MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
// 审批人集合参数
multiInstanceLoopCharacteristics.setInputDataItem(userTask.getId() + "assigneeList");
// 迭代集合
multiInstanceLoopCharacteristics.setElementVariable("assigneeName");
// 并行
multiInstanceLoopCharacteristics.setSequential(false);
userTask.setAssignee("${assigneeName}");
// 设置多实例属性
userTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);
if (ModeEnums.OR.getTypeName().equals(mode)) {
multiInstanceLoopCharacteristics.setCompletionCondition("${nrOfCompletedInstances/nrOfInstances > 0}");
} else if (ModeEnums.NEXT.getTypeName().equals(mode)) {
multiInstanceLoopCharacteristics.setSequential(true);
}
JSONObject timeLimit = props.getTimeLimit();
if (timeLimit != null && !timeLimit.isEmpty()) {
JSONObject timeout = timeLimit.getJSONObject("timeout");
if (timeout != null && !timeout.isEmpty()) {
String unit = timeout.getString("unit");
Integer value = timeout.getInteger("value");
if (value > 0) {
List<BoundaryEvent> boundaryEvents = new ArrayList<>();
BoundaryEvent boundaryEvent = new BoundaryEvent();
boundaryEvent.setId(id("boundaryEvent"));
boundaryEvent.setAttachedToRefId(id);
boundaryEvent.setAttachedToRef(userTask);
boundaryEvent.setCancelActivity(Boolean.TRUE);
TimerEventDefinition timerEventDefinition = new TimerEventDefinition();
timerEventDefinition.setTimeDuration("PT" + 1 + "M");
timerEventDefinition.setId(id("timerEventDefinition"));
boundaryEvent.addEventDefinition(timerEventDefinition);
FlowableListener flowableListener = new FlowableListener();
flowableListener.setEvent(ExecutionListener.EVENTNAME_END);
flowableListener.setImplementationType(IMPLEMENTATION_TYPE_CLASS);
flowableListener.setImplementation("com.dingding.mid.listener.TimerListener");
List<FlowableListener> listenerList = new ArrayList<>();
listenerList.add(flowableListener);
boundaryEvent.setExecutionListeners(listenerList);
process.addFlowElement(boundaryEvent);
boundaryEvents.add(boundaryEvent);
userTask.setBoundaryEvents(boundaryEvents);
}
}
}
}
}
return id;
}
private static String createServiceTask(Process process, ChildNode flowNode, List<SequenceFlow> sequenceFlows, Map<String, ChildNode> childNodeMap) {
JSONObject incomingJson = flowNode.getIncoming();
List<String> incoming = incomingJson.getJSONArray("incoming").toJavaList(String.class);
String id = flowNode.getId();
if (incoming != null && !incoming.isEmpty()) {
}
return id;
}
private enum Type { private enum Type {
/** /**
* 并行事件 * 并行事件
...@@ -744,48 +251,7 @@ public class BpmnModelUtils { ...@@ -744,48 +251,7 @@ public class BpmnModelUtils {
} }
private enum FlowType {
/**
* 并行事件
*/
CONCURRENTS(0, ParallelGateway.class),
CONCURRENT(1, SequenceFlow.class),
/**
* 排他事件
*/
CONDITION(2, ExclusiveGateway.class),
CONDITIONS(3, ExclusiveGateway.class),
/**
* 任务
*/
USER_TASK(4, UserTask.class),
EMPTY(5, Object.class),
ROOT(6, UserTask.class),
CC(7, ServiceTask.class),
TRIGGER(8, ServiceTask.class),
DELAY(9, IntermediateCatchEvent.class);
private int type;
private Class<?> typeClass;
FlowType(int type, Class<?> typeClass) {
this.type = type;
this.typeClass = typeClass;
}
public final static Map<String, Class<?>> TYPE_MAP = Maps.newHashMap();
static {
for (Type element : Type.values()) {
TYPE_MAP.put(element.type, element.typeClass);
}
}
public boolean isEqual(int type) {
return this.type == (type);
}
}
public static ChildNode getChildNode(ChildNode childNode, String nodeId) { public static ChildNode getChildNode(ChildNode childNode, String nodeId) {
Map<String, ChildNode> childNodeMap = new HashMap<>(); Map<String, ChildNode> childNodeMap = new HashMap<>();
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
GROUP BY su.user_id,su.real_name GROUP BY su.user_id,su.real_name
</select> </select>
<select id="QueryUserParentOrg" resultMap="UserListDTO"> <select id="QueryUserWithParentOrg" resultMap="UserListDTO">
SELECT SELECT
CASE CASE
WHEN userorg2.org_id = -1 THEN mainUser.user_id WHEN userorg2.org_id = -1 THEN mainUser.user_id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论