开发流程与工序数据回显功能。优化修改和新增
parent
bc7877a1e4
commit
129521de6e
|
@ -1,11 +1,8 @@
|
|||
package com.wangziyang.mes.basedata.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.wangziyang.mes.basedata.dto.SpFlowDto;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlow;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlowOperRelation;
|
||||
import com.wangziyang.mes.basedata.entity.SpOper;
|
||||
import com.wangziyang.mes.basedata.request.SpTableManagerReq;
|
||||
import com.wangziyang.mes.basedata.service.ISpFlowOperRelationService;
|
||||
import com.wangziyang.mes.basedata.service.ISpFlowService;
|
||||
|
@ -17,13 +14,11 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -77,22 +72,16 @@ public class SpFlowOperRelationController extends BaseController {
|
|||
*/
|
||||
@ApiOperation("流程与工序关系管理编辑界面")
|
||||
@GetMapping("/add-or-update-ui")
|
||||
public String addOrUpdateUI(Model model, SpFlow record) {
|
||||
List<SpOper> operList = iSpOperService.list();
|
||||
List<SpOperVo> spOperVos = new ArrayList<>();
|
||||
//得出全部的工序数据
|
||||
for (SpOper spOper : operList) {
|
||||
SpOperVo operVo = new SpOperVo();
|
||||
operVo.setValue(spOper.getId());
|
||||
operVo.setTitle(spOper.getOper());
|
||||
spOperVos.add(operVo);
|
||||
}
|
||||
model.addAttribute("allOper", spOperVos);
|
||||
public String addOrUpdateUI(Model model, SpFlow record) throws Exception {
|
||||
List<SpOperVo> allSpOperVos = iSpFlowOperRelationService.allOperViewServer();
|
||||
//全部工序
|
||||
model.addAttribute("allOper", allSpOperVos);
|
||||
if (StringUtils.isNotEmpty(record.getId())) {
|
||||
SpFlow flowbyId = iSpFlowService.getById(record.getId());
|
||||
//当前流程信息
|
||||
model.addAttribute("flow", flowbyId);
|
||||
// model.addAttribute("current", spOperVos);
|
||||
List<SpOperVo> currentSpOperVos = iSpFlowOperRelationService.currentOperViewServer(record.getId());
|
||||
model.addAttribute("currentOper", currentSpOperVos);
|
||||
}
|
||||
return "basedata/flowprocess/addOrUpdate";
|
||||
}
|
||||
|
@ -124,20 +113,7 @@ public class SpFlowOperRelationController extends BaseController {
|
|||
@PostMapping("/add-or-update")
|
||||
@ResponseBody
|
||||
public Result addOrUpdate(@RequestBody SpFlowDto spFlowDto) throws Exception {
|
||||
List<SpFlowOperRelation> spFlowOperRelationList = spFlowDto.getSpFlowOperRelationList();
|
||||
|
||||
if(CollectionUtil.isEmpty(spFlowOperRelationList))
|
||||
{
|
||||
throw new Exception("流程下的工序不能为空");
|
||||
}
|
||||
SpFlow spFlow =new SpFlow();
|
||||
BeanUtils.copyProperties(spFlowDto,spFlow);
|
||||
|
||||
|
||||
//保存流程头表信息
|
||||
iSpFlowService.saveOrUpdate(spFlow);
|
||||
iSpFlowOperRelationService.saveOrUpdateBatch(spFlowOperRelationList);
|
||||
return Result.success();
|
||||
return iSpFlowOperRelationService.addOrUpdate(spFlowDto);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.wangziyang.mes.basedata.dto;
|
|||
|
||||
import com.wangziyang.mes.basedata.entity.SpFlow;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlowOperRelation;
|
||||
import com.wangziyang.mes.basedata.vo.SpOperVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -12,23 +13,13 @@ public class SpFlowDto extends SpFlow {
|
|||
/**
|
||||
* 流程与工序关系集合
|
||||
*/
|
||||
private List<SpFlowOperRelation> spFlowOperRelationList;
|
||||
private List<SpOperVo> spOperVoList;
|
||||
|
||||
/**
|
||||
* 获取 流程与工序关系集合
|
||||
*
|
||||
* @return spFlowOperRelationList 流程与工序关系集合
|
||||
*/
|
||||
public List<SpFlowOperRelation> getSpFlowOperRelationList() {
|
||||
return this.spFlowOperRelationList;
|
||||
public List<SpOperVo> getSpOperVoList() {
|
||||
return spOperVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 流程与工序关系集合
|
||||
*
|
||||
* @param spFlowOperRelationList 流程与工序关系集合
|
||||
*/
|
||||
public void setSpFlowOperRelationList(List<SpFlowOperRelation> spFlowOperRelationList) {
|
||||
this.spFlowOperRelationList = spFlowOperRelationList;
|
||||
public void setSpOperVoList(List<SpOperVo> spOperVoList) {
|
||||
this.spOperVoList = spOperVoList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,44 @@
|
|||
package com.wangziyang.mes.basedata.service;
|
||||
|
||||
import com.wangziyang.mes.basedata.entity.SpFlowOperRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wangziyang.mes.basedata.dto.SpFlowDto;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlowOperRelation;
|
||||
import com.wangziyang.mes.basedata.vo.SpOperVo;
|
||||
import com.wangziyang.mes.common.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author WangZiYang
|
||||
* @since 2020-03-14
|
||||
*/
|
||||
public interface ISpFlowOperRelationService extends IService<SpFlowOperRelation> {
|
||||
/**
|
||||
* 流程与工序关系新增与修改
|
||||
*
|
||||
* @param spFlowDto 流程信息DTO
|
||||
* @return 执行结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
Result addOrUpdate(SpFlowDto spFlowDto) throws Exception;
|
||||
|
||||
/**
|
||||
* 全部工序集合
|
||||
*
|
||||
* @return 工序VO集合
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
List<SpOperVo> allOperViewServer() throws Exception;
|
||||
|
||||
/**
|
||||
* 绘制当前流程下的工序
|
||||
*
|
||||
* @return 工序VO集合
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
List<SpOperVo> currentOperViewServer(String flowId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,30 @@
|
|||
package com.wangziyang.mes.basedata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wangziyang.mes.basedata.dto.SpFlowDto;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlow;
|
||||
import com.wangziyang.mes.basedata.entity.SpFlowOperRelation;
|
||||
import com.wangziyang.mes.basedata.entity.SpOper;
|
||||
import com.wangziyang.mes.basedata.mapper.SpFlowOperRelationMapper;
|
||||
import com.wangziyang.mes.basedata.service.ISpFlowOperRelationService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wangziyang.mes.basedata.service.ISpFlowService;
|
||||
import com.wangziyang.mes.basedata.service.ISpOperService;
|
||||
import com.wangziyang.mes.basedata.vo.SpOperVo;
|
||||
import com.wangziyang.mes.common.Result;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author WangZiYang
|
||||
|
@ -17,4 +33,112 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class SpFlowOperRelationServiceImpl extends ServiceImpl<SpFlowOperRelationMapper, SpFlowOperRelation> implements ISpFlowOperRelationService {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(SpFlowOperRelationServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 流程基础数据服务
|
||||
*/
|
||||
@Autowired
|
||||
public ISpFlowService iSpFlowService;
|
||||
|
||||
/**
|
||||
* 工序基础数据服务
|
||||
*/
|
||||
@Autowired
|
||||
public ISpOperService iSpOperService;
|
||||
|
||||
/**
|
||||
* 全部工序集合
|
||||
*
|
||||
* @return 工序VO集合
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public List<SpOperVo> allOperViewServer() throws Exception {
|
||||
List<SpOper> operList = iSpOperService.list();
|
||||
List<SpOperVo> spOperVos = new ArrayList<>();
|
||||
//得出全部的工序数据
|
||||
for (SpOper spOper : operList) {
|
||||
SpOperVo operVo = new SpOperVo();
|
||||
operVo.setValue(spOper.getId());
|
||||
operVo.setTitle(spOper.getOper());
|
||||
spOperVos.add(operVo);
|
||||
}
|
||||
return spOperVos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制当前流程下的工序
|
||||
*
|
||||
* @return 工序VO集合
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public List<SpOperVo> currentOperViewServer(String flowId) throws Exception {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程与工序关系新增与修改
|
||||
*
|
||||
* @param spFlowDto 流程信息DTO
|
||||
* @return 执行结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public Result addOrUpdate(SpFlowDto spFlowDto) throws Exception {
|
||||
List<SpOperVo> spOperVoList = spFlowDto.getSpOperVoList();
|
||||
List<SpFlowOperRelation> spFlowOperRelationList = new ArrayList<>();
|
||||
StringBuilder processBuild = new StringBuilder();
|
||||
if (CollectionUtil.isEmpty(spOperVoList)) {
|
||||
throw new Exception("流程下的工序不能为空");
|
||||
}
|
||||
SpFlow spFlow = new SpFlow();
|
||||
BeanUtils.copyProperties(spFlowDto, spFlow);
|
||||
String flowId = spFlow.getId();
|
||||
String flow = spFlow.getFlow();
|
||||
if (StringUtils.isNotEmpty(flowId)) {
|
||||
//TODO 根据流程ID 批量删除下挂的工序
|
||||
}
|
||||
// 批量处理需要插入数据库的工序
|
||||
log.info("开始处理流程下工序关系");
|
||||
for (int i = 0; i < spOperVoList.size(); i++) {
|
||||
SpFlowOperRelation relation = new SpFlowOperRelation();
|
||||
relation.setFlowId(flowId);//流程ID
|
||||
relation.setFlow(flow);//流程编号
|
||||
if (i == 0) {//首个工序
|
||||
relation.setPerOperId("");
|
||||
relation.setPerOper("");
|
||||
//下一道工序
|
||||
relation.setNextOperId(spOperVoList.get(i + 1).getValue());
|
||||
relation.setNextOper(spOperVoList.get(i + 1).getTitle());
|
||||
} else if (i + 1 >= spOperVoList.size()) {//末尾工序
|
||||
//前一道工序
|
||||
relation.setPerOperId(spOperVoList.get(i - 1).getValue());
|
||||
relation.setPerOper(spOperVoList.get(i - 1).getTitle());
|
||||
relation.setNextOperId("");
|
||||
relation.setNextOper("");
|
||||
} else {
|
||||
//前一道工序
|
||||
relation.setPerOperId(spOperVoList.get(i - 1).getValue());
|
||||
relation.setPerOper(spOperVoList.get(i - 1).getTitle());
|
||||
//下一道工序
|
||||
relation.setNextOperId(spOperVoList.get(i + 1).getValue());
|
||||
relation.setNextOper(spOperVoList.get(i + 1).getTitle());
|
||||
}
|
||||
//当前工序
|
||||
relation.setOperId(spOperVoList.get(i).getValue());
|
||||
relation.setOper(spOperVoList.get(i).getTitle());
|
||||
relation.setSortNum(i + 1);//顺序
|
||||
processBuild.append("123->");
|
||||
spFlowOperRelationList.add(relation);
|
||||
}
|
||||
log.info("本次流程时序" + processBuild.toString());
|
||||
spFlow.setProcess(processBuild.toString());
|
||||
//保存流程头表信息
|
||||
iSpFlowService.saveOrUpdate(spFlow);
|
||||
saveOrUpdateBatch(spFlowOperRelationList);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,16 +18,20 @@ layui.define(['layer'], function (exports) {
|
|||
//点击确认触发 iframe 内容中的按钮提交
|
||||
var submit = layero.find('iframe').contents().find("#js-submit");
|
||||
submit.click();
|
||||
// 如果是搜索弹窗面板,之下如下逻辑,以便调用页面可以通过回调函数获取数据
|
||||
|
||||
var spChildFrameResult = layero.find('iframe')[0].contentWindow.spChildFrameResult;
|
||||
if (param.spCallback && (param.spCallback instanceof Function)) {
|
||||
param.spCallback(layero.find('iframe')[0].contentWindow.spChildFrameResult);
|
||||
param.spCallback(spChildFrameResult);
|
||||
}
|
||||
if (param.close !== false) {
|
||||
layer.close(index);
|
||||
}
|
||||
if (param.reload !== false) {
|
||||
// 刷新父页面,注意一定要在关闭当前iframe层之前执行刷新
|
||||
window.location.reload();
|
||||
if (spChildFrameResult && spChildFrameResult.code === 0) {
|
||||
if (param.close !== false) {
|
||||
layer.close(index);
|
||||
}
|
||||
|
||||
if (param.reload !== false) {
|
||||
// 刷新父页面,注意一定要在关闭当前iframe层之前执行刷新
|
||||
parent.location.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
|
|
|
@ -31,14 +31,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label for="js-descr" class="layui-form-label sp-required">流程时序
|
||||
<label for="js-descr" class="layui-form-label ">流程时序
|
||||
</label>
|
||||
<div class="layui-input-inline" style="width: 200px">
|
||||
<input type="text" id="js-process" name="process" lay-verify="required" autocomplete="off"
|
||||
<input type="text" id="js-process" name="process" readonly autocomplete="off"
|
||||
class="layui-input" value="${flow.process}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
|
||||
<legend>流程与工序关系</legend>
|
||||
|
@ -47,7 +48,7 @@
|
|||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<div class="layui-input-block">
|
||||
<input id="js-id" name="id" value="${result.id}"/>
|
||||
<input id="js-id" name="id" value="${flow.id}"/>
|
||||
<button id="js-submit" class="layui-btn" lay-demotransferactive="getData" lay-submit
|
||||
lay-filter="js-submit-filter">确定
|
||||
</button>
|
||||
|
@ -62,13 +63,12 @@
|
|||
util = layui.util,
|
||||
layer = layui.layer,
|
||||
transfer = layui.transfer;
|
||||
|
||||
console.log("1");
|
||||
var requestParmaArr = [];
|
||||
//模拟数据
|
||||
data2 = [];
|
||||
<#list allOper as oper >
|
||||
oper = {};
|
||||
oper.value = '${oper.value}';
|
||||
oper.value = '${oper.value}';
|
||||
oper.title = '${oper.title}';
|
||||
data2.push(oper);
|
||||
</#list>
|
||||
|
@ -78,24 +78,18 @@
|
|||
title: ['全部工序', '当前Flow下工序']
|
||||
, data: data2
|
||||
, value: ["1", "3", "5", "7", "9", "11"]
|
||||
, id: 'key123' //定义唯一索引
|
||||
})
|
||||
//监听提交
|
||||
form.on('submit(js-submit-filter)', function (data) {
|
||||
spUtil.submitForm({
|
||||
url: "${request.contextPath}/admin/sys/role/add-or-update",
|
||||
data: data.field
|
||||
});
|
||||
, id: 'keyFlow' //定义唯一索引
|
||||
});
|
||||
|
||||
//批量办法定事件
|
||||
util.event('lay-demoTransferActive', {
|
||||
getData: function (othis) {
|
||||
var getData = transfer.getData('key123'); //获取右侧数据
|
||||
console.log(JSON.stringify(getData));
|
||||
var getData = transfer.getData('keyFlow'); //获取右侧数据
|
||||
requestParmaArr = getData;
|
||||
}
|
||||
, reload: function () {
|
||||
//实例重载
|
||||
transfer.reload('key123', {
|
||||
transfer.reload('keyFlow', {
|
||||
title: ['文人', '喜欢的文人']
|
||||
, value: ['2', '5', '9']
|
||||
, showSearch: true
|
||||
|
@ -103,10 +97,20 @@
|
|||
}
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(js-submit-filter)', function (data) {
|
||||
data.field.spOperVoList = requestParmaArr;
|
||||
console.log(data.field)
|
||||
spUtil.submitForm({
|
||||
contentType: 'application/json;charset=UTF-8',
|
||||
url: "${request.contextPath}/basedata/flow/process/add-or-update",
|
||||
data: JSON.stringify(data.field)
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue