更新MybatisPlusSaasConfig中的租户ID默认值为1002;在ShiroConfig中添加MES密炼物料管理和系统分类字典的免密接口;在MesMixerMaterialController中实现密炼物料信息的免密增删改查接口,并添加相应的事件广播功能;在SysCategoryController中新增分类字典的免密查询接口;更新前端导航和菜单数据以支持密炼物料信息模块。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.mes.material.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -17,14 +18,23 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
|
||||
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "MES-密炼物料信息")
|
||||
@RestController
|
||||
@RequestMapping("/mes/material/mixerMaterial")
|
||||
public class MesMixerMaterialController extends JeecgController<MesMixerMaterial, IMesMixerMaterialService> {
|
||||
private final SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
public MesMixerMaterialController(SimpMessagingTemplate messagingTemplate) {
|
||||
this.messagingTemplate = messagingTemplate;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesMixerMaterial>> queryPageList(
|
||||
@@ -43,6 +53,7 @@ public class MesMixerMaterialController extends JeecgController<MesMixerMaterial
|
||||
@PostMapping("/add")
|
||||
public Result<String> add(@RequestBody MesMixerMaterial model) {
|
||||
service.save(model);
|
||||
publishChanged("add", model.getId());
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@@ -52,6 +63,7 @@ public class MesMixerMaterialController extends JeecgController<MesMixerMaterial
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesMixerMaterial model) {
|
||||
service.updateById(model);
|
||||
publishChanged("edit", model.getId());
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@@ -61,6 +73,7 @@ public class MesMixerMaterialController extends JeecgController<MesMixerMaterial
|
||||
@DeleteMapping("/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id") String id) {
|
||||
service.removeById(id);
|
||||
publishChanged("delete", id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@@ -71,6 +84,62 @@ public class MesMixerMaterialController extends JeecgController<MesMixerMaterial
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
service.removeByIds(idList);
|
||||
publishChanged("batchDelete", ids);
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密分页查询")
|
||||
@GetMapping("/anon/list")
|
||||
public Result<IPage<MesMixerMaterial>> anonList(
|
||||
MesMixerMaterial model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesMixerMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
IPage<MesMixerMaterial> pageList = service.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密通过id查询")
|
||||
@GetMapping("/anon/queryById")
|
||||
public Result<MesMixerMaterial> anonQueryById(@RequestParam(name = "id") String id) {
|
||||
MesMixerMaterial data = service.getById(id);
|
||||
return data != null ? Result.OK(data) : Result.error("未找到对应数据");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密添加")
|
||||
@PostMapping("/anon/add")
|
||||
public Result<String> anonAdd(@RequestBody MesMixerMaterial model) {
|
||||
service.save(model);
|
||||
publishChanged("add", model.getId());
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密编辑")
|
||||
@RequestMapping(value = "/anon/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> anonEdit(@RequestBody MesMixerMaterial model) {
|
||||
boolean ok = service.updateById(model);
|
||||
if (!ok) {
|
||||
return Result.error("数据已被他人修改,请刷新后重试");
|
||||
}
|
||||
publishChanged("edit", model.getId());
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密删除")
|
||||
@DeleteMapping("/anon/delete")
|
||||
public Result<String> anonDelete(@RequestParam(name = "id") String id) {
|
||||
service.removeById(id);
|
||||
publishChanged("delete", id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES-密炼物料信息-免密批量删除")
|
||||
@DeleteMapping("/anon/deleteBatch")
|
||||
public Result<String> anonDeleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
service.removeByIds(idList);
|
||||
publishChanged("batchDelete", ids);
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@@ -90,4 +159,17 @@ public class MesMixerMaterialController extends JeecgController<MesMixerMaterial
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, MesMixerMaterial.class);
|
||||
}
|
||||
|
||||
private void publishChanged(String action, String mixerMaterialId) {
|
||||
try {
|
||||
Map<String, Object> event = new HashMap<>();
|
||||
event.put("cmd", "MIXER_MATERIAL_CHANGED");
|
||||
event.put("action", action);
|
||||
event.put("mixerMaterialId", mixerMaterialId);
|
||||
event.put("timestamp", System.currentTimeMillis());
|
||||
messagingTemplate.convertAndSend("/topic/sync/mes-mixer-materials", JSON.toJSONString(event));
|
||||
} catch (Exception e) {
|
||||
log.debug("广播密炼物料 STOMP 事件失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,6 +482,78 @@ public class SysCategoryController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典树控件(免密)加载节点
|
||||
*/
|
||||
@RequestMapping(value = "/anon/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> anonLoadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
String queryPid = pid;
|
||||
if (oConvertUtils.isEmpty(queryPid)) {
|
||||
if (oConvertUtils.isEmpty(pcode) || ISysCategoryService.ROOT_PID_VALUE.equals(pcode)) {
|
||||
queryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
} else {
|
||||
queryPid = this.sysCategoryService.queryIdByCode(pcode);
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isEmpty(queryPid)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[code]!");
|
||||
return result;
|
||||
}
|
||||
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
if (ISysCategoryService.ROOT_PID_VALUE.equals(queryPid)) {
|
||||
queryWrapper.and(w -> w.eq("pid", ISysCategoryService.ROOT_PID_VALUE).or().isNull("pid"));
|
||||
} else {
|
||||
queryWrapper.eq("pid", queryPid);
|
||||
}
|
||||
queryWrapper.orderByAsc("code");
|
||||
List<SysCategory> categories = this.sysCategoryService.list(queryWrapper);
|
||||
List<TreeSelectModel> list = new ArrayList<>();
|
||||
for (SysCategory c : categories) {
|
||||
TreeSelectModel tsm = new TreeSelectModel();
|
||||
tsm.setKey(c.getId());
|
||||
tsm.setValue(c.getId());
|
||||
tsm.setTitle(c.getName());
|
||||
tsm.setParentId(c.getPid());
|
||||
tsm.setCode(c.getCode());
|
||||
tsm.setLeaf(!CommonConstant.STATUS_1.equals(c.getHasChild()));
|
||||
list.add(tsm);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典子节点(免密)
|
||||
*/
|
||||
@GetMapping(value = "/anon/childList")
|
||||
public Result<List<SysCategory>> anonChildList(SysCategory sysCategory, HttpServletRequest req) {
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
String pid = sysCategory.getPid();
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
if (oConvertUtils.isEmpty(pid) || ISysCategoryService.ROOT_PID_VALUE.equals(pid)) {
|
||||
queryWrapper.and(w -> w.eq("pid", ISysCategoryService.ROOT_PID_VALUE).or().isNull("pid"));
|
||||
} else {
|
||||
queryWrapper.eq("pid", pid);
|
||||
}
|
||||
queryWrapper.orderByAsc("code");
|
||||
List<SysCategory> list = this.sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典详情(免密)
|
||||
*/
|
||||
@GetMapping(value = "/anon/queryById")
|
||||
public Result<SysCategory> anonQueryById(@RequestParam(name="id",required=true) String id) {
|
||||
return queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user