diff --git a/sql/202310119JS.sql b/sql/202310119JS.sql new file mode 100644 index 00000000..15af0caa --- /dev/null +++ b/sql/202310119JS.sql @@ -0,0 +1,18 @@ +-- 修改 归档表 鉴定默认值 +alter table archives_record alter column identify_status set default '0'; + +-- 新增借阅申请表 借阅档案id +ALTER TABLE archives_borrow_apply ADD COLUMN `record_id` bigint(20) NULL DEFAULT NULL COMMENT '档案id'; + + +INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ( '借阅状态', 'borrow_state', 0, NULL, '', '2023-10-19 14:38:49', '', '2023-10-19 14:38:49', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '已借阅', '0', 'borrow_state', 0, 'default', '', NULL, '', '2023-10-19 14:40:16', '', '2023-10-19 14:40:16', b'0'); +INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '未借阅', '1', 'borrow_state', 0, 'default', '', NULL, '', '2023-10-19 14:40:28', '', '2023-10-19 14:40:28', b'0'); + +INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('借阅方式', 'way_type', 0, NULL, '', '2023-10-19 14:41:44', '', '2023-10-19 14:41:44', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 0, '外借', '0', 'way_type', 0, 'default', '', NULL, '', '2023-10-19 14:41:59', '', '2023-10-19 14:41:59', b'0'); +INSERT INTO `lyr-one`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '现场查阅', '1', 'way_type', 0, 'default', '', NULL, '', '2023-10-19 14:42:05', '', '2023-10-19 14:42:05', b'0'); + +INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('档案介质类型', 'media_type', 0, NULL, '', '2023-10-19 14:43:33', '', '2023-10-19 14:43:33', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 0, '纸质', '0', 'media_type', 0, 'default', '', NULL, '', '2023-10-19 14:43:49', '', '2023-10-19 14:43:49', b'0'); +INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '电子档案', '1', 'media_type', 0, 'default', '', NULL, '', '2023-10-19 14:44:02', '', '2023-10-19 14:44:02', b'0'); diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/BorrowApplyController.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/BorrowApplyController.java index 59242013..f8d43673 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/BorrowApplyController.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/BorrowApplyController.java @@ -40,8 +40,9 @@ public class BorrowApplyController { @PostMapping("/create") @Operation(summary = "创建档案借阅申请") @PreAuthorize("@ss.hasPermission('archives:borrow-apply:create')") - public CommonResult createBorrowApply(@Valid @RequestBody BorrowApplyCreateReqVO createReqVO) { - return success(borrowApplyService.createBorrowApply(createReqVO)); + public CommonResult createBorrowApply(@Valid @RequestBody BorrowApplyCreateReqVO createReqVO) { + + return borrowApplyService.createBorrowApply(createReqVO); } @PutMapping("/update") diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyBaseVO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyBaseVO.java index 70080219..63a67759 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyBaseVO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyBaseVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -61,4 +62,20 @@ public class BorrowApplyBaseVO { @Schema(description = "描述", example = "你猜") private String remark; + @Schema(description = "档案id", example = "档案id") + private Long recordId; + + @Schema(description = "档案类型", example = "档案类型") + @TableField(exist = false) + private String fileType; + + @Schema(description = "档案位置", example = "档案位置") + @TableField(exist = false) + private String site; + + @Schema(description = "案卷号", example = "案卷号") + @TableField(exist = false) + private String filesNum; + + } diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyPageReqVO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyPageReqVO.java index 45ba431b..8c67cc2c 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyPageReqVO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/borrowapply/vo/BorrowApplyPageReqVO.java @@ -62,4 +62,21 @@ public class BorrowApplyPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; + + @Schema(description = "档案id", example = "档案id") + private Long recordId; + + @Schema(description = "档案类型", example = "档案类型") + private String fileType; + + @Schema(description = "档案位置", example = "档案位置") + private String site; + + @Schema(description = "案卷号", example = "案卷号") + private String filesNum; + + + @Schema(description = "判断调用历史接口还是新增列表接口", example = "判断调用历史接口还是新增列表接口") + private String historyOrList; + } diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/borrowapply/BorrowApplyDO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/borrowapply/BorrowApplyDO.java index c7e51190..c1bb8549 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/borrowapply/BorrowApplyDO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/borrowapply/BorrowApplyDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; import java.time.LocalDateTime; @@ -85,4 +86,28 @@ public class BorrowApplyDO extends BaseDO { */ private String remark; + /** + * 档案id + */ + private Long recordId; + + /** + * 档案类型 + */ + @TableField(exist = false) + private String fileType; + + /** + * 档案位置 + */ + @TableField(exist = false) + private String site; + + /** + * 案卷号 + */ + @TableField(exist = false) + private String filesNum; + + } diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/record/RecordDO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/record/RecordDO.java index f40d02ec..59acdb65 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/record/RecordDO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/record/RecordDO.java @@ -91,6 +91,7 @@ public class RecordDO extends BaseDO { /** * 借阅状态 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String borrowStatus; /** * 鉴定状态 diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/mysql/borrowapply/BorrowApplyMapper.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/mysql/borrowapply/BorrowApplyMapper.java index 1f0db30c..ea9acde1 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/mysql/borrowapply/BorrowApplyMapper.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/mysql/borrowapply/BorrowApplyMapper.java @@ -20,7 +20,6 @@ public interface BorrowApplyMapper extends BaseMapperX { default PageResult selectPage(BorrowApplyPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(BorrowApplyDO::getBorrowCode, reqVO.getBorrowCode()) - .eqIfPresent(BorrowApplyDO::getBorrowState, reqVO.getBorrowState()) .eqIfPresent(BorrowApplyDO::getReason, reqVO.getReason()) .eqIfPresent(BorrowApplyDO::getDescribes, reqVO.getDescribes()) .eqIfPresent(BorrowApplyDO::getUserId, reqVO.getUserId()) @@ -34,7 +33,30 @@ public interface BorrowApplyMapper extends BaseMapperX { .eqIfPresent(BorrowApplyDO::getCompany, reqVO.getCompany()) .eqIfPresent(BorrowApplyDO::getRemark, reqVO.getRemark()) .betweenIfPresent(BorrowApplyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BorrowApplyDO::getId)); + .orderByDesc(BorrowApplyDO::getId) + .eq(BorrowApplyDO::getBorrowState,"1")); + } + + + default PageResult selectPageHistory(BorrowApplyPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(BorrowApplyDO::getBorrowCode, reqVO.getBorrowCode()) + .eqIfPresent(BorrowApplyDO::getReason, reqVO.getReason()) + .eqIfPresent(BorrowApplyDO::getDescribes, reqVO.getDescribes()) + .eqIfPresent(BorrowApplyDO::getUserId, reqVO.getUserId()) + .likeIfPresent(BorrowApplyDO::getUserName, reqVO.getUserName()) + .eqIfPresent(BorrowApplyDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(BorrowApplyDO::getDeptName, reqVO.getDeptName()) + .betweenIfPresent(BorrowApplyDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(BorrowApplyDO::getWay, reqVO.getWay()) + .eqIfPresent(BorrowApplyDO::getMedia, reqVO.getMedia()) + .eqIfPresent(BorrowApplyDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(BorrowApplyDO::getCompany, reqVO.getCompany()) + .eqIfPresent(BorrowApplyDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(BorrowApplyDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BorrowApplyDO::getId) + .isNull(BorrowApplyDO::getBorrowState)); + } default List selectList(BorrowApplyExportReqVO reqVO) { diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyService.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyService.java index de63c097..70bd5225 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyService.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyService.java @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.archives.service.borrowapply; import java.util.*; import javax.validation.*; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo.*; import cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply.BorrowApplyDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -19,7 +21,7 @@ public interface BorrowApplyService { * @param createReqVO 创建信息 * @return 编号 */ - Long createBorrowApply(@Valid BorrowApplyCreateReqVO createReqVO); + CommonResult createBorrowApply(@Valid BorrowApplyCreateReqVO createReqVO); /** * 更新档案借阅申请 diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyServiceImpl.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyServiceImpl.java index ce17b670..9a765af6 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyServiceImpl.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/service/borrowapply/BorrowApplyServiceImpl.java @@ -1,19 +1,23 @@ package cn.iocoder.yudao.module.archives.service.borrowapply; -import cn.hutool.core.date.LocalDateTimeUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.string.StringUtils; +import cn.iocoder.yudao.module.archives.controller.admin.record.vo.RecordUpdateReqVO; +import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO; +import cn.iocoder.yudao.module.archives.service.record.RecordService; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import java.time.LocalDateTime; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; import java.util.*; +import java.util.List; import cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo.*; import cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply.BorrowApplyDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; - import cn.iocoder.yudao.module.archives.convert.borrowapply.BorrowApplyConvert; import cn.iocoder.yudao.module.archives.dal.mysql.borrowapply.BorrowApplyMapper; - import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*; @@ -29,17 +33,47 @@ public class BorrowApplyServiceImpl implements BorrowApplyService { @Resource private BorrowApplyMapper borrowApplyMapper; + @Resource + private RecordService recordService; + @Override - public Long createBorrowApply(BorrowApplyCreateReqVO createReqVO) { + @Transactional + public CommonResult createBorrowApply(BorrowApplyCreateReqVO createReqVO) { // 插入 BorrowApplyDO borrowApply = BorrowApplyConvert.INSTANCE.convert(createReqVO); + //修改借阅状态 + RecordDO record = recordService.getRecord(createReqVO.getRecordId()); + if (StringUtils.isNotNull(record.getBorrowStatus())){ + if (record.getBorrowStatus().equals("0")){ + return CommonResult.error("档案已被借阅"); + } + } + RecordUpdateReqVO recordUpdateReqVO = new RecordUpdateReqVO(); + BeanUtils.copyProperties(record,recordUpdateReqVO); + recordUpdateReqVO.setBorrowStatus("1"); + recordService.updateRecord(recordUpdateReqVO); borrowApplyMapper.insert(borrowApply); // 返回 - return borrowApply.getId(); + return CommonResult.success(borrowApply); } @Override + @Transactional public void updateBorrowApply(BorrowApplyUpdateReqVO updateReqVO) { + + BorrowApplyDO borrowApply = this.getBorrowApply(updateReqVO.getId()); + RecordUpdateReqVO recordUpdateReqVO = new RecordUpdateReqVO(); + + RecordDO record = recordService.getRecord(borrowApply.getRecordId()); + BeanUtils.copyProperties(record,recordUpdateReqVO); + + if (StringUtils.isNotNull(updateReqVO.getBorrowState())){ + if (updateReqVO.getBorrowState().equals("2")) { + recordUpdateReqVO.setBorrowStatus(null); + } + recordUpdateReqVO.setBorrowStatus(updateReqVO.getBorrowState()); + recordService.updateRecord(recordUpdateReqVO); + } // 校验存在 validateBorrowApplyExists(updateReqVO.getId()); // 更新 @@ -63,7 +97,9 @@ public class BorrowApplyServiceImpl implements BorrowApplyService { @Override public BorrowApplyDO getBorrowApply(Long id) { - return borrowApplyMapper.selectById(id); + BorrowApplyDO borrowApplyDO = borrowApplyMapper.selectById(id); + RecordDO record = recordService.getRecord(borrowApplyDO.getRecordId()); + return borrowApplyDO.setSite(record.getSite()).setFileType(record.getFileType()).setFilesNum(record.getFilesNum()); } @Override @@ -73,6 +109,9 @@ public class BorrowApplyServiceImpl implements BorrowApplyService { @Override public PageResult getBorrowApplyPage(BorrowApplyPageReqVO pageReqVO) { + if (pageReqVO.getHistoryOrList().equals("history")){ + return borrowApplyMapper.selectPageHistory(pageReqVO); + } return borrowApplyMapper.selectPage(pageReqVO); }