|
@@ -8,11 +8,14 @@ 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;
|
|
@@ -33,14 +36,14 @@ public class MuseumInfoController {
|
|
@Operation(summary = "新增标本")
|
|
@Operation(summary = "新增标本")
|
|
public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
|
|
String sampleId = saveVO.getSampleId();
|
|
String sampleId = saveVO.getSampleId();
|
|
- MuseumInfoDO result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
|
|
|
+ List<MuseumInfoDO> result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
if (result != null) {
|
|
if (result != null) {
|
|
return CommonResult.error(1, "标本编号已存在");
|
|
return CommonResult.error(1, "标本编号已存在");
|
|
} else {
|
|
} else {
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ @PostMapping("/update")
|
|
@Operation(summary = "更新标本")
|
|
@Operation(summary = "更新标本")
|
|
public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
|
|
public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
|
|
museumInfoService.updateMuseumInfo(saveVO);
|
|
museumInfoService.updateMuseumInfo(saveVO);
|
|
@@ -67,14 +70,23 @@ public class MuseumInfoController {
|
|
return CommonResult.success(result1);
|
|
return CommonResult.success(result1);
|
|
}
|
|
}
|
|
|
|
|
|
- @GetMapping("/selectMuseumInfoList")
|
|
|
|
- @Operation(summary = "标本类型查找")
|
|
|
|
|
|
+ @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);
|
|
|
|
+ return CommonResult.success(result1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getSampleType")
|
|
|
|
+ @Operation(summary = "标本类型查寻")
|
|
public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
|
|
public CommonResult<List<MuseumInfoRespVO>> getMuseumInfoList(@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){
|
|
@@ -90,10 +102,18 @@ public class MuseumInfoController {
|
|
//
|
|
//
|
|
@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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -101,36 +121,74 @@ public class MuseumInfoController {
|
|
|
|
|
|
@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++) {
|
|
|
|
+
|
|
|
|
+ Integer number =museumInfoService.MuseumInfoBySaveOut(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("/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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|