From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/TableExampleController.java | 414 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 414 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/TableExampleController.java b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/TableExampleController.java
new file mode 100644
index 0000000..f4bbab5
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/TableExampleController.java
@@ -0,0 +1,414 @@
+package jnpf.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import io.swagger.v3.oas.annotations.Parameter;
+import jnpf.base.controller.SuperController;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+import jnpf.base.*;
+import jnpf.base.entity.DictionaryDataEntity;
+import jnpf.base.entity.ProvinceEntity;
+import jnpf.base.vo.ListVO;
+import jnpf.base.vo.PageListVO;
+import jnpf.base.vo.PaginationVO;
+import jnpf.constant.MsgCode;
+import jnpf.exception.DataException;
+import jnpf.model.tableexample.*;
+import jnpf.permission.UserApi;
+import jnpf.permission.entity.UserEntity;
+import jnpf.service.TableExampleService;
+import jnpf.entity.TableExampleEntity;
+import jnpf.model.tableexample.postil.PostilInfoVO;
+import jnpf.model.tableexample.postil.PostilModel;
+import jnpf.model.tableexample.postil.PostilSendForm;
+import jnpf.util.DateUtil;
+import jnpf.util.JsonUtil;
+import jnpf.util.StringUtil;
+import jnpf.util.treeutil.SumTree;
+import jnpf.util.treeutil.TreeDotUtils;
+import jnpf.util.UserProvider;
+import jnpf.util.type.StringNumber;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.validation.Valid;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 琛ㄦ牸绀轰緥鏁版嵁
+ *
+ * @author JNPF寮�鍙戝钩鍙扮粍
+ * @version V3.1.0
+ * @copyright 寮曡繄淇℃伅鎶�鏈湁闄愬叕鍙革紙https://www.jnpfsoft.com锛�
+ * @date 2019骞�9鏈�26鏃� 涓婂崍9:18
+ */
+@Tag(name = "琛ㄦ牸绀轰緥鏁版嵁", description = "TableExample")
+@RestController
+@RequestMapping("/TableExample")
+@RequiredArgsConstructor
+public class TableExampleController extends SuperController<TableExampleService, TableExampleEntity> {
+
+
+ private final TableExampleService tableExampleService;
+
+ private final AreaApi areaApi;
+
+ private final DictionaryDataApi dictionaryDataApi;
+
+ private final UserApi usersApi;
+
+ /**
+ * 鍒楄〃
+ *
+ * @param paginationTableExample 鍒嗛〉妯″瀷
+ * @return
+ */
+ @Operation(summary = "鑾峰彇琛ㄦ牸鏁版嵁鍒楄〃")
+ @GetMapping
+ @SaCheckPermission("extend.tableDemo.commonTable")
+ public ActionResult<PageListVO<TableExampleListVO>> list(PaginationTableExample paginationTableExample) {
+ List<TableExampleEntity> data = tableExampleService.getList(paginationTableExample);
+ List<TableExampleListVO> list = JsonUtil.getJsonToList(data, TableExampleListVO.class);
+ List<String> userId = list.stream().map(TableExampleListVO::getRegistrant).collect(Collectors.toList());
+ List<UserEntity> userList = usersApi.getUserName(userId);
+ for (TableExampleListVO tableExampleListVO : list) {
+ UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
+ tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
+ }
+ PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationTableExample, PaginationVO.class);
+ return ActionResult.page(list, paginationVO);
+ }
+
+ /**
+ * 鍒楄〃锛堟爲褰㈣〃鏍硷級
+ *
+ * @param typeId 涓婚敭
+ * @param paginationTableExample 鏌ヨ妯″瀷
+ * @return
+ */
+ @Operation(summary = "锛堟爲褰㈣〃鏍硷級")
+ @GetMapping("/ControlSample/{typeId}")
+ @Parameter(name = "typeId", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.tableTree")
+ public ActionResult<PageListVO<TableExampleListVO>> list(@PathVariable("typeId") String typeId, PaginationTableExample paginationTableExample) {
+ List<TableExampleEntity> data = tableExampleService.getList(typeId, paginationTableExample);
+ List<TableExampleListVO> list = JsonUtil.getJsonToList(data, TableExampleListVO.class);
+ List<String> userId = list.stream().map(TableExampleListVO::getRegistrant).collect(Collectors.toList());
+ List<UserEntity> userList = usersApi.getUserName(userId);
+ for (TableExampleListVO tableExampleListVO : list) {
+ UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
+ tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
+ }
+ PaginationVO paginationVO = JsonUtil.getJsonToBean(paginationTableExample, PaginationVO.class);
+ return ActionResult.page(list, paginationVO);
+ }
+
+ /**
+ * 鍒楄〃
+ *
+ * @return
+ */
+ @Operation(summary = "鑾峰彇琛ㄦ牸鍒嗙粍鍒楄〃")
+ @GetMapping("/All")
+ @SaCheckPermission("extend.tableDemo.groupingTable")
+ public ActionResult<ListVO<TableExampleListAllVO>> listAll() {
+ List<TableExampleEntity> data = tableExampleService.getList();
+ List<TableExampleListAllVO> list = JsonUtil.getJsonToList(data, TableExampleListAllVO.class);
+ List<String> userId = list.stream().map(TableExampleListAllVO::getRegistrant).collect(Collectors.toList());
+ List<UserEntity> userList = usersApi.getUserName(userId);
+ for (TableExampleListAllVO tableExampleListVO : list) {
+ UserEntity user = userList.stream().filter(t -> t.getId().equals(tableExampleListVO.getRegistrant())).findFirst().orElse(null);
+ tableExampleListVO.setRegistrant(user != null ? user.getRealName() + "/" + user.getAccount() : "");
+ }
+ ListVO<TableExampleListAllVO> vo = new ListVO<>();
+ vo.setList(list);
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 鍒楄〃
+ *
+ * @param page 鏌ヨ妯″瀷
+ * @return
+ */
+ @Operation(summary = "鑾峰彇寤朵几鎵╁睍鍒楄〃(琛屾斂鍖哄垝)")
+ @GetMapping("/IndustryList")
+ @SaCheckPermission("extend.tableDemo.extension")
+ public ActionResult<ListVO<TableExampleIndustryListVO>> industryList(Page page) {
+ String keyword = page.getKeyword();
+ List<ProvinceEntity> data = areaApi.getList("-1");
+ if (!StringUtils.isEmpty(keyword)) {
+ data = data.stream().filter(t -> t.getFullName().contains(keyword)).collect(Collectors.toList());
+ }
+ List<TableExampleIndustryListVO> listVos = JsonUtil.getJsonToList(data, TableExampleIndustryListVO.class);
+ ListVO<TableExampleIndustryListVO> vo = new ListVO<>();
+ vo.setList(listVos);
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 鍒楄〃
+ *
+ * @param id 涓婚敭鍊�
+ * @return
+ */
+ @Operation(summary = "鑾峰彇鍩庡競淇℃伅鍒楄〃(鑾峰彇寤朵几鎵╁睍鍒楄〃(琛屾斂鍖哄垝))")
+ @GetMapping("/CityList/{id}")
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.extension")
+ public ActionResult<ListVO<TableExampleCityListVO>> cityList(@PathVariable("id") String id) {
+ List<ProvinceEntity> data = areaApi.getList(id);
+ List<TableExampleCityListVO> listVos = JsonUtil.getJsonToList(data, TableExampleCityListVO.class);
+ ListVO<TableExampleCityListVO> vo = new ListVO<>();
+ vo.setList(listVos);
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 鍒楄〃锛堣〃鏍兼爲褰級
+ *
+ * @param isTree 绫诲瀷
+ * @return
+ */
+ @Operation(summary = "琛ㄦ牸鏍戝舰")
+ @GetMapping("/ControlSample/TreeList")
+ @Parameter(name = "isTree", description = "绫诲瀷")
+ @SaCheckPermission("extend.tableDemo.tableTree")
+ public ActionResult<ListVO<TableExampleTreeModel>> treeList(@RequestParam("isTree")String isTree) {
+ List<DictionaryDataEntity> data = dictionaryDataApi.getList("d59a3cf65f9847dbb08be449e3feae16");
+ List<TableExampleTreeModel> treeList = new ArrayList<>();
+ for (DictionaryDataEntity entity : data) {
+ TableExampleTreeModel treeModel = new TableExampleTreeModel();
+ treeModel.setId(entity.getId());
+ treeModel.setText(entity.getFullName());
+ treeModel.setParentId(entity.getParentId());
+ treeModel.setLoaded(true);
+ treeModel.setExpanded(true);
+ treeModel.setHt(JsonUtil.entityToMap(entity));
+ treeList.add(treeModel);
+ }
+ if (StringNumber.ONE.equals(isTree)) {
+ List<SumTree<TableExampleTreeModel>> trees = TreeDotUtils.convertListToTreeDot(treeList);
+ List<TableExampleTreeModel> listVO = JsonUtil.getJsonToList(trees, TableExampleTreeModel.class);
+ ListVO<TableExampleTreeModel> vo = new ListVO<>();
+ vo.setList(listVO);
+ return ActionResult.success(vo);
+ }
+ ListVO<TableExampleTreeModel> vo = new ListVO<>();
+ vo.setList(treeList);
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 淇℃伅
+ *
+ * @param id 涓婚敭
+ * @return
+ */
+ @Operation(summary = "鑾峰彇鏅�氳〃鏍肩ず渚嬩俊鎭�")
+ @GetMapping("/{id}")
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.extension")
+ public ActionResult<TableExampleInfoVO> info(@PathVariable("id") String id) throws DataException {
+ TableExampleEntity entity = tableExampleService.getInfo(id);
+ TableExampleInfoVO vo = JsonUtil.getJsonToBeanEx(entity, TableExampleInfoVO.class);
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 鍒犻櫎
+ *
+ * @param id 涓婚敭
+ * @return
+ */
+ @Operation(summary = "鍒犻櫎椤圭洰")
+ @DeleteMapping("/{id}")
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.extension")
+ public ActionResult<Object> delete(@PathVariable("id") String id) {
+ TableExampleEntity entity = tableExampleService.getInfo(id);
+ if (entity != null) {
+ tableExampleService.delete(entity);
+ return ActionResult.success(MsgCode.SU003.get());
+ }
+ return ActionResult.fail(MsgCode.FA003.get());
+ }
+
+ /**
+ * 鍒涘缓
+ *
+ * @param tableExampleCrForm 椤圭洰妯″瀷
+ * @return
+ */
+ @Operation(summary = "鏂板缓椤圭洰")
+ @PostMapping
+ @Parameter(name = "tableExampleCrForm", description = "椤圭洰妯″瀷",required = true)
+ @SaCheckPermission("extend.tableDemo.extension")
+ public ActionResult<Object> create(@RequestBody @Valid TableExampleCrForm tableExampleCrForm) {
+ TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleCrForm, TableExampleEntity.class);
+ entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
+ entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
+ entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
+ entity.setSign("0000000");
+ tableExampleService.create(entity);
+ return ActionResult.success(MsgCode.SU001.get());
+ }
+
+ /**
+ * 鏇存柊
+ *
+ * @param id 涓婚敭
+ * @param tableExampleUpForm 椤圭洰妯″瀷
+ * @return
+ */
+ @Operation(summary = "鏇存柊椤圭洰")
+ @PutMapping("/{id}")
+ @Parameter(name = "tableExampleUpForm", description = "椤圭洰妯″瀷",required = true)
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.postilTable")
+ public ActionResult<Object> update(@PathVariable("id") String id, @RequestBody @Valid TableExampleUpForm tableExampleUpForm) {
+ TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleUpForm, TableExampleEntity.class);
+ entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
+ entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
+ entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
+ boolean flag = tableExampleService.update(id, entity);
+ if (!flag) {
+ return ActionResult.fail(MsgCode.FA002.get());
+ }
+ return ActionResult.success(MsgCode.SU004.get());
+ }
+
+ /**
+ * 鏇存柊鏍囩
+ *
+ * @param id 涓婚敭
+ * @param tableExampleSignUpForm 椤圭洰妯″瀷
+ * @return
+ */
+ @Operation(summary = "鏇存柊鏍囪")
+ @PutMapping("/UpdateSign/{id}")
+ @Parameter(name = "tableExampleSignUpForm", description = "椤圭洰妯″瀷",required = true)
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.postilTable")
+ public ActionResult<Object> updateSign(@PathVariable("id") String id, @RequestBody @Valid TableExampleSignUpForm tableExampleSignUpForm) {
+ TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleSignUpForm, TableExampleEntity.class);
+ TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
+ if (tableExampleEntity == null) {
+ return ActionResult.success(MsgCode.FA002.get());
+ }
+ tableExampleEntity.setSign(entity.getSign());
+ tableExampleService.update(id, entity);
+ return ActionResult.success(MsgCode.SU004.get());
+ }
+
+ /**
+ * 琛岀紪杈�
+ *
+ * @param tableExampleRowUpForm 椤圭洰妯″瀷
+ * @param id 涓婚敭
+ * @return
+ */
+ @Operation(summary = "琛岀紪杈�")
+ @PutMapping("/{id}/Actions/RowsEdit")
+ @Parameter(name = "tableExampleRowUpForm", description = "椤圭洰妯″瀷",required = true)
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.redactTable")
+ public ActionResult<Object> rowEditing(@PathVariable("id") String id, @RequestBody @Valid TableExampleRowUpForm tableExampleRowUpForm) {
+ TableExampleEntity entity = JsonUtil.getJsonToBean(tableExampleRowUpForm, TableExampleEntity.class);
+ entity.setCostAmount(entity.getCostAmount() == null ? new BigDecimal("0") : entity.getCostAmount());
+ entity.setTunesAmount(entity.getTunesAmount() == null ? new BigDecimal("0") : entity.getTunesAmount());
+ entity.setProjectedIncome(entity.getProjectedIncome() == null ? new BigDecimal("0") : entity.getProjectedIncome());
+ entity.setId(id);
+ boolean falg = tableExampleService.rowEditing(entity);
+ if (!falg) {
+ return ActionResult.fail(MsgCode.FA002.get());
+ }
+ return ActionResult.success(MsgCode.SU004.get());
+ }
+
+ /**
+ * 鍙戦��
+ *
+ * @param postilSendForm 椤圭洰妯″瀷
+ * @param id 涓婚敭
+ * @return
+ */
+ @Operation(summary = "鍙戦�佹壒娉�")
+ @PostMapping("/{id}/Postil")
+ @Parameter(name = "postilSendForm", description = "椤圭洰妯″瀷",required = true)
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @SaCheckPermission("extend.tableDemo.postilTable")
+ public ActionResult<Object> sendPostil(@PathVariable("id") String id, @RequestBody PostilSendForm postilSendForm) {
+ TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
+ if (tableExampleEntity == null) {
+ return ActionResult.success(MsgCode.FA005.get());
+ }
+ UserInfo userInfo = UserProvider.getUser();
+ PostilModel model = new PostilModel();
+ model.setCreatorTime(DateUtil.getNow("+8"));
+ model.setText(postilSendForm.getText());
+ model.setUserId(userInfo != null ? userInfo.getUserName() + "/" + userInfo.getUserAccount() : "");
+ List<PostilModel> list = new ArrayList<>();
+ list.add(model);
+ if (!StringUtil.isEmpty(tableExampleEntity.getPostilJson())) {
+ list.addAll(JsonUtil.getJsonToList(tableExampleEntity.getPostilJson(), PostilModel.class));
+ }
+
+ String postilJson = JsonUtil.getObjectToString(list);
+ tableExampleEntity.setPostilJson(postilJson);
+ tableExampleEntity.setPostilCount(list.size());
+ tableExampleService.update(id, tableExampleEntity);
+ return ActionResult.success(MsgCode.SU012.get());
+ }
+
+
+ /**
+ * 鍙戦��
+ *
+ * @param id 涓婚敭鍊�
+ * @return
+ */
+ @Operation(summary = "鑾峰彇鎵规敞")
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @GetMapping("/{id}/Actions/Postil")
+ @SaCheckPermission("extend.tableDemo.postilTable")
+ public ActionResult<PostilInfoVO> getPostil(@PathVariable("id") String id) {
+ TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
+ if (tableExampleEntity == null) {
+ return ActionResult.success(MsgCode.FA012.get());
+ }
+ PostilInfoVO vo = new PostilInfoVO();
+ vo.setPostilJson(tableExampleEntity.getPostilJson());
+ return ActionResult.success(vo);
+ }
+
+ /**
+ * 鍒犻櫎鎵规敞
+ *
+ * @param id 涓婚敭鍊�
+ * @param index 琛屾暟
+ * @return
+ */
+ @Operation(summary = "鍒犻櫎鎵规敞")
+ @DeleteMapping("/{id}/Postil/{index}")
+ @Parameter(name = "id", description = "涓婚敭", required = true)
+ @Parameter(name = "index", description = "琛屾暟", required = true)
+ @SaCheckPermission("extend.tableDemo.postilTable")
+ public ActionResult<Object> deletePostil(@PathVariable("id") String id, @PathVariable("index") int index) {
+ TableExampleEntity tableExampleEntity = tableExampleService.getInfo(id);
+ if (tableExampleEntity == null) {
+ return ActionResult.success(MsgCode.FA003.get());
+ }
+ List<PostilModel> list = JsonUtil.getJsonToList(tableExampleEntity.getPostilJson(), PostilModel.class);
+ list.remove(index);
+ String postilJson = JsonUtil.getObjectToString(list);
+ tableExampleEntity.setPostilJson(postilJson);
+ tableExampleEntity.setPostilCount((list.size()));
+ tableExampleService.update(id, tableExampleEntity);
+ return ActionResult.success(MsgCode.SU003.get());
+ }
+}
--
Gitblit v1.8.0