|
@@ -1,5 +1,6 @@
|
|
package cn.iocoder.yudao.module.museum.controller.admin.museuminfo;
|
|
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.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
@@ -8,15 +9,18 @@ import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
|
|
import cn.iocoder.yudao.module.museum.service.museuminfo.MuseumInfoService;
|
|
import cn.iocoder.yudao.module.museum.service.museuminfo.MuseumInfoService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
@Tag(name = "博物馆-标本库")
|
|
@Tag(name = "博物馆-标本库")
|
|
@@ -31,22 +35,32 @@ public class MuseumInfoController {
|
|
//TODO 判断标本编号是否重复
|
|
//TODO 判断标本编号是否重复
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "新增标本")
|
|
@Operation(summary = "新增标本")
|
|
- public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
|
|
|
|
+ public CommonResult<Long> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
String sampleId = saveVO.getSampleId();
|
|
String sampleId = saveVO.getSampleId();
|
|
- MuseumInfoDO result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
|
|
|
+ String result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
if (result != null) {
|
|
if (result != null) {
|
|
- return CommonResult.error(1, "标本编号已存在");
|
|
|
|
|
|
+ return CommonResult.error(200, "标本编号已存在");
|
|
} else {
|
|
} else {
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ @PutMapping("/update")
|
|
@Operation(summary = "更新标本")
|
|
@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 需要提供原因,调用更新方法
|
|
//TODO 需要提供原因,调用更新方法
|
|
@@ -54,11 +68,9 @@ public class MuseumInfoController {
|
|
@Operation(summary = "删除标本")
|
|
@Operation(summary = "删除标本")
|
|
public CommonResult<Boolean> deleteMuseumInfo(@RequestParam("id") Integer id,@RequestParam("reason") String reason){
|
|
public CommonResult<Boolean> deleteMuseumInfo(@RequestParam("id") Integer id,@RequestParam("reason") String reason){
|
|
museumInfoService.deleteMuseumInfo(id,reason);
|
|
museumInfoService.deleteMuseumInfo(id,reason);
|
|
-// result.put("删除原因:",);
|
|
|
|
return CommonResult.success(true);
|
|
return CommonResult.success(true);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
@Operation(summary = "id查找")
|
|
@Operation(summary = "id查找")
|
|
public CommonResult<MuseumInfoRespVO> selectMuseumInfo(@RequestParam("id") Integer id){
|
|
public CommonResult<MuseumInfoRespVO> selectMuseumInfo(@RequestParam("id") Integer id){
|
|
@@ -67,14 +79,23 @@ public class MuseumInfoController {
|
|
return CommonResult.success(result1);
|
|
return CommonResult.success(result1);
|
|
}
|
|
}
|
|
|
|
|
|
- @GetMapping("/selectMuseumInfoList")
|
|
|
|
- @Operation(summary = "标本类型查找")
|
|
|
|
- public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
|
|
|
|
|
|
+ @GetMapping("/getSampleId")
|
|
|
|
+ @Operation(summary = "标本编号查寻")
|
|
|
|
+ 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>> selectMuseumInfoBySampleType(@RequestParam("sampleType") Integer sampleType){
|
|
List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
|
|
List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
|
|
List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
return CommonResult.success(result1);
|
|
return CommonResult.success(result1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@Operation(summary = "获取分页")
|
|
@Operation(summary = "获取分页")
|
|
public CommonResult<PageResult<MuseumInfoPageReqVO>> getPage(@Valid MuseumInfoPageReqVO pageReqVO){
|
|
public CommonResult<PageResult<MuseumInfoPageReqVO>> getPage(@Valid MuseumInfoPageReqVO pageReqVO){
|
|
@@ -87,50 +108,162 @@ public class MuseumInfoController {
|
|
// TODO 1.2.3.代表哪种标本类型
|
|
// TODO 1.2.3.代表哪种标本类型
|
|
// 返回某种标本类型的List数组
|
|
// 返回某种标本类型的List数组
|
|
// Integer
|
|
// Integer
|
|
-//
|
|
|
|
|
|
+
|
|
@GetMapping("/sampleTypeCount")
|
|
@GetMapping("/sampleTypeCount")
|
|
@Operation(summary = "标本类型计数")
|
|
@Operation(summary = "标本类型计数")
|
|
- public CommonResult<List<MuseuminfoTypeVO>> getMap(@RequestParam("sampleType") Integer sampleType) {
|
|
|
|
- List<MuseuminfoTypeVO> result = museumInfoService.MuseumInfoBySampleType(sampleType);
|
|
|
|
|
|
+ public CommonResult<Map<String,Integer>> getMap() {
|
|
|
|
+ Integer count1 = museumInfoService.MuseumInfoBySampleType(1);
|
|
|
|
+ Integer count2 = museumInfoService.MuseumInfoBySampleType(2);
|
|
|
|
+ Integer count3 = museumInfoService.MuseumInfoBySampleType(3);
|
|
|
|
+ Integer count4 = museumInfoService.MuseumInfoBySampleType(4);
|
|
// 标本类型:矿石-1 岩石-2 矿物-3 陨石-4>
|
|
// 标本类型:矿石-1 岩石-2 矿物-3 陨石-4>
|
|
- return CommonResult.success(result);
|
|
|
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
|
+ map.put("矿石", count1);
|
|
|
|
+ map.put("岩石", count2);
|
|
|
|
+ map.put("矿物", count3);
|
|
|
|
+ map.put("陨石", count4);
|
|
|
|
+ return CommonResult.success(map);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@GetMapping("/joinSaveCount")
|
|
@GetMapping("/joinSaveCount")
|
|
@Operation(summary = "标本出入库状态计数(每月)(入库)")
|
|
@Operation(summary = "标本出入库状态计数(每月)(入库)")
|
|
- public CommonResult<List<MuseuminfoMonthSaveVO>> getJoinSave(@RequestParam("save") Integer save) {
|
|
|
|
- List<MuseuminfoMonthSaveVO> result1 = museumInfoService.MuseumInfoBySaveJoin(save);
|
|
|
|
|
|
+ public CommonResult<List<MuseuminfoMonthSaveVO>> getJoinSave() {
|
|
// 状态:在库-1 出库-0
|
|
// 状态:在库-1 出库-0
|
|
// 构造 12 个月的数据,确保每个月都有数据(即使为 0)
|
|
// 构造 12 个月的数据,确保每个月都有数据(即使为 0)
|
|
-// List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
|
-// for (int month = 1 ; month <= 1 ; month++){
|
|
|
|
-// String monthStr = String.format("%d-%2d",save, month);
|
|
|
|
-// Optional<MuseuminfoMonthSaveVO> found = MonthSave.stream()
|
|
|
|
-// filter(f ->f.getMonth().equals(monthStr))
|
|
|
|
-// .findFirst();
|
|
|
|
-// MuseuminfoMonthSaveVO vo = new MuseuminfoMonthSaveVO();
|
|
|
|
-// vo.setMonth(monthStr);
|
|
|
|
-// vo.setCount(found.map(MuseuminfoMonthSaveVO::getSave).orElse( other: 0)).
|
|
|
|
-// result.add(vo);
|
|
|
|
- return CommonResult.success(result1);
|
|
|
|
|
|
+ List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
|
+ int currentYear =date.getYear();
|
|
|
|
+ for (int month = 1 ; month <= 12 ; month++) {
|
|
|
|
+
|
|
|
|
+ Integer number =museumInfoService.MuseumInfoBySaveJoin(month,currentYear);
|
|
|
|
+ MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
|
+ re.setMonth(month);
|
|
|
|
+ if (number == null) {
|
|
|
|
+ re.setCount(0);
|
|
|
|
+ }else {
|
|
|
|
+ re.setCount(number);
|
|
|
|
+ }
|
|
|
|
+ result.add(re);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/outSaveCount")
|
|
@GetMapping("/outSaveCount")
|
|
@Operation(summary = "标本出入库状态计数(每月)(出库)")
|
|
@Operation(summary = "标本出入库状态计数(每月)(出库)")
|
|
- public CommonResult<List<MuseuminfoMonthSaveVO>> getOutSave(@RequestParam("save") Integer save) {
|
|
|
|
- List<MuseuminfoMonthSaveVO> result1 = museumInfoService.MuseumInfoBySaveOut(save);
|
|
|
|
- return CommonResult.success(result1);
|
|
|
|
|
|
+ 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++) {
|
|
|
|
+ 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 {
|
|
|
|
+ for (String numberStr : number) {
|
|
|
|
+
|
|
|
|
+ String[] groupElements = numberStr.split(",");
|
|
|
|
+ // 累加元素数量(每个元素为一组)
|
|
|
|
+ sample_number += groupElements.length;
|
|
|
|
+ }
|
|
|
|
+ re.setCount(sample_number);
|
|
|
|
+ }
|
|
|
|
+ result.add(re);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/backSaveCount")
|
|
|
|
+ @Operation(summary = "标本出入库状态计数(每月)(回库)")
|
|
|
|
+ public CommonResult<List<MuseuminfoMonthSaveVO>> getBackSave() {
|
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
|
+ int currentYear =date.getYear();
|
|
|
|
+
|
|
|
|
+ List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
|
+ for (int month = 1 ; month <= 12 ; month++) {
|
|
|
|
+ int sample_number = countSampleNumbers(museumInfoService.MuseumInfoBySaveBack(month,currentYear));
|
|
|
|
+ MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
|
+ re.setMonth(month);
|
|
|
|
+ re.setCount(sample_number);
|
|
|
|
+ result.add(re);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/yearCount")
|
|
|
|
+ @Operation(summary = "历年标本数量统计")
|
|
|
|
+ public CommonResult<List<Map<Integer,Object>>> getYearSampleCount() {
|
|
|
|
+ List<Map<Integer, Object>> result = new ArrayList<>();
|
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
|
+ int currentYear = date.getYear();
|
|
|
|
+ int year1 = currentYear - 2;
|
|
|
|
+ for (int year = currentYear; year >= year1; year--) {
|
|
|
|
+
|
|
|
|
+ Integer number1 = museumInfoService.MuseumInfoYearJoin(year);
|
|
|
|
+ int sample_number2 = countSampleNumbers(museumInfoService.MuseumInfoYearOutBack(1, year));
|
|
|
|
+ int sample_number3 = countSampleNumbers(museumInfoService.MuseumInfoYearOutBack(0, year));
|
|
|
|
+ Map<Integer,Object> map = new HashMap<>();
|
|
|
|
+ Map<String, Integer> innerMap = new HashMap<>();
|
|
|
|
+ innerMap.put("入库", number1);
|
|
|
|
+ innerMap.put("回库", sample_number2);
|
|
|
|
+ innerMap.put("出库", sample_number3);
|
|
|
|
+ map.put(year,innerMap);
|
|
|
|
+ result.add(map);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 统计样本数量
|
|
|
|
+ * @param number 包含样本信息的列表
|
|
|
|
+ * @return 样本数量
|
|
|
|
+ */
|
|
|
|
+ private int countSampleNumbers(List<String> number) {
|
|
|
|
+ if (number == null) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (String numberStr : number) {
|
|
|
|
+
|
|
|
|
+ String processedStr = numberStr.replaceAll("\\[|\\]","");
|
|
|
|
+ // 按逗号分割元素
|
|
|
|
+ String[] groupElements = processedStr.split(",");
|
|
|
|
+
|
|
|
|
+ count += groupElements.length;
|
|
|
|
+ }
|
|
|
|
+ return count;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@GetMapping("/originCount")
|
|
@GetMapping("/originCount")
|
|
@Operation(summary = "标本来源计数")
|
|
@Operation(summary = "标本来源计数")
|
|
- public CommonResult<List<MuseuminfoOriginVO>> getOrigin(@RequestParam("origin") Integer origin){
|
|
|
|
- List<MuseuminfoOriginVO> result1 =museumInfoService.MuseumInfoByOrigin(origin);
|
|
|
|
|
|
+ public CommonResult<List<Map<Integer,Object>>> getOrigin(){
|
|
// 来源:采购-1 捐赠-2 采集-3 其他-4
|
|
// 来源:采购-1 捐赠-2 采集-3 其他-4
|
|
- return CommonResult.success(result1);
|
|
|
|
|
|
+
|
|
|
|
+ List<Map<Integer,Object>> result = new ArrayList<>();
|
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
|
+ int currentYear =date.getYear();
|
|
|
|
+ int year1 =currentYear-2;
|
|
|
|
+ for (int year =currentYear ; year>=year1 ; year--) {
|
|
|
|
+
|
|
|
|
+ Integer number1 = museumInfoService.MuseumInfoByOrigin(year,1);
|
|
|
|
+ Integer number2 = museumInfoService.MuseumInfoByOrigin(year,2);
|
|
|
|
+ Integer number3 = museumInfoService.MuseumInfoByOrigin(year,3);
|
|
|
|
+ Integer number4 = museumInfoService.MuseumInfoByOrigin(year,4);
|
|
|
|
+
|
|
|
|
+ Map<Integer,Object> map = new HashMap<>();
|
|
|
|
+ Map<String, Integer> innerMap = new HashMap<>();
|
|
|
|
+ innerMap.put("采购", number1);
|
|
|
|
+ innerMap.put("捐赠", number2);
|
|
|
|
+ innerMap.put("采集", number3);
|
|
|
|
+ innerMap.put("其他", number4);
|
|
|
|
+ map.put(year,innerMap);
|
|
|
|
+ result.add(map);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|