新增物料类型处理逻辑,确保在保存和编辑称重记录时自动设置默认物料类型。更新前端表单以支持密炼物料的选择和显示,优化用户体验。添加分类字典和数据字典的事件广播功能,增强系统的实时数据同步能力。
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
@@ -51,6 +52,8 @@ import java.util.stream.Collectors;
|
||||
public class SysCategoryController {
|
||||
@Autowired
|
||||
private ISysCategoryService sysCategoryService;
|
||||
@Autowired
|
||||
private SimpMessagingTemplate stompTemplate;
|
||||
|
||||
/**
|
||||
* 分类编码0
|
||||
@@ -128,6 +131,7 @@ public class SysCategoryController {
|
||||
try {
|
||||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
publishCategoryChanged("add", sysCategory.getId());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
@@ -149,10 +153,11 @@ public class SysCategoryController {
|
||||
}else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
result.success("修改成功!");
|
||||
publishCategoryChanged("edit", sysCategory.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
@@ -167,11 +172,11 @@ public class SysCategoryController {
|
||||
}else {
|
||||
this.sysCategoryService.deleteSysCategory(id);
|
||||
result.success("删除成功!");
|
||||
publishCategoryChanged("delete", id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
@@ -185,10 +190,11 @@ public class SysCategoryController {
|
||||
}else {
|
||||
this.sysCategoryService.deleteSysCategory(ids);
|
||||
result.success("删除成功!");
|
||||
publishCategoryChanged("deleteBatch", null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
@@ -625,5 +631,16 @@ public class SysCategoryController {
|
||||
}
|
||||
}
|
||||
|
||||
private void publishCategoryChanged(String action, String categoryId) {
|
||||
try {
|
||||
String json = "{\"cmd\":\"SYS_CATEGORY_CHANGED\",\"action\":\"" + action + "\""
|
||||
+ (categoryId != null ? ",\"categoryId\":\"" + categoryId + "\"" : "")
|
||||
+ ",\"timestamp\":" + System.currentTimeMillis() + "}";
|
||||
stompTemplate.convertAndSend("/topic/sync/sys-categories", json);
|
||||
} catch (Exception e) {
|
||||
log.debug("广播分类字典变更失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -77,6 +78,8 @@ public class SysDictController {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private SimpMessagingTemplate stompTemplate;
|
||||
@Autowired
|
||||
private ShiroRealm shiroRealm;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@@ -502,6 +505,7 @@ public class SysDictController {
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
sysDictService.save(sysDict);
|
||||
result.success("保存成功!");
|
||||
publishDictChanged("add", sysDict.getId());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
@@ -526,6 +530,7 @@ public class SysDictController {
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
if(ok) {
|
||||
result.success("编辑成功!");
|
||||
publishDictChanged("edit", sysDict.getId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -544,6 +549,7 @@ public class SysDictController {
|
||||
boolean ok = sysDictService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
publishDictChanged("delete", id);
|
||||
}else{
|
||||
result.error500("删除失败!");
|
||||
}
|
||||
@@ -565,6 +571,7 @@ public class SysDictController {
|
||||
}else {
|
||||
sysDictService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
publishDictChanged("deleteBatch", null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -870,4 +877,15 @@ public class SysDictController {
|
||||
sysDictService.editDictByLowAppId(sysDictVo);
|
||||
return Result.ok("编辑成功");
|
||||
}
|
||||
|
||||
private void publishDictChanged(String action, String dictId) {
|
||||
try {
|
||||
String json = "{\"cmd\":\"SYS_DICT_CHANGED\",\"action\":\"" + action + "\""
|
||||
+ (dictId != null ? ",\"dictId\":\"" + dictId + "\"" : "")
|
||||
+ ",\"timestamp\":" + System.currentTimeMillis() + "}";
|
||||
stompTemplate.convertAndSend("/topic/sync/sys-dicts", json);
|
||||
} catch (Exception e) {
|
||||
log.debug("广播数据字典变更失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.service.ISysDictItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -48,6 +49,8 @@ public class SysDictItemController {
|
||||
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
private SimpMessagingTemplate stompTemplate;
|
||||
|
||||
/**
|
||||
* @功能:查询字典数据
|
||||
@@ -83,6 +86,7 @@ public class SysDictItemController {
|
||||
sysDictItem.setCreateTime(new Date());
|
||||
sysDictItemService.save(sysDictItem);
|
||||
result.success("保存成功!");
|
||||
publishDictChanged("add", sysDictItem.getId());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
@@ -109,11 +113,12 @@ public class SysDictItemController {
|
||||
//TODO 返回false说明什么?
|
||||
if(ok) {
|
||||
result.success("编辑成功!");
|
||||
publishDictChanged("edit", sysDictItem.getId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:删除字典数据
|
||||
* @param id
|
||||
@@ -131,11 +136,12 @@ public class SysDictItemController {
|
||||
boolean ok = sysDictItemService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
publishDictChanged("delete", id);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:批量删除字典数据
|
||||
* @param ids
|
||||
@@ -151,6 +157,7 @@ public class SysDictItemController {
|
||||
}else {
|
||||
this.sysDictItemService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
publishDictChanged("deleteBatch", null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -182,5 +189,15 @@ public class SysDictItemController {
|
||||
return Result.error("该值不可用,系统中已存在!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void publishDictChanged(String action, String itemId) {
|
||||
try {
|
||||
String json = "{\"cmd\":\"SYS_DICT_CHANGED\",\"action\":\"" + action + "\""
|
||||
+ (itemId != null ? ",\"dictId\":\"" + itemId + "\"" : "") + "}";
|
||||
stompTemplate.convertAndSend("/topic/sync/sys-dicts", json);
|
||||
} catch (Exception e) {
|
||||
log.warn("[数据字典] STOMP推送失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user