|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.museum.controller.admin.museuminfo;
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
@@ -12,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDate;
|
|
@@ -19,7 +21,6 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
@Tag(name = "博物馆-标本库")
|
|
@@ -34,22 +35,32 @@ public class MuseumInfoController {
|
|
|
//TODO 判断标本编号是否重复
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "新增标本")
|
|
|
- public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
|
+ public CommonResult<Long> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
|
String sampleId = saveVO.getSampleId();
|
|
|
- List<MuseumInfoDO> result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
+ String result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
if (result != null) {
|
|
|
- return CommonResult.error(1, "标本编号已存在");
|
|
|
+ return CommonResult.error(200, "标本编号已存在");
|
|
|
} else {
|
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
|
}
|
|
|
}
|
|
|
- @PostMapping("/update")
|
|
|
+ @PutMapping("/update")
|
|
|
@Operation(summary = "更新标本")
|
|
|
- public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
|
|
|
- museumInfoService.updateMuseumInfo(saveVO);
|
|
|
- return CommonResult.success(true);
|
|
|
-
|
|
|
-
|
|
|
+ public CommonResult<Boolean> updateSampleMuseumInfo(@Valid @RequestBody MuseumInfoSaveVO saveVO){
|
|
|
+ museumInfoService.updateSampleMuseumInfo(saveVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+ @PutMapping("/outSample")
|
|
|
+ @Operation(summary = "标本出库")
|
|
|
+ public CommonResult<Boolean> outSampleMuseumInfo(@RequestParam("id")Integer id){
|
|
|
+ museumInfoService.outSampleMuseumInfo(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+ @PutMapping("/backSample")
|
|
|
+ @Operation(summary = "标本出库")
|
|
|
+ public CommonResult<Boolean> backSampleMuseumInfo(@RequestParam("id")Integer id){
|
|
|
+ museumInfoService.backSampleMuseumInfo(id);
|
|
|
+ return success(true);
|
|
|
}
|
|
|
|
|
|
//TODO 需要提供原因,调用更新方法
|
|
@@ -57,11 +68,9 @@ public class MuseumInfoController {
|
|
|
@Operation(summary = "删除标本")
|
|
|
public CommonResult<Boolean> deleteMuseumInfo(@RequestParam("id") Integer id,@RequestParam("reason") String reason){
|
|
|
museumInfoService.deleteMuseumInfo(id,reason);
|
|
|
-// result.put("删除原因:",);
|
|
|
return CommonResult.success(true);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@GetMapping("/get")
|
|
|
@Operation(summary = "id查找")
|
|
|
public CommonResult<MuseumInfoRespVO> selectMuseumInfo(@RequestParam("id") Integer id){
|
|
@@ -72,15 +81,15 @@ public class MuseumInfoController {
|
|
|
|
|
|
@GetMapping("/getSampleId")
|
|
|
@Operation(summary = "标本编号查寻")
|
|
|
- public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleId") String sampleId){
|
|
|
- List<MuseumInfoDO> result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
- List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
|
+ public CommonResult<MuseumInfoRespVO>selectMuseumInfoBySampleId(@RequestParam("sampleId") String sampleId){
|
|
|
+ MuseumInfoDO result = museumInfoService.selectMuseumInfoBySampleId(sampleId);
|
|
|
+ MuseumInfoRespVO result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
|
return CommonResult.success(result1);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getSampleType")
|
|
|
@Operation(summary = "标本类型查寻")
|
|
|
- public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
|
|
|
+ public CommonResult<List<MuseumInfoRespVO>> selectMuseumInfoBySampleType(@RequestParam("sampleType") Integer sampleType){
|
|
|
List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
|
|
|
List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
|
return CommonResult.success(result1);
|
|
@@ -115,10 +124,6 @@ public class MuseumInfoController {
|
|
|
map.put("陨石", count4);
|
|
|
return CommonResult.success(map);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@GetMapping("/joinSaveCount")
|
|
|
@Operation(summary = "标本出入库状态计数(每月)(入库)")
|
|
|
public CommonResult<List<MuseuminfoMonthSaveVO>> getJoinSave() {
|
|
@@ -147,16 +152,26 @@ public class MuseumInfoController {
|
|
|
public CommonResult<List<MuseuminfoMonthSaveVO>> getOutSave() {
|
|
|
LocalDate date = LocalDate.now();
|
|
|
int currentYear =date.getYear();
|
|
|
+
|
|
|
List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
for (int month = 1 ; month <= 12 ; month++) {
|
|
|
-
|
|
|
- Integer number =museumInfoService.MuseumInfoBySaveOut(month,currentYear);
|
|
|
+ int sample_number =0;
|
|
|
+ List<String> number =museumInfoService.MuseumInfoBySaveOut(month,currentYear);
|
|
|
MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
re.setMonth(month);
|
|
|
+
|
|
|
if (number == null) {
|
|
|
re.setCount(0);
|
|
|
}else {
|
|
|
- re.setCount(number);
|
|
|
+ for (String numberStr : number) {
|
|
|
+ // 去除方括号
|
|
|
+ String processedStr = numberStr.replaceAll("\\[|\\]","");
|
|
|
+ // 按逗号分割元素
|
|
|
+ String[] groupElements = processedStr.split(",");
|
|
|
+ // 累加元素数量(每个元素为一组)
|
|
|
+ sample_number += groupElements.length;
|
|
|
+ }
|
|
|
+ re.setCount(sample_number);
|
|
|
}
|
|
|
result.add(re);
|
|
|
}
|