|
@@ -21,12 +21,10 @@ import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.activiti.entity.*;
|
|
|
import org.jeecg.modules.activiti.mapper.TbTableInfoMapper;
|
|
|
-import org.jeecg.modules.activiti.service.IActBusinessService;
|
|
|
-import org.jeecg.modules.activiti.service.IActReModelService;
|
|
|
-import org.jeecg.modules.activiti.service.ITbTableInfoPracticeService;
|
|
|
-import org.jeecg.modules.activiti.service.ITbTableInfoService;
|
|
|
+import org.jeecg.modules.activiti.service.*;
|
|
|
import org.jeecg.modules.activiti.service.Impl.ActBusinessServiceImpl;
|
|
|
import org.jeecg.modules.activiti.service.Impl.ActZprocessServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -36,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -71,6 +70,9 @@ public class ActBusinessController {
|
|
|
@Autowired
|
|
|
private IActReModelService iActReModelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITbTableInfoOuterService tbTableInfoOuterService;
|
|
|
+
|
|
|
/*添加申请草稿状态*/
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
public Result add(HttpServletRequest request, @RequestBody JsonContent jsonContent) throws IOException {
|
|
@@ -452,17 +454,20 @@ public class ActBusinessController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Author chenchuang
|
|
|
- * @Description //TODO 外部项目用来调用的流程提交接口
|
|
|
- * @Date 2021/11/26 10:52
|
|
|
- * @Param [act]
|
|
|
- * @return org.jeecg.common.api.vo.Result
|
|
|
- */
|
|
|
- @RequestMapping(value = "/external/apply", method = RequestMethod.POST)
|
|
|
- public Result externalApply(ActBusiness act){
|
|
|
+ * @Author chenchuang
|
|
|
+ * @Description //TODO 外部项目用来调用的流程提交接口
|
|
|
+ * @Date 2021/11/26 10:52
|
|
|
+ * @Param [act]
|
|
|
+ * @return org.jeecg.common.api.vo.Result
|
|
|
+ * @modified by fhf 2023-03-22 外部表单提交,用户使用当前登录用户
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/external/apply")
|
|
|
+ public Result externalApply(@RequestBody ActBusiness act){
|
|
|
Result result=new Result();
|
|
|
try {
|
|
|
//获取审核人
|
|
|
+ /*
|
|
|
ProcessNodeVo node = actZprocessService.getFirstNode(act.getProcDefId());
|
|
|
ActBusiness actBusiness = new ActBusiness();
|
|
|
actBusiness.setUserId(act.getExternalUsername());
|
|
@@ -475,10 +480,23 @@ public class ActBusinessController {
|
|
|
actBusiness.setRouteName(act.getTableName());
|
|
|
actBusinessService.save(actBusiness);
|
|
|
submit(actBusiness,node);
|
|
|
+ result.success("操作成功");*/
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ ProcessNodeVo node = actZprocessService.getFirstNode(act.getProcDefId());
|
|
|
+ act.setPkOrg(sysUser.getPkOrg());//公司id
|
|
|
+ act.setExternalUsername(sysUser.getUsername());
|
|
|
+
|
|
|
+ String processInstanceId = actZprocessService.startProcess(act);
|
|
|
+ act.setProcInstId(processInstanceId);
|
|
|
+ act.setStatus(1);
|
|
|
+ act.setResult(1);
|
|
|
+ act.setApplyTime(new Date());
|
|
|
+ actBusinessService.updateById(act);
|
|
|
+
|
|
|
result.success("操作成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- result.error500("操作失败");
|
|
|
+ result.error500("提交失败,错误信息:"+e.getMessage());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -657,18 +675,27 @@ public class ActBusinessController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc 获取表单信息
|
|
|
+ * @desc 获取外部表单信息
|
|
|
*/
|
|
|
@RequestMapping(value = "/getTableInfoList")
|
|
|
@ResponseBody
|
|
|
public Result<Object> listData(){
|
|
|
+ List<TbTableInfoOuter> tableInfoOuterList = tbTableInfoOuterService.list();
|
|
|
+ List<Map<String,Object>> retList = tableInfoOuterList.stream().map(item->{
|
|
|
+ Map<String,Object> mapItem = new Hashtable<>();
|
|
|
+ mapItem.put("text", item.getText());
|
|
|
+ mapItem.put("routeName", item.getRouteName());
|
|
|
+ mapItem.put("businessTable", item.getText());
|
|
|
+ return mapItem;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ /*
|
|
|
List<Map> list = new ArrayList();
|
|
|
Map map = Maps.newHashMap();
|
|
|
map.put("text", "合同表单");
|
|
|
map.put("routeName", "外部表单contract-file");
|
|
|
map.put("businessTable", "contract-file");
|
|
|
- list.add(map);
|
|
|
- return Result.ok(list);
|
|
|
+ list.add(map);*/
|
|
|
+ return Result.ok(retList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -782,4 +809,139 @@ public class ActBusinessController {
|
|
|
|
|
|
return sb2.toString();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加外部申请草稿状态
|
|
|
+ * @Author fhf
|
|
|
+ * @Date 2023-03-22
|
|
|
+ * @param param - 固定参数type,其他参数外部表单提供,用于显示外部表单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/addOuter")
|
|
|
+ public Result addOuter(@RequestBody Map<String,Object> param) {
|
|
|
+ Result result=new Result();
|
|
|
+ try {
|
|
|
+ /* 表单名称 */
|
|
|
+ String tableName = oConvertUtils.getString(param.get("type"));
|
|
|
+ QueryWrapper<TbTableInfoOuter> tableInfoOuterQueryWrapper = new QueryWrapper<>();
|
|
|
+ tableInfoOuterQueryWrapper.eq("text",tableName);
|
|
|
+ List<TbTableInfoOuter> tbTableInfoOuterList = tbTableInfoOuterService.list(tableInfoOuterQueryWrapper);
|
|
|
+ if (tbTableInfoOuterList.size() == 0){
|
|
|
+ result.error500("外部表单:"+tableName+"没有定义,申请失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (tbTableInfoOuterList.size() > 1){
|
|
|
+ result.error500("外部表单:"+tableName+"定义了"+tbTableInfoOuterList.size()+"个,超过了1个,申请失败");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ TbTableInfoOuter tbTableInfoOuter = tbTableInfoOuterList.get(0);
|
|
|
+ if (oConvertUtils.isEmpty(tbTableInfoOuter.getRouteName()) ||
|
|
|
+ !tbTableInfoOuter.getRouteName().startsWith("外部表单")
|
|
|
+ ){
|
|
|
+ result.error500("外部表单:"+tableName+"路由:"+tbTableInfoOuter.getRouteName()+"不是以'外部表单'开头,申请失败");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ /* 获取ActZprocess,只能有一个,并且RouteName要以外部表单开头*/
|
|
|
+ QueryWrapper<ActZprocess> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("business_table", tableName);
|
|
|
+ queryWrapper.eq("latest", 1);
|
|
|
+ List<ActZprocess> actZprocessList = actZprocessService.list(queryWrapper);
|
|
|
+ if (actZprocessList.size() == 0){
|
|
|
+ result.error500("外部表单:"+tableName+"没有已部署的流程,申请失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (actZprocessList.size() > 1){
|
|
|
+ result.error500("外部表单:"+tableName+"部署了"+actZprocessList.size()+"个流程,超过了1个,申请失败");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ ActZprocess actZprocess = actZprocessList.get(0);
|
|
|
+
|
|
|
+ /* 获取请求参数 */
|
|
|
+ JSONObject jsonObject = new JSONObject(param);
|
|
|
+
|
|
|
+ /* 判断是否已经有发起得流程 */
|
|
|
+ QueryWrapper<TbTableInfoPractice> practiceQueryWrapper = new QueryWrapper<>();
|
|
|
+ practiceQueryWrapper.eq("text", tableName);
|
|
|
+ practiceQueryWrapper.eq("route_name", tbTableInfoOuter.getRouteName());
|
|
|
+ practiceQueryWrapper.eq("content", JSON.toJSONString(jsonObject));
|
|
|
+ List<TbTableInfoPractice> tableInfoPracticeList = tbTableInfoPracticeService.list(practiceQueryWrapper);
|
|
|
+ if (tableInfoPracticeList.size()>0){
|
|
|
+ QueryWrapper<ActBusiness> businessQueryWrapper = new QueryWrapper<>();
|
|
|
+ businessQueryWrapper.eq("table_id", tableInfoPracticeList.get(0).getId());
|
|
|
+ ActBusiness actBusiness = actBusinessService.getOne(businessQueryWrapper);
|
|
|
+ if (actBusiness == null){
|
|
|
+ result.error500("数据校验失败,请联系管理员");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (oConvertUtils.isNotEmpty(actBusiness.getProcInstId())){
|
|
|
+ result.error500("流程已发起,不能重复发起");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ actBusiness.setRouteName(tableInfoPracticeList.get(0).getRouteName());
|
|
|
+ result.success("发起申请成功");
|
|
|
+ result.setResult(actBusiness);
|
|
|
+ }else {
|
|
|
+ /*保存业务表单数据到数据库表*/
|
|
|
+ String tableId = IdUtil.simpleUUID();
|
|
|
+ TbTableInfoPractice tbTableInfoPractice = new TbTableInfoPractice(tableId, tableName, tableName,
|
|
|
+ JSON.toJSONString(jsonObject),
|
|
|
+ null, tbTableInfoOuter.getRouteName(), "", null, null,
|
|
|
+ "1", tableId, tbTableInfoOuter.getType());
|
|
|
+ tbTableInfoPracticeService.save(tbTableInfoPractice);
|
|
|
+ // 保存至我的申请业务
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String username = sysUser.getUsername();
|
|
|
+ ActBusiness actBusiness = new ActBusiness();
|
|
|
+ actBusiness.setUserId(username);
|
|
|
+ actBusiness.setTableId(tableId);
|
|
|
+ actBusiness.setProcDefId(actZprocess.getId());
|
|
|
+ String title = tableName;
|
|
|
+ actBusiness.setTitle(title);
|
|
|
+ actBusiness.setTableName(tableName);
|
|
|
+ actBusiness.setPkOrg(sysUser.getOrgCode());//公司id
|
|
|
+ actBusinessService.save(actBusiness);
|
|
|
+
|
|
|
+ QueryWrapper<ActBusiness> businessQueryWrapper = new QueryWrapper<>();
|
|
|
+ businessQueryWrapper.eq("table_id", tableId);
|
|
|
+ actBusiness = actBusinessService.getOne(businessQueryWrapper);
|
|
|
+ actBusiness.setRouteName(tbTableInfoOuter.getRouteName());
|
|
|
+
|
|
|
+ result.success("发起申请成功");
|
|
|
+ result.setResult(actBusiness);
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ result.error500("发起申请异常:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取显示的外部表单路径
|
|
|
+ * @Author fhf
|
|
|
+ * @Date 2023-03-23
|
|
|
+ * @param tableId - tb_table_info_practice 表 id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/external/getViewUrl")
|
|
|
+ public Result getViewUrl(@RequestParam(name="tableId", required = true) String tableId ) {
|
|
|
+ Result result=new Result();
|
|
|
+ try {
|
|
|
+ TbTableInfoPractice tableInfoPractice = tbTableInfoPracticeService.getById(tableId);
|
|
|
+ QueryWrapper<TbTableInfoOuter> tableInfoOuterQueryWrapper = new QueryWrapper<>();
|
|
|
+ tableInfoOuterQueryWrapper.eq("text", tableInfoPractice.getText());
|
|
|
+ TbTableInfoOuter tableInfoOuter = tbTableInfoOuterService.getOne(tableInfoOuterQueryWrapper);
|
|
|
+ String url = tableInfoOuter.getViewurl();
|
|
|
+ JSONObject param = JSON.parseObject(tableInfoPractice.getContent());
|
|
|
+ JSONObject retObj = new JSONObject();
|
|
|
+ retObj.put("url", url);
|
|
|
+ retObj.put("param", param);
|
|
|
+ result.success("获取成功");
|
|
|
+ result.setResult(retObj);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ result.error500("获取异常:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|