|
@@ -5,20 +5,28 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.museum.controller.admin.museumflow.vo.*;
|
|
|
import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoPageReqVO;
|
|
|
+
|
|
|
import cn.iocoder.yudao.module.museum.dal.database.museumflow.MuseumFlowDO;
|
|
|
import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
|
|
|
-import cn.iocoder.yudao.module.museum.dal.mysql.museumflow.MuseumFlowMapper;
|
|
|
import cn.iocoder.yudao.module.museum.service.museumflow.MuseumFlowService;
|
|
|
import cn.iocoder.yudao.module.museum.service.museuminfo.MuseumInfoService;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
|
|
|
+import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
|
|
+import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.*;
|
|
|
+
|
|
|
+
|
|
|
@Tag(name = "博物馆-出回库管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/museum/flow")
|
|
@@ -27,6 +35,13 @@ public class MuseumFlowController {
|
|
|
@Resource
|
|
|
private MuseumFlowService museumFlowService;
|
|
|
private MuseumInfoService museumInfoService;
|
|
|
+ @Resource
|
|
|
+ private RoleService roleService;
|
|
|
+ @Resource
|
|
|
+ private UserRoleMapper userRoleMapper;
|
|
|
+ @Resource
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "新增表单")
|
|
@@ -36,351 +51,336 @@ public class MuseumFlowController {
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新表单")
|
|
|
- public CommonResult<Boolean> updateMuseumFlow(@RequestBody MuseumFlowSaveVO saveVO){
|
|
|
- museumFlowService.updateMuseumFlow(saveVO);
|
|
|
- return CommonResult.success(true);
|
|
|
+ public CommonResult<Boolean> updateMuseumFlow(@RequestBody MuseumFlowSaveVO saveVO) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ museumFlowService.updateMuseumFlow(saveVO);
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此权限");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/delete")
|
|
|
@Operation(summary = "删除表单")
|
|
|
- public CommonResult<Boolean> deleteMuseumFlow(@RequestParam("id") Integer id){
|
|
|
- museumFlowService.deleteMuseumFlow(id);
|
|
|
- return CommonResult.success(true);
|
|
|
+ public CommonResult<Boolean> deleteMuseumFlow(@RequestParam("id") Integer id) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ museumFlowService.deleteMuseumFlow(id);
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此权限");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
@Operation(summary = "查找表单")
|
|
|
- public CommonResult<MuseumFlowRespVO> getMuseumFlow(@RequestParam("id") Integer id){
|
|
|
+ public CommonResult<MuseumFlowRespVO> getMuseumFlow(@RequestParam("id") Integer id) {
|
|
|
MuseumFlowDO result = museumFlowService.selectMuseumFlow(id);
|
|
|
- MuseumFlowRespVO result1 = BeanUtils.toBean(result,MuseumFlowRespVO.class);
|
|
|
+ MuseumFlowRespVO result1 = BeanUtils.toBean(result, MuseumFlowRespVO.class);
|
|
|
return CommonResult.success(result1);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/get-info")
|
|
|
+ @Operation(summary = "查找标本信息")
|
|
|
+ public CommonResult<List<MuseumFlowInfoVO>> getMuseumInfo(@RequestParam("number") List<String> number) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ List<MuseumFlowInfoVO> informationList = new ArrayList<>();
|
|
|
+ for (String number1 : number) {
|
|
|
+ MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(number1);
|
|
|
+ if (result == null) {
|
|
|
+ return CommonResult.error(200, "标本不存在");
|
|
|
+ } else {
|
|
|
+ MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number1);
|
|
|
+ MuseumFlowInfoVO event1 = BeanUtils.toBean(event, MuseumFlowInfoVO.class);
|
|
|
+ List<MuseumInfoDO> information = new ArrayList<>();
|
|
|
+ information.add(result);
|
|
|
+ event1.setMuseumInfoDO(information);
|
|
|
+ informationList.add(event1);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return CommonResult.success(informationList);
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此权限");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/menId")
|
|
|
+ @Operation(summary = "查询身份信息")
|
|
|
+ public CommonResult<Boolean> hasAnyRoles() {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "无权限");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/outbound")
|
|
|
@Operation(summary = "添加出库单")
|
|
|
- public CommonResult<Boolean> createMuseumFlowOutbound(@RequestBody MuseumFlowSaveVO saveVO) {
|
|
|
- String sample_id = saveVO.getNumber();
|
|
|
- String number = saveVO.getNumber();
|
|
|
- MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
- MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number);
|
|
|
+ public CommonResult<Boolean> createMuseumFlowOutbound(@RequestBody MuseumFlowSaveVO saveVO) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ String sample_id = saveVO.getNumber();
|
|
|
+ String number = saveVO.getNumber();
|
|
|
+ MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
+ MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number);
|
|
|
+ AdminUserDO userList = museumFlowService.selectAdminUserDOById(UserId);
|
|
|
// Save中 1现为未出库或已回库,0为已出库
|
|
|
// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
- //TODO 你这里上面获取了result和event的值再判断他为空,怎么可能为空 ,所以如果为空的话,上面两句就直接报错了
|
|
|
- if (result == null) {
|
|
|
- return CommonResult.error(200, "标本不存在");
|
|
|
- }
|
|
|
- else{
|
|
|
- int Save = result.getSave();
|
|
|
- if (Save == 1) {
|
|
|
- if (event != null) {
|
|
|
+ if (result == null) {
|
|
|
+ return CommonResult.error(200, "标本不存在");
|
|
|
+ } else {
|
|
|
+ if (event == null) {
|
|
|
+ int Save = result.getSave();
|
|
|
+ if (Save == 1) {
|
|
|
+ LocalDateTime applyTime = LocalDateTime.now();
|
|
|
+ saveVO.setApplyTime(applyTime);
|
|
|
+ String name = result.getChineseName();
|
|
|
+ saveVO.setSampleName(name);//标本名称
|
|
|
+ museumFlowService.createMuseumFlow(saveVO);
|
|
|
+ museumFlowService.updateMuseumFlowStateOutbound2(saveVO);//状态2 审批中
|
|
|
+ return CommonResult.success(true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
int State = event.getState();
|
|
|
- if (State == 2) {
|
|
|
- return CommonResult.error(200, "标本正在审批");
|
|
|
+ if (State == 0) {
|
|
|
+ return CommonResult.error(200, "标本已回库");
|
|
|
+ } else if (State == 1) {
|
|
|
+ return CommonResult.error(200, "标本已出库");
|
|
|
+ } else if (State == 2) {
|
|
|
+ return CommonResult.error(200, "标本正在审批");
|
|
|
} else if (State == 3) {
|
|
|
return CommonResult.error(200, "标本审批已通过");
|
|
|
} else if (State == 4) {
|
|
|
return CommonResult.error(200, "标本已审批已驳回");
|
|
|
}
|
|
|
- } else {
|
|
|
- String name = result.getChineseName();
|
|
|
- saveVO.setSampleName(name);
|
|
|
- museumFlowService.createMuseumFlow(saveVO);
|
|
|
- museumFlowService.updateMuseumFlowStateOutbound2(saveVO);
|
|
|
- return CommonResult.success(true);
|
|
|
+ return CommonResult.error(200, "标本信息已存放在出入库的数据库中");
|
|
|
}
|
|
|
- } else {
|
|
|
- return CommonResult.error(200, "标本不在库中");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此操作权限");
|
|
|
}
|
|
|
return CommonResult.success(true);
|
|
|
-// List<String> sample_ids = saveVO.getNumber();
|
|
|
-// List<String> errorList = new ArrayList<>();
|
|
|
-// List<String> sample_names = new ArrayList<>();
|
|
|
-////// Save中 1现为未出库或已回库,0为已出库
|
|
|
-////// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
-// for (String sample_id : sample_ids) {
|
|
|
-// MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
-// if (result == null) {
|
|
|
-// errorList.add(sample_id+"标本不存在");
|
|
|
-// return CommonResult.error(200, "标本不存在");
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// int save = result.getSave();
|
|
|
-// String name = result.getChineseName();
|
|
|
-// if (save == 0) {
|
|
|
-// errorList.add(sample_id+"标本不在库中");
|
|
|
-// return CommonResult.error(200, "标本不在库中");
|
|
|
-// }else {
|
|
|
-// sample_names.add(name);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (errorList.isEmpty()) {
|
|
|
-// saveVO.setSampleName(sample_names);//设置标本名称
|
|
|
-// museumFlowService.createMuseumFlow(saveVO);//创建表单
|
|
|
-// museumFlowService.updateMuseumFlowStateOutbound2(saveVO);//更改标本状态为出库
|
|
|
-//
|
|
|
-//// museumFlowService.selectPageS(respVO);
|
|
|
-// return CommonResult.success(true);
|
|
|
-// }else {
|
|
|
-// System.out.println(errorList);
|
|
|
-// return CommonResult.error(200, "标本存在错误");
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
@PostMapping("outboundEnd")
|
|
|
@Operation(summary = "出库完成功能")
|
|
|
- public CommonResult<Boolean> createMuseumFlowOutboundEnd(@RequestBody MuseumFlowReviewVO reviewVO){
|
|
|
- List<String> sample_ids = reviewVO.getNumber();
|
|
|
- List<String> errorList = new ArrayList<>();
|
|
|
- List<String> sample_names = new ArrayList<>();
|
|
|
+ public CommonResult<Boolean> createMuseumFlowOutboundEnd(@RequestBody MuseumFlowReviewVO reviewVO) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ List<String> sample_ids = reviewVO.getNumber();
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
+ List<String> sample_names = new ArrayList<>();
|
|
|
//// Save中 1现为未出库或已回库,0为已出库
|
|
|
//// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
- for (String sample_id : sample_ids) {
|
|
|
- MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
- MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
- String name = result.getChineseName();
|
|
|
- if (event != null) {
|
|
|
- int State = event.getState();
|
|
|
- if (State == 2) {
|
|
|
- errorList.add(sample_id+"标本正在审批");
|
|
|
- }else if (State == 3) {
|
|
|
- sample_names.add(name);
|
|
|
- }else if (State == 4) {
|
|
|
- errorList.add(sample_id+"标本审批已驳回");
|
|
|
+ for (String sample_id : sample_ids) {
|
|
|
+ MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
+ if (event != null) {
|
|
|
+ int State = event.getState();
|
|
|
+ if (State == 1) {
|
|
|
+ errorList.add(sample_id + "标本已出库");
|
|
|
+ } else if (State == 2) {
|
|
|
+ errorList.add(sample_id + "标本正在审批");
|
|
|
+ } else if (State == 3) {
|
|
|
+ AdminUserDO userList = museumFlowService.selectAdminUserDOById(UserId);
|
|
|
+ String name = event.getSampleName();
|
|
|
+ sample_names.add(name);
|
|
|
+ String reviewPerson = userList.getNickname();
|
|
|
+ reviewVO.setReviewPerson(reviewPerson);
|
|
|
+ } else if (State == 4) {
|
|
|
+ errorList.add(sample_id + "标本审批已驳回");
|
|
|
+ } else if (State == 0) {
|
|
|
+ errorList.add(sample_id + "标本审批已回库");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ errorList.add(sample_id + "标本未申请出库");
|
|
|
}
|
|
|
- }else {
|
|
|
- errorList.add(sample_id+"标本未申请出库");
|
|
|
}
|
|
|
- }
|
|
|
- if (errorList.isEmpty()) {
|
|
|
- for (String sample_id : sample_ids) {
|
|
|
- String number = sample_id;
|
|
|
- museumFlowService.updateMuseumFlowStateOutbound1(number);
|
|
|
+ if (errorList.isEmpty()) {
|
|
|
+ for (String sample_id : sample_ids) {
|
|
|
+ museumFlowService.updateMuseumFlowStateOutbound1(sample_id);
|
|
|
+ museumFlowService.updateMuseumFlowSave0(sample_id);
|
|
|
+ }
|
|
|
+ LocalDateTime outboundTime = LocalDateTime.now();
|
|
|
+ reviewVO.setOutboundTime(outboundTime);
|
|
|
+ reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
+ reviewVO.setState(1);
|
|
|
+ museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ System.out.println(errorList);
|
|
|
+ return CommonResult.error(200, errorList.toString());
|
|
|
}
|
|
|
- reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
- museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
- museumFlowService.updateMuseumFlowStateOutbounds1(reviewVO);//更改标本状态为出库
|
|
|
-
|
|
|
-// museumFlowService.selectPageS(respVO);
|
|
|
- return CommonResult.success(true);
|
|
|
- }else {
|
|
|
- System.out.println(errorList);
|
|
|
- return CommonResult.error(200, errorList.toString());
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此操作权限");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@GetMapping("/selectPageS")
|
|
|
@Operation(summary = "获取关于标本信息的分页")
|
|
|
- public PageResult<MuseumInfoDO> selectPageS(@Valid MuseumInfoPageReqVO pageVO){
|
|
|
- return museumInfoService.getMuseumInfoPage(pageVO);
|
|
|
+ public PageResult<MuseumInfoDO> selectPageS(@Valid MuseumInfoPageReqVO pageVO) {
|
|
|
+ return museumInfoService.getMuseumInfoPage(pageVO);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/pagePerson")
|
|
|
@Operation(summary = "获取关于出库员的分页")
|
|
|
- public PageResult<MuseumFlowDO> selectMuseumFlowOutboundPerson(@Valid MuseumFlowPageVO pageVO){
|
|
|
- return museumFlowService.selectPageMuseumFlowOutboundPerson(pageVO);
|
|
|
+ public PageResult<MuseumFlowDO> selectMuseumFlowOutboundPerson(@Valid MuseumFlowPageVO pageVO) {
|
|
|
+ return museumFlowService.selectPageMuseumFlowOutboundPerson(pageVO);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/review")
|
|
|
@Operation(summary = "通过的审批单")
|
|
|
public CommonResult<Boolean> createMuseumFlowReview(@RequestBody MuseumFlowReviewVO reviewVO) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
List<String> sample_ids = reviewVO.getNumber();
|
|
|
List<String> errorList = new ArrayList<>();
|
|
|
List<String> sample_names = new ArrayList<>();
|
|
|
//// Save中 1现为未出库或已回库,0为已出库
|
|
|
//// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
- for (String sample_id : sample_ids) {
|
|
|
- MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
- MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
- String name = result.getChineseName();
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "leader")) {
|
|
|
+ for (String sample_id : sample_ids) {
|
|
|
+ MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
+ MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
+ String name = result.getChineseName();
|
|
|
if (event != null) {
|
|
|
int State = event.getState();
|
|
|
if (State == 2) {
|
|
|
sample_names.add(name);
|
|
|
- }else if (State == 3) {
|
|
|
- errorList.add(sample_id+"标本审批已通过");
|
|
|
- }else if (State == 4) {
|
|
|
- errorList.add(sample_id+"标本审批已驳回");
|
|
|
+ } else if (State == 3) {
|
|
|
+ errorList.add(sample_id + "标本审批已通过");
|
|
|
+ } else if (State == 4) {
|
|
|
+ errorList.add(sample_id + "标本审批已驳回");
|
|
|
+ } else {
|
|
|
+ if (State == 0) {
|
|
|
+ errorList.add(sample_id + "标本审批已回库");
|
|
|
+ } else if (State == 1) {
|
|
|
+ errorList.add(sample_id + "标本已出库");
|
|
|
+ }
|
|
|
}
|
|
|
- }else {
|
|
|
- errorList.add(sample_id+"标本未申请出库");
|
|
|
+ } else {
|
|
|
+ errorList.add(sample_id + "标本未申请出库");
|
|
|
}
|
|
|
- }
|
|
|
- if (errorList.isEmpty()) {
|
|
|
- for (String sample_id : sample_ids) {
|
|
|
- String number = sample_id;
|
|
|
- museumFlowService.updateMuseumFlowStateReview3(number);
|
|
|
}
|
|
|
- reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
- museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
- museumFlowService.updateMuseumFlowStateReviews3(reviewVO);//更改标本状态为出库
|
|
|
-
|
|
|
-// museumFlowService.selectPageS(respVO);
|
|
|
- return CommonResult.success(true);
|
|
|
- }else {
|
|
|
- System.out.println(errorList);
|
|
|
- return CommonResult.error(200, errorList.toString());
|
|
|
+ if (errorList.isEmpty()) {
|
|
|
+ for (String sample_id : sample_ids) {
|
|
|
+ museumFlowService.updateMuseumFlowStateReview3(sample_id);
|
|
|
+ }
|
|
|
+ AdminUserDO userList = museumFlowService.selectAdminUserDOById(UserId);
|
|
|
+ String reviewPerson = userList.getNickname();
|
|
|
+ reviewVO.setReviewPerson(reviewPerson);
|
|
|
+ reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
+ LocalDateTime reviewTime = LocalDateTime.now();
|
|
|
+ reviewVO.setReviewTime(reviewTime);
|
|
|
+ museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
+ museumFlowService.updateMuseumFlowStateReviews3(reviewVO);//更改标本状态为3 审批通过
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ System.out.println(errorList);
|
|
|
+ return CommonResult.error(200, errorList.toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此操作权限");
|
|
|
}
|
|
|
}
|
|
|
-// String sample_id = reviewVO.getNumber();
|
|
|
-// String number = reviewVO.getNumber();
|
|
|
-// MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
-// MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number);
|
|
|
-//
|
|
|
-// int Save = result.getSave();
|
|
|
-// int State = event.getState();
|
|
|
-//// Save中 0现为未出库或已回库,1为已出库
|
|
|
-//// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
-// //TODO 你这里上面获取了result和event的值再判断他为空,怎么可能为空 ,所以如果为空的话,上面两句就直接报错了
|
|
|
-// if (result == null) {
|
|
|
-// return CommonResult.error(200, "样品不存在");
|
|
|
-// } else if (event == null) {
|
|
|
-// return CommonResult.error(200, "样品在出入库的库中不存在");
|
|
|
-// }
|
|
|
-// else if (Save == 0) {
|
|
|
-// return CommonResult.error(200, "样品并未申请出库");
|
|
|
-// } else if (Save == 1) {
|
|
|
-// if (State == 2) {
|
|
|
-// museumFlowService.createMuseumFlowReview(reviewVO);
|
|
|
-// museumFlowService.updateMuseumFlowStateReview3(reviewVO);
|
|
|
-// return CommonResult.success(true);
|
|
|
-// } else if (State == 3) {
|
|
|
-// return CommonResult.error(200, "样品已审批通过");
|
|
|
-// } else if (State == 4) {
|
|
|
-// return CommonResult.error(200, "样品审批已被驳回");
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// return CommonResult.error(200, "样品已审批通过并出库");
|
|
|
-// }
|
|
|
|
|
|
@PostMapping("/reject")
|
|
|
@Operation(summary = "新增驳回的审批单")
|
|
|
public CommonResult<Boolean> createMuseumFlowReject(@RequestBody MuseumFlowReviewVO reviewVO) {
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
List<String> sample_ids = reviewVO.getNumber();
|
|
|
List<String> errorList = new ArrayList<>();
|
|
|
List<String> sample_names = new ArrayList<>();
|
|
|
//// Save中 1现为未出库或已回库,0为已出库
|
|
|
//// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
- for (String sample_id : sample_ids) {
|
|
|
- MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
- MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
- String name = result.getChineseName();
|
|
|
- if (event != null) {
|
|
|
- int State = event.getState();
|
|
|
- if (State == 2) {
|
|
|
- sample_names.add(name);
|
|
|
- }else if (State == 3) {
|
|
|
- errorList.add(sample_id+"标本审批已通过");
|
|
|
- }else if (State == 4) {
|
|
|
- errorList.add(sample_id+"标本审批已驳回");
|
|
|
- }
|
|
|
- }else {
|
|
|
- errorList.add(sample_id+"标本未申请出库");
|
|
|
- }
|
|
|
- }
|
|
|
- if (errorList.isEmpty()) {
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "leader")) {
|
|
|
for (String sample_id : sample_ids) {
|
|
|
- String number = sample_id;
|
|
|
- museumFlowService.updateMuseumFlowStateReview4(number);
|
|
|
+ MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
+ MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(sample_id);
|
|
|
+ String name = result.getChineseName();
|
|
|
+ if (event != null) {
|
|
|
+ int State = event.getState();
|
|
|
+ if (State == 2) {
|
|
|
+ sample_names.add(name);
|
|
|
+ } else if (State == 3) {
|
|
|
+ errorList.add(sample_id + "标本审批已通过");
|
|
|
+ } else if (State == 4) {
|
|
|
+ errorList.add(sample_id + "标本审批已驳回");
|
|
|
+ } else {
|
|
|
+ if (State == 0) {
|
|
|
+ errorList.add(sample_id + "标本审批已回库");
|
|
|
+ } else if (State == 1) {
|
|
|
+ errorList.add(sample_id + "标本已出库");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ errorList.add(sample_id + "标本未申请出库");
|
|
|
+ }
|
|
|
}
|
|
|
- reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
- museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
- museumFlowService.updateMuseumFlowStateReviews4(reviewVO);//更改标本状态为出库
|
|
|
-
|
|
|
+ if (errorList.isEmpty()) {
|
|
|
+ for (String sample_id : sample_ids) {
|
|
|
+ museumFlowService.updateMuseumFlowStateReview4(sample_id);
|
|
|
+ }
|
|
|
+ AdminUserDO userList = museumFlowService.selectAdminUserDOById(UserId);
|
|
|
+ String reviewPerson = userList.getNickname();
|
|
|
+ reviewVO.setReviewPerson(reviewPerson);
|
|
|
+ reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
+ LocalDateTime reviewTime = LocalDateTime.now();
|
|
|
+ reviewVO.setReviewTime(reviewTime);
|
|
|
+ museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
+ museumFlowService.updateMuseumFlowStateReviews4(reviewVO);//更改标本状态为出库
|
|
|
// museumFlowService.selectPageS(respVO);
|
|
|
- return CommonResult.success(true);
|
|
|
- }else {
|
|
|
- System.out.println(errorList);
|
|
|
- return CommonResult.error(200, errorList.toString());
|
|
|
+ return CommonResult.success(true);
|
|
|
+ } else {
|
|
|
+ System.out.println(errorList);
|
|
|
+ return CommonResult.error(200, errorList.toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "您无此操作权限");
|
|
|
}
|
|
|
-// for (String sample_id : sample_ids) {
|
|
|
-// MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
-// if (result == null) {
|
|
|
-// errorList.add(sample_id+"标本不存在");
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// int save = result.getSave();
|
|
|
-// String name = result.getChineseName();
|
|
|
-// if (save == 0) {
|
|
|
-// errorList.add(sample_id+"标本不在库中");
|
|
|
-// }else {
|
|
|
-// sample_names.add(name);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (errorList.isEmpty()) {
|
|
|
-// reviewVO.setSampleName(sample_names);//设置标本名称
|
|
|
-// museumFlowService.createMuseumFlowReview(reviewVO);//创建表单
|
|
|
-// museumFlowService.updateMuseumFlowStateReview4(reviewVO);
|
|
|
-//// museumFlowService.selectPageS(respVO);
|
|
|
-// return CommonResult.success(true);
|
|
|
-// }else {
|
|
|
-// System.out.println(errorList);
|
|
|
-// return CommonResult.error(200, "标本存在错误");
|
|
|
-// }
|
|
|
-// String sample_id = reviewVO.getNumber();
|
|
|
-// String number = reviewVO.getNumber();
|
|
|
-// MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
-// MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number);
|
|
|
-// int Save = result.getSave();
|
|
|
-// int State = event.getState();
|
|
|
-//// Save中 0现为未出库或已回库,1为已出库
|
|
|
-//// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
-// if (result == null) {
|
|
|
-// return CommonResult.error(200, "样品不存在");
|
|
|
-// } else if (event == null) {
|
|
|
-// return CommonResult.error(200, "样品在出入库的库中不存在");
|
|
|
-// }
|
|
|
-// else if (Save == 1) {
|
|
|
-// return CommonResult.error(200, "样品已出库");
|
|
|
-// } else if (Save == 0) {
|
|
|
-// if (State == 2) {
|
|
|
-// museumFlowService.createMuseumFlowReview(reviewVO);
|
|
|
-// museumFlowService.updateMuseumFlowStateReview4(reviewVO);
|
|
|
-// return CommonResult.success(true);
|
|
|
-// } else if (State == 3) {
|
|
|
-// return CommonResult.error(200, "样品已审批通过");
|
|
|
-// } else if (State == 4) {
|
|
|
-// return CommonResult.error(200, "样品审批已被驳回");
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// return CommonResult.error(200, "样品已审批通过并出库");
|
|
|
-// }
|
|
|
-// return CommonResult.success(true);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/return")
|
|
|
- @Operation(summary = "新建回库单")
|
|
|
+ @Operation(summary = "回库功能")
|
|
|
public CommonResult<Boolean> createMuseumFlowReturn(@RequestBody MuseumFlowReturnVO returnVO) {
|
|
|
- String sample_id = returnVO.getNumber();
|
|
|
+ Long UserId = getLoginUserId();
|
|
|
String number = returnVO.getNumber();
|
|
|
- MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
+ String sample_id = returnVO.getNumber();
|
|
|
MuseumFlowDO event = museumFlowService.selectMuseumFlowNumber(number);
|
|
|
- int Save = result.getSave();
|
|
|
- int State = event.getState();
|
|
|
-// Save中 0现为未出库或已回库,1为已出库
|
|
|
+ MuseumInfoDO result = museumFlowService.selectMuseumFlowSampleId(sample_id);
|
|
|
+// Save中 1现为未出库或已回库,0为已出库
|
|
|
// State中 0现为未出库或已回库,1为已出库,2为审批中,3为审批通过,4为审批驳回
|
|
|
- if (result == null) {
|
|
|
- return CommonResult.error(200, "样品不存在");
|
|
|
- } else if (event == null) {
|
|
|
- return CommonResult.error(200, "样品在出入库的库中不存在");
|
|
|
- }
|
|
|
- if (Save == 1) {
|
|
|
- return CommonResult.error(200, "样品已出库");
|
|
|
- } else if (Save == 0) {
|
|
|
- if (State == 2) {
|
|
|
- museumFlowService.createMuseumFlowReturn(returnVO);
|
|
|
- museumFlowService.updateMuseumFlowSave0(returnVO);
|
|
|
- return CommonResult.success(true);
|
|
|
- } else if (State == 3) {
|
|
|
- return CommonResult.error(200, "样品已审批通过");
|
|
|
- } else if (State == 4) {
|
|
|
- return CommonResult.error(200, "样品审批已被驳回");
|
|
|
+ if (permissionService.hasAnyRoles(UserId, "operate")) {
|
|
|
+ if (event == null) {
|
|
|
+ return CommonResult.error(200, "标本未申请出库");
|
|
|
+ } else {
|
|
|
+ int Save = result.getSave();
|
|
|
+ if (Save == 0) {
|
|
|
+ int State = event.getState();
|
|
|
+ if (State == 0) {
|
|
|
+ return CommonResult.error(200, "标本已返回库中");
|
|
|
+ } else if (State == 1) {
|
|
|
+ museumFlowService.updateMuseumFlowStateReturn1(returnVO);
|
|
|
+ museumFlowService.updateMuseumFlowSave1(sample_id);
|
|
|
+ LocalDateTime returnTime = LocalDateTime.now();
|
|
|
+ returnVO.setReturnTime(returnTime);
|
|
|
+ } else if (State == 2) {
|
|
|
+ return CommonResult.error(200, "标本正在审批");
|
|
|
+ } else if (State == 3) {
|
|
|
+ return CommonResult.error(200, "标本审批已通过但未出库");
|
|
|
+ } else if (State == 4) {
|
|
|
+ return CommonResult.error(200, "标本审批已驳回");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonResult.error(200, "标本还未出库");
|
|
|
+ }
|
|
|
}
|
|
|
+ return CommonResult.success(true);
|
|
|
} else {
|
|
|
- return CommonResult.error(200, "样品已审批通过并出库");
|
|
|
+ return CommonResult.error(200, "您无此操作权限");
|
|
|
}
|
|
|
- return CommonResult.success(true);
|
|
|
}
|
|
|
}
|