|
@@ -59,6 +59,42 @@ public class FmsCropController extends BaseController
|
|
|
private IFmsLandService fmsLandService;
|
|
private IFmsLandService fmsLandService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private ISysResService sysResService;
|
|
private ISysResService sysResService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增字典类型
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('fms:crop:type:add')")
|
|
|
|
|
+ @Log(title = "字典数据", businessType = BusinessType.INSERT)
|
|
|
|
|
+ @PostMapping("/type/add")
|
|
|
|
|
+ public AjaxResult addNoValue(@Validated @RequestBody AddNoValueReqVo reqVo) {
|
|
|
|
|
+ /* 判断是否存在 */
|
|
|
|
|
+ SysDictData dictData = new SysDictData();
|
|
|
|
|
+ dictData.setDicttypeCode(reqVo.getDicttypeCode());
|
|
|
|
|
+ dictData.setDictNameEq(reqVo.getDictName());
|
|
|
|
|
+ List<SysDictData> dictDataList = dictDataService.selectDictDataList(dictData);
|
|
|
|
|
+ if (!dictDataList.isEmpty()) {
|
|
|
|
|
+ return AjaxResult.error(ErrorCode.ADD_DUPLICATE_ERROR.getCode(), ErrorCode.ADD_DUPLICATE_ERROR.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 新增 */
|
|
|
|
|
+ SysDictData dict = new SysDictData();
|
|
|
|
|
+ BeanUtils.copyProperties(reqVo, dict);
|
|
|
|
|
+ //查询当前字典类型的数值的最大值
|
|
|
|
|
+ Integer max = dictDataService.maxValueByDictType(dict.getDicttypeCode());
|
|
|
|
|
+ max = max == null ? 0 : max;
|
|
|
|
|
+ if (StringUtils.isEmpty(dict.getDictValue())) {
|
|
|
|
|
+ dict.setDictValue(String.valueOf(max+1));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (dict.getDictSeq() == null) {
|
|
|
|
|
+ dict.setDictSeq(Long.valueOf(max+1));
|
|
|
|
|
+ }
|
|
|
|
|
+ dict.setDictAvlstatus(CommonEnums.DICT_STATUS_NORMAL.getCode());
|
|
|
|
|
+ dict.setDictCreator(getUserId());
|
|
|
|
|
+ return toAjax(dictDataService.insertDictData(dict));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询作物列表
|
|
* 查询作物列表
|
|
|
*/
|
|
*/
|
|
@@ -209,38 +245,4 @@ public class FmsCropController extends BaseController
|
|
|
}
|
|
}
|
|
|
return error(ErrorCode.UPLOAD_FAIL.getCode());
|
|
return error(ErrorCode.UPLOAD_FAIL.getCode());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增字典类型
|
|
|
|
|
- */
|
|
|
|
|
- @PreAuthorize("@ss.hasPermi('fms:crop:type:add')")
|
|
|
|
|
- @Log(title = "字典数据", businessType = BusinessType.INSERT)
|
|
|
|
|
- @PostMapping("/type/add")
|
|
|
|
|
- public AjaxResult addNoValue(@Validated @RequestBody AddNoValueReqVo reqVo) {
|
|
|
|
|
- /* 判断是否存在 */
|
|
|
|
|
- SysDictData dictData = new SysDictData();
|
|
|
|
|
- dictData.setDicttypeCode(reqVo.getDicttypeCode());
|
|
|
|
|
- dictData.setDictNameEq(reqVo.getDictName());
|
|
|
|
|
- List<SysDictData> dictDataList = dictDataService.selectDictDataList(dictData);
|
|
|
|
|
- if (dictDataList.size() > 0) {
|
|
|
|
|
- return AjaxResult.error(ErrorCode.ADD_DUPLICATE_ERROR.getCode(), ErrorCode.ADD_DUPLICATE_ERROR.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* 新增 */
|
|
|
|
|
- SysDictData dict = new SysDictData();
|
|
|
|
|
- BeanUtils.copyProperties(reqVo, dict);
|
|
|
|
|
- //查询当前字典类型的数值的最大值
|
|
|
|
|
- Integer max = dictDataService.maxValueByDictType(dict.getDicttypeCode());
|
|
|
|
|
- max = max == null ? 0 : max;
|
|
|
|
|
- if (StringUtils.isEmpty(dict.getDictValue())) {
|
|
|
|
|
- dict.setDictValue(String.valueOf(max+1));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (dict.getDictSeq() == null) {
|
|
|
|
|
- dict.setDictSeq(Long.valueOf(max+1));
|
|
|
|
|
- }
|
|
|
|
|
- dict.setDictAvlstatus(CommonEnums.DICT_STATUS_NORMAL.getCode());
|
|
|
|
|
- dict.setDictCreator(getUserId());
|
|
|
|
|
- return toAjax(dictDataService.insertDictData(dict));
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|