移交管理修改

new
JiilingLee 1 year ago
parent eaa1d23ac2
commit 55f91ca50c

@ -53,13 +53,14 @@ CREATE TABLE `archives_code_rule` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`case_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`catalog_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`files_num` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`files_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`tenant_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`deleted` bit(1) NULL DEFAULT b'0' COMMENT '',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`updater` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '' ROW_FORMAT = Dynamic;

@ -26,7 +26,7 @@ DROP TABLE IF EXISTS `archives_turn_over`;
CREATE TABLE `archives_turn_over` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`apply_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`turn_date` datetime(0) NULL DEFAULT NULL COMMENT '',
`turn_date` datetime NULL DEFAULT NULL COMMENT '',
`turn_explain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`output_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`output_name_id` bigint(20) NULL DEFAULT NULL COMMENT 'ID',
@ -35,7 +35,7 @@ CREATE TABLE `archives_turn_over` (
`user_id` bigint(20) NULL DEFAULT NULL COMMENT 'ID',
`deleted` bit(1) NULL DEFAULT b'0' COMMENT '',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`update_time` datetime NULL DEFAULT NULL COMMENT '',
`dept_id` bigint(20) NULL DEFAULT NULL COMMENT 'ID',
`dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`company_id` bigint(20) NULL DEFAULT NULL COMMENT 'ID',
@ -55,10 +55,14 @@ CREATE TABLE `archives_turn_over` (
`attr4` int(11) NULL DEFAULT NULL COMMENT '4',
`create_by_id` bigint(20) NOT NULL COMMENT 'id',
`amount` int(11) NULL DEFAULT NULL COMMENT '',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '',
`create_time` datetime NULL DEFAULT NULL COMMENT '',
`process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`bill_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`auth_record_id` bigint(20) NULL DEFAULT NULL COMMENT 'id',
`file_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
`file_size` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '' ROW_FORMAT = Dynamic;

@ -41,6 +41,12 @@ public class CodeRuleController {
@Resource
private CodeRuleService codeRuleService;
@PostMapping("/createWS")
@Operation(summary = "创建移交编码")
public CommonResult<String> createWS(@Valid @RequestBody CodeRuleCreateReqVO createReqVO) {
return success(codeRuleService.createWS(createReqVO));
}
@PostMapping("/create")
@Operation(summary = "创建档案编码规则")
public CommonResult<String> createCodeRule(@Valid @RequestBody CodeRuleCreateReqVO createReqVO) {

@ -10,5 +10,9 @@ import javax.validation.constraints.*;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CodeRuleCreateReqVO extends CodeRuleBaseVO {
/**
* id
*/
private Long id;
}

@ -50,7 +50,7 @@ public class TurnOverController {
@PostMapping("/create")
@Operation(summary = "创建移交")
@PreAuthorize("@ss.hasPermission('archives:turn-over:create')")
public CommonResult createTurnOver(@Valid @RequestBody TurnOverCreateReqVO createReqVO) {
public CommonResult createTurnOver(@Valid @RequestBody TurnOverCreateReqVO createReqVO) throws IOException {
return turnOverService.createTurnOver(createReqVO);
}

@ -94,4 +94,16 @@ public class TurnOverBaseVO {
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "旧档案位置")
private String position;
@Schema(description = "鉴定历史记录id")
private Long authRecordId;
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
private String fileUrl;
@Schema(description = "文件大小")
private String fileSize;
}

@ -13,4 +13,8 @@ import javax.validation.constraints.*;
public class TurnOverCreateReqVO extends TurnOverBaseVO {
@Schema(description = "id")
private Long id;
@Schema(description = "鉴定历史记录id")
@NotNull(message = "鉴定历史记录主键authRecordId不能为空")
private Long authRecordId;
}

@ -98,4 +98,15 @@ public class TurnOverExcelVO {
@ExcelProperty("状态")
private String status;
@ExcelProperty("旧档案位置")
private String position;
@ExcelProperty("鉴定历史记录id")
private Long authRecordId;
@ExcelProperty("文件地址")
private String fileUrl;
@ExcelProperty("文件大小")
private String fileSize;
}

@ -93,4 +93,16 @@ public class TurnOverExportReqVO {
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "旧档案位置")
private String position;
@Schema(description = "鉴定历史记录id")
private Long authRecordId;
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
private String fileUrl;
@Schema(description = "文件大小")
private String fileSize;
}

@ -95,4 +95,16 @@ public class TurnOverPageReqVO extends PageParam {
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "旧档案位置")
private String position;
@Schema(description = "鉴定历史记录id")
private Long authRecordId;
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
private String fileUrl;
@Schema(description = "文件大小")
private String fileSize;
}

@ -144,5 +144,21 @@ public class TurnOverDO extends BaseDO {
*
*/
private String status;
/**
*
*/
private String position;
/**
* id
*/
private Long authRecordId;
/**
*
*/
private String fileUrl;
/**
*
*/
private String fileSize;
}

@ -45,6 +45,10 @@ public interface TurnOverMapper extends BaseMapperX<TurnOverDO> {
.eqIfPresent(TurnOverDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.eqIfPresent(TurnOverDO::getBillType, reqVO.getBillType())
.eqIfPresent(TurnOverDO::getStatus, reqVO.getStatus())
.eqIfPresent(TurnOverDO::getPosition, reqVO.getPosition())
.eqIfPresent(TurnOverDO::getAuthRecordId, reqVO.getAuthRecordId())
.eqIfPresent(TurnOverDO::getFileUrl, reqVO.getFileUrl())
.eqIfPresent(TurnOverDO::getFileSize, reqVO.getFileSize())
.orderByDesc(TurnOverDO::getId));
}
@ -76,6 +80,10 @@ public interface TurnOverMapper extends BaseMapperX<TurnOverDO> {
.eqIfPresent(TurnOverDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.eqIfPresent(TurnOverDO::getBillType, reqVO.getBillType())
.eqIfPresent(TurnOverDO::getStatus, reqVO.getStatus())
.eqIfPresent(TurnOverDO::getPosition, reqVO.getPosition())
.eqIfPresent(TurnOverDO::getAuthRecordId, reqVO.getAuthRecordId())
.eqIfPresent(TurnOverDO::getFileUrl, reqVO.getFileUrl())
.eqIfPresent(TurnOverDO::getFileSize, reqVO.getFileSize())
.orderByDesc(TurnOverDO::getId));
}

@ -21,6 +21,14 @@ public interface CodeRuleService {
*/
String createCodeRule(@Valid CodeRuleCreateReqVO createReqVO);
/**
*
*
* @param createReqVO
* @return
*/
String createWS(@Valid CodeRuleCreateReqVO createReqVO);
/**
*
*

@ -1,5 +1,9 @@
package cn.iocoder.yudao.module.archives.service.coderule;
import cn.iocoder.yudao.module.archives.dal.dataobject.authenticate.AuthenticateDO;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.module.archives.dal.mysql.authenticate.AuthenticateMapper;
import cn.iocoder.yudao.module.archives.dal.mysql.record.RecordMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.checkerframework.checker.units.qual.C;
@ -8,6 +12,9 @@ import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
@ -30,57 +37,148 @@ public class CodeRuleServiceImpl implements CodeRuleService {
@Resource
private CodeRuleMapper codeRuleMapper;
@Resource
private AuthenticateMapper authenticateMapper;
@Resource
private RecordMapper recordMapper;
@Override
public String createCodeRule(CodeRuleCreateReqVO createReqVO) {
// 插入
//格式说明 CODE20201111xxx CODE+当前年月日+编号(具体长度看需求)
String front = "CODE";
// 前缀//当前时间编码
Date date = new Date();
String bidDate = new SimpleDateFormat("yyyyMMdd").format(date);
List<CodeRuleDO> codeRuleDOList = codeRuleMapper.selectList(Wrappers.<CodeRuleDO>lambdaQuery()
.eq(CodeRuleDO::getCaseNum, createReqVO.getCaseNum())
.eq(CodeRuleDO::getCatalogNum, createReqVO.getCatalogNum())
.orderByDesc(CodeRuleDO::getCreateTime)
.last("LIMIT 1")
);
String code ="";
//修改为自己的业务代码
if (codeRuleDOList.size()>0) {
// 在数据表中查到了,说明现在这个订单不是今天的第一单
String bid = codeRuleDOList.get(0).getFilesNum();
//取出ID也就是业务号
bid = bid.substring(12, 15);
// 取出后三位数,也就是自动生成的三位数 001
int num = Integer.valueOf(bid);
num++;
// 加1
if (num < 10) {
String bidNum = String.format("%03d", num);
//%03d 只是三位不足补0
code = front + bidDate + bidNum;
} else if (num < 100) {
String bidNum = String.format("%03d", num);
//num<100,说明是两位数前面要补一个0
code = front + bidDate + bidNum;
synchronized (this) {
// 插入
//格式说明 CODE20201111xxx CODE+当前年月日+编号(具体长度看需求)
String front = "CODE";
// 前缀//当前时间编码
LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
Date date = new Date();
String bidDate = new SimpleDateFormat("yyyyMMdd").format(date);
List<CodeRuleDO> codeRuleDOList = codeRuleMapper.selectList(Wrappers.<CodeRuleDO>lambdaQuery()
.eq(CodeRuleDO::getCaseNum, createReqVO.getCaseNum())
.eq(CodeRuleDO::getCatalogNum, createReqVO.getCatalogNum())
.between(CodeRuleDO::getCreateTime, todayStart, todayEnd)
.orderByDesc(CodeRuleDO::getCreateTime)
.last("LIMIT 1")
);
String code = "";
//修改为自己的业务代码
if (codeRuleDOList.size() > 0) {
// 在数据表中查到了,说明现在这个订单不是今天的第一单
String bid = codeRuleDOList.get(0).getFilesNum();
//取出ID也就是业务号
bid = bid.substring(12, 15);
// 取出后三位数,也就是自动生成的三位数 001
int num = Integer.valueOf(bid);
num++;
// 加1
if (num < 10) {
String bidNum = String.format("%03d", num);
//%03d 只是三位不足补0
code = front + bidDate + bidNum;
} else if (num < 100) {
String bidNum = String.format("%03d", num);
//num<100,说明是两位数前面要补一个0
code = front + bidDate + bidNum;
} else {
String bidNum = String.valueOf(num);
code = front + bidDate + bidNum;
}
} else {
String bidNum = String.valueOf(num);
int number = 1;
String bidNum = "00" + number;
code = front + bidDate + bidNum;
}
CodeRuleDO codeRule = CodeRuleConvert.INSTANCE.convert(createReqVO);
codeRule.setFilesNum(code);
codeRule.setDeleted(false);
codeRuleMapper.insert(codeRule);
// 返回
return codeRule.getFilesNum();
}
}
@Override
public String createWS(CodeRuleCreateReqVO createReqVO) {
//查找鉴定记录的档案id
AuthenticateDO authenticateDO = authenticateMapper.selectById(createReqVO.getId());
if (authenticateDO != null) {
Integer recordId = authenticateDO.getRecordId();
RecordDO recordDO = recordMapper.selectById(recordId);
//格式说明 全宗号-WS-2010/2016-DK+顺序号
String caseNum = recordDO.getCaseNum();
createReqVO.setCaseNum(caseNum);
createReqVO.setCatalogNum("WS");
//年
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
//保管期限
String timeLimit = authenticateDO.getTimeLimit();
int year2 = year + Integer.valueOf(timeLimit);
//只有延长保存的
synchronized (this) {
if (timeLimit != null) {
String front = caseNum + "-WS-" + year + "/" + year2 + "-DK";
// 前缀//当前时间编码
LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
Date date = new Date();
String bidDate = new SimpleDateFormat("yyyyMMdd").format(date);
List<CodeRuleDO> codeRuleDOList = codeRuleMapper.selectList(Wrappers.<CodeRuleDO>lambdaQuery()
.eq(CodeRuleDO::getCaseNum, caseNum)
.eq(CodeRuleDO::getCatalogNum, "WS")
.between(CodeRuleDO::getCreateTime, todayStart, todayEnd)
.orderByDesc(CodeRuleDO::getCreateTime)
.last("LIMIT 1")
);
String code = "";
//修改为自己的业务代码
if (codeRuleDOList.size() > 0) {
// 在数据表中查到了,说明现在这个订单不是今天的第一单
String bid = codeRuleDOList.get(0).getFilesNum();
//取出ID也就是业务号
int index = bid.indexOf("DK");
if (index != -1) {
String dkValue = bid.substring(index + 2);
bid = dkValue;
// 输出:"20211202001"
}
bid = bid.substring(8, 11);
// 取出后三位数,也就是自动生成的三位数 001
int num = Integer.valueOf(bid);
num++;
// 加1
if (num < 10) {
String bidNum = String.format("%03d", num);
//%03d 只是三位不足补0
code = front + bidDate + bidNum;
} else if (num < 100) {
String bidNum = String.format("%03d", num);
//num<100,说明是两位数前面要补一个0
code = front + bidDate + bidNum;
} else {
String bidNum = String.valueOf(num);
code = front + bidDate + bidNum;
}
} else {
int number = 1;
String bidNum = "00" + number;
code = front + bidDate + bidNum;
}
CodeRuleDO codeRule = CodeRuleConvert.INSTANCE.convert(createReqVO);
codeRule.setId(null);
codeRule.setFilesNum(code);
codeRule.setDeleted(false);
codeRuleMapper.insert(codeRule);
return code;
}
}
} else {
int number = 1;
String bidNum = "00" + number;
code = front + bidDate + bidNum;
}
CodeRuleDO codeRule = CodeRuleConvert.INSTANCE.convert(createReqVO);
codeRule.setFilesNum(code);
codeRule.setDeleted(false);
codeRuleMapper.insert(codeRule);
// 返回
return codeRule.getFilesNum();
return "";
}
@Override

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.archives.service.turnover;
import java.io.IOException;
import java.util.*;
import javax.validation.*;
@ -21,7 +22,7 @@ public interface TurnOverService {
* @param createReqVO
* @return
*/
CommonResult createTurnOver(@Valid TurnOverCreateReqVO createReqVO);
CommonResult createTurnOver(@Valid TurnOverCreateReqVO createReqVO) throws IOException;
/**
*

@ -1,23 +1,83 @@
package cn.iocoder.yudao.module.archives.service.turnover;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ZipUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.attachment.vo.AttachmentExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.bankslip.vo.BankSlipExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.flow.vo.FlowExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.invoices.vo.InvoicesExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.other.vo.OtherExportReqVO;
import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.VoucherExportReqVO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.attachment.AttachmentDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.bankslip.BankSlipDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.flow.FlowDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.invoices.InvoicesDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.other.OtherDO;
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
import cn.iocoder.yudao.module.accounting.dal.mysql.accountingbook.AccountingBookMapper;
import cn.iocoder.yudao.module.accounting.dal.mysql.accountingreport.AccountingReportMapper;
import cn.iocoder.yudao.module.accounting.dal.mysql.other.OtherMapper;
import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper;
import cn.iocoder.yudao.module.accounting.service.attachment.AttachmentService;
import cn.iocoder.yudao.module.accounting.service.bankslip.BankSlipService;
import cn.iocoder.yudao.module.accounting.service.flow.FlowService;
import cn.iocoder.yudao.module.accounting.service.invoices.InvoicesService;
import cn.iocoder.yudao.module.archives.dal.dataobject.authenticate.AuthenticateDO;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.module.archives.dal.mysql.authenticate.AuthenticateMapper;
import cn.iocoder.yudao.module.archives.dal.mysql.record.RecordMapper;
import cn.iocoder.yudao.module.archives.enums.ArchivesStatusEnum;
import cn.iocoder.yudao.module.archives.enums.ArchivesTypeEnum;
import cn.iocoder.yudao.module.archives.enums.BillTypeEnum;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.ea.controller.admin.electronicassets.vo.ElectronicAssetsExportReqVO;
import cn.iocoder.yudao.module.ea.controller.admin.electronicconsultation.vo.ElectronicConsultationExportReqVO;
import cn.iocoder.yudao.module.ea.controller.admin.electroniccontracts.vo.ElectronicContractsExportReqVO;
import cn.iocoder.yudao.module.ea.controller.admin.electroniccustomercomplaint.vo.ElectronicCustomerComplaintExportReqVO;
import cn.iocoder.yudao.module.ea.controller.admin.electronicemployee.vo.ElectronicEmployeeExportReqVO;
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicassets.ElectronicAssetsDO;
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicconsultation.ElectronicConsultationDO;
import cn.iocoder.yudao.module.ea.dal.dataobject.electroniccontracts.ElectronicContractsDO;
import cn.iocoder.yudao.module.ea.dal.dataobject.electroniccustomercomplaint.ElectronicCustomerComplaintDO;
import cn.iocoder.yudao.module.ea.dal.dataobject.electronicemployee.ElectronicEmployeeDO;
import cn.iocoder.yudao.module.ea.dal.mysql.electronicassets.ElectronicAssetsMapper;
import cn.iocoder.yudao.module.ea.dal.mysql.electronicconsultation.ElectronicConsultationMapper;
import cn.iocoder.yudao.module.ea.dal.mysql.electroniccontracts.ElectronicContractsMapper;
import cn.iocoder.yudao.module.ea.dal.mysql.electroniccustomercomplaint.ElectronicCustomerComplaintMapper;
import cn.iocoder.yudao.module.ea.dal.mysql.electronicemployee.ElectronicEmployeeMapper;
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.setting.tools.JsonToXml;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import com.alibaba.fastjson.JSON;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.Validator;
import org.springframework.validation.annotation.Validated;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import cn.iocoder.yudao.module.archives.controller.admin.turnover.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.turnover.TurnOverDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -41,27 +101,331 @@ public class TurnOverServiceImpl extends MPJBaseServiceImpl<TurnOverMapper, Turn
@Resource
private TurnOverMapper turnOverMapper;
@Resource
private Validator validator;
@Resource
private AdminUserApi adminUserApi;
private AuthenticateMapper authenticateMapper;
@Resource
private DeptApi deptApi;
private RecordMapper recordMapper;
@Resource
private BpmProcessInstanceApi processInstanceApi;
@Resource
private FileService fileService;
@Resource
private VoucherMapper voucherMapper;
@Resource
private AccountingBookMapper accountingBookMapper;
@Resource
private OtherMapper otherMapper;
@Resource
private AccountingReportMapper accountingReportMapper;
@Resource
private ElectronicAssetsMapper electronicAssetsMapper;
@Resource
private ElectronicContractsMapper electronicContractsMapper;
@Resource
private ElectronicConsultationMapper electronicConsultationMapper;
@Resource
private ElectronicEmployeeMapper electronicEmployeeMapper;
@Resource
private ElectronicCustomerComplaintMapper electronicCustomerComplaintMapper;
@Resource
private AttachmentService attachmentService;
@Resource
private BankSlipService bankSlipService;
@Resource
private InvoicesService invoicesService;
@Resource
private FlowService flowService;
@Override
public CommonResult createTurnOver(TurnOverCreateReqVO createReqVO) {
public CommonResult createTurnOver(TurnOverCreateReqVO createReqVO) throws IOException {
//查找档案相关文件记录
AuthenticateDO authenticateDO = authenticateMapper.selectById(createReqVO.getAuthRecordId());
// 插入
TurnOverDO turnOver = TurnOverConvert.INSTANCE.convert(createReqVO);
if (authenticateDO != null) {
Long recordId = Long.valueOf(authenticateDO.getRecordId());
RecordDO recordDO = recordMapper.selectById(recordId);
turnOver.setCompany(recordDO.getCompany());
turnOver.setCompanyId(recordDO.getCompanyId());
// 创建存放文件夹
String folderPath = "/temp" + UUID.randomUUID();
//最后打包文件夹
String zipFolderStr = "/zip";
//全宗文件夹
String folderCaseNum = folderPath + "/" + recordDO.getCaseNum();
FileUtil.mkdir(new File(folderPath));
FileUtil.mkdir(new File(zipFolderStr));
FileUtil.mkdir(new File(folderCaseNum));
//获取档案类型
String fileType = recordDO.getFileType();
//会计档案归档
if (fileType.equals(ArchivesTypeEnum.ACCOUNTING_VOUCHER.getValue())) {
VoucherExportReqVO voucherExportReqVO = new VoucherExportReqVO();
voucherExportReqVO.setRecordId(Long.valueOf(recordId));
List<VoucherDO> voucherDOS = voucherMapper.selectList(voucherExportReqVO);
for (VoucherDO voucher : voucherDOS
) {
try {
Long id = voucher.getId();
//凭证文件夹
String voucherPath = folderCaseNum + "/" + voucher.getVoucherNum();
FileUtil.mkdir(voucherPath);
//凭证xml
String voucherXmlPath = voucherPath + "/" + voucher.getVoucherNum() + ".xml";
String voucherStr = JsonToXml.jsonToXml(JSON.toJSONString(voucher));
FileUtil.writeString(voucherStr, voucherXmlPath, CharsetUtil.CHARSET_UTF_8);
//凭证附件
AttachmentExportReqVO attachmentExportReqVO = new AttachmentExportReqVO();
attachmentExportReqVO.setVoucherId(id);
List<AttachmentDO> attachmentList = attachmentService.getAttachmentList(attachmentExportReqVO);
if (attachmentList.size() > 0) {
for (AttachmentDO at : attachmentList
) {
String fileUrl = at.getFileUrl();
downloadFile(voucherPath, fileUrl);
}
}
//审批流程
FlowExportReqVO flowExportReqVO = new FlowExportReqVO();
flowExportReqVO.setVoucherId(id);
List<FlowDO> flowList = flowService.getFlowList(flowExportReqVO);
if (flowList.size() > 0) {
for (FlowDO fl : flowList
) {
String fileUrl = fl.getFileUrl();
downloadFile(voucherPath, fileUrl);
}
}
//电子发票
InvoicesExportReqVO invoicesExportReqVO = new InvoicesExportReqVO().setVoucherId(id);
List<InvoicesDO> invoicesList = invoicesService.getInvoicesList(invoicesExportReqVO);
if (invoicesList.size() > 1) {
for (InvoicesDO iv : invoicesList
) {
String fileUrl = iv.getFileUrl();
downloadFile(voucherPath, fileUrl);
}
}
//银行回单
BankSlipExportReqVO bankSlipExportReqVO = new BankSlipExportReqVO();
bankSlipExportReqVO.setVoucherId(id);
List<BankSlipDO> bankSlipList = bankSlipService.getBankSlipList(bankSlipExportReqVO);
if (bankSlipList.size() > 0) {
for (BankSlipDO bs : bankSlipList
) {
String fileUrl = bs.getFileUrl();
downloadFile(voucherPath, fileUrl);
}
}
} catch (Exception e) {
log.error(e.getMessage());
continue;
}
}
}
//会计账簿
if (fileType.equals(ArchivesTypeEnum.ACCOUNTING_BOOK.getValue())) {
AccountingBookExportReqVO accountingBookExportReqVO = new AccountingBookExportReqVO();
accountingBookExportReqVO.setRecordId(recordDO.getId());
List<AccountingBookDO> accountingBookDOS = accountingBookMapper.selectList(accountingBookExportReqVO);
for (AccountingBookDO a : accountingBookDOS
) {
try {
//账簿文件夹
String bookPath = folderCaseNum + "/" + a.getId();
FileUtil.mkdir(bookPath);
//账簿xml
String bookXmlPath = bookPath + "/" + a.getName() + ".xml";
String aStr = JsonToXml.jsonToXml(JSON.toJSONString(a));
FileUtil.writeString(aStr, bookXmlPath, CharsetUtil.CHARSET_UTF_8);
//账簿文件
downloadFile(bookPath, a.getUri());
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//会计报表
if (fileType.equals(ArchivesTypeEnum.ACCOUNTING_REPORT.getValue())) {
AccountingReportExportReqVO accountingReportExportReqVO = new AccountingReportExportReqVO();
accountingReportExportReqVO.setRecordId(Long.valueOf(recordId));
List<AccountingReportDO> accountingReportDOS = accountingReportMapper.selectList(accountingReportExportReqVO);
for (AccountingReportDO report:accountingReportDOS
) {
try {
//会计报表文件夹
String reportPath = folderCaseNum + "/" + report.getId();
FileUtil.mkdir(reportPath);
//会计报表xml
String reportXmlPath = reportPath + "/" + report.getName() + ".xml";
String reportStr = JsonToXml.jsonToXml(JSON.toJSONString(report));
FileUtil.writeString(reportStr, reportXmlPath, CharsetUtil.CHARSET_UTF_8);
//账簿文件
downloadFile(reportPath, report.getUrl());
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//会计其他资料
if (fileType.equals(ArchivesTypeEnum.ACCOUNTING_OTHER.getValue())) {
OtherExportReqVO otherExportReqVO = new OtherExportReqVO();
otherExportReqVO.setRecordId(Long.valueOf(recordId));
List<OtherDO> otherDOS = otherMapper.selectList(otherExportReqVO);
for (OtherDO otherDO:otherDOS
) {
try {
//会计其他资料文件夹
String otherDOPath = folderCaseNum + "/" + otherDO.getId();
FileUtil.mkdir(otherDOPath);
//会计其他资料xml
String reportXmlPath = otherDOPath + "/" + otherDO.getName() + ".xml";
String reportStr = JsonToXml.jsonToXml(JSON.toJSONString(otherDO));
FileUtil.writeString(reportStr, reportXmlPath, CharsetUtil.CHARSET_UTF_8);
//会计其他资料文件
downloadFile(otherDOPath, otherDO.getFileUrl());
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//资产档案
if (fileType.equals(ArchivesTypeEnum.ELECTRONI_ASSETS.getValue())) {
ElectronicAssetsExportReqVO electronicAssetsExportReqVO = new ElectronicAssetsExportReqVO();
electronicAssetsExportReqVO.setRecordId(recordId);
List<ElectronicAssetsDO> electronicAssetsDOS = electronicAssetsMapper.selectList(electronicAssetsExportReqVO);
for (ElectronicAssetsDO assets:electronicAssetsDOS
) {
try {
//资产档案文件夹
String assetsPath = folderCaseNum + "/" + assets.getId();
FileUtil.mkdir(assetsPath);
//资产档案xml
String reportXmlPath = assetsPath + "/" + assets.getAssetCode() + ".xml";
String reportStr = JsonToXml.jsonToXml(JSON.toJSONString(assets));
FileUtil.writeString(reportStr, reportXmlPath, CharsetUtil.CHARSET_UTF_8);
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//合同档案
if (fileType.equals(ArchivesTypeEnum.ELECTRONI_CONTRACTS.getValue())) {
ElectronicContractsExportReqVO electronicContractsExportReqVO = new ElectronicContractsExportReqVO();
electronicContractsExportReqVO.setRecordId(recordId);
List<ElectronicContractsDO> electronicContractsDOS = electronicContractsMapper.selectList(electronicContractsExportReqVO);
for (ElectronicContractsDO assets:electronicContractsDOS
) {
try {
//合同档案文件夹
String contractPath = folderCaseNum + "/" + assets.getId();
FileUtil.mkdir(contractPath);
//合同档案xml
String contractXmlPath = contractPath + "/" + assets.getContractCode() + ".xml";
String contractPathStr = JsonToXml.jsonToXml(JSON.toJSONString(assets));
FileUtil.writeString(contractPathStr, contractXmlPath, CharsetUtil.CHARSET_UTF_8);
downloadFile(contractPath, assets.getContractAttachment());
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//咨询档案
if (fileType.equals(ArchivesTypeEnum.ELECTRONI_CONSULTATION.getValue())) {
ElectronicConsultationExportReqVO electronicConsultationExportReqVO = new ElectronicConsultationExportReqVO();
electronicConsultationExportReqVO.setRecordId(recordId);
List<ElectronicConsultationDO> electronicConsultationDOS = electronicConsultationMapper.selectList(electronicConsultationExportReqVO);
for (ElectronicConsultationDO ec:electronicConsultationDOS
) {
try {
//咨询档案文件夹
String contractPath = folderCaseNum + "/" + ec.getConsultationId();
FileUtil.mkdir(contractPath);
//咨询档案xml
String contractXmlPath = contractPath + "/" + ec.getConsultationId() + ".xml";
String contractPathStr = JsonToXml.jsonToXml(JSON.toJSONString(ec));
FileUtil.writeString(contractPathStr, contractXmlPath, CharsetUtil.CHARSET_UTF_8);
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//员工档案
if (fileType.equals(ArchivesTypeEnum.ELECTRONI_EMPLOYEE.getValue())) {
ElectronicEmployeeExportReqVO electronicEmployeeExportReqVO = new ElectronicEmployeeExportReqVO();
electronicEmployeeExportReqVO.setRecordId(recordId);
List<ElectronicEmployeeDO> electronicEmployeeDOS = electronicEmployeeMapper.selectList(electronicEmployeeExportReqVO);
for (ElectronicEmployeeDO ec:electronicEmployeeDOS
) {
try {
//员工档案文件夹
String contractPath = folderCaseNum + "/" + ec.getIdCardNumber();
FileUtil.mkdir(contractPath);
//员工档案xml
String contractXmlPath = contractPath + "/" + ec.getIdCardNumber() + ".xml";
String contractPathStr = JsonToXml.jsonToXml(JSON.toJSONString(ec));
FileUtil.writeString(contractPathStr, contractXmlPath, CharsetUtil.CHARSET_UTF_8);
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//客诉档案
if (fileType.equals(ArchivesTypeEnum.ELECTRONI_CUSTOMER_COMPLAINT.getValue())) {
ElectronicCustomerComplaintExportReqVO electronicCustomerComplaintExportReqVO = new ElectronicCustomerComplaintExportReqVO();
electronicCustomerComplaintExportReqVO.setRecordId(recordId);
List<ElectronicCustomerComplaintDO> electronicCustomerComplaintDOS = electronicCustomerComplaintMapper.selectList(electronicCustomerComplaintExportReqVO);
for (ElectronicCustomerComplaintDO ec:electronicCustomerComplaintDOS
) {
try {
//客诉档案文件夹
String contractPath = folderCaseNum + "/" + ec.getComplaintCode();
FileUtil.mkdir(contractPath);
//客诉档案xml
String contractXmlPath = contractPath + "/" + ec.getComplaintCode() + ".xml";
String contractPathStr = JsonToXml.jsonToXml(JSON.toJSONString(ec));
FileUtil.writeString(contractPathStr, contractXmlPath, CharsetUtil.CHARSET_UTF_8);
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
//打包zip
String zipFilePath = zipFolderStr + "/" + UUID.randomUUID() + ".zip";
File zip = ZipUtil.zip(folderPath, zipFilePath);
if (!zip.exists()) {
log.error(zipFilePath + " Failed to create zip file!");
}
//上传minio
byte[] zipBytes = Files.readAllBytes(zip.toPath());
String fileUrl = fileService.createFile(zip.getName(), null, zipBytes);
FileDO fileDO = getFileDO(fileUrl);
turnOver.setFileSize(fileDO.getSize().toString());
turnOver.setFileUrl(fileUrl);
}
//添加数据userid
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
turnOver.setDeleted(false);
turnOver.setBillType("DAYJ");
//添加数据userid
turnOver.setUserId(loginUser.getId());
turnOver.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult().toString());
turnOver.setCreateById(loginUser.getId());
turnOverMapper.insert(turnOver);
//开启审批
if (turnOver.getStatus().equals(ArchivesStatusEnum.PROCESS.getValue())) {
Map<String, Object> variables = new HashMap<>();
variables.put("billType", turnOver.getBillType());
@ -79,6 +443,48 @@ public class TurnOverServiceImpl extends MPJBaseServiceImpl<TurnOverMapper, Turn
return CommonResult.success();
}
/**
*
*
* @param foldPath
* @param fileUrl
* @throws IOException
*/
private void downloadFile(String foldPath, String fileUrl) throws Exception {
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
System.out.println("文件名: " + fileName);
// 下载保存文件的路径和文件名
String saveFilePath = foldPath + "/" + fileName;
URL url = new URL(fileUrl);
URLConnection connection = url.openConnection();
InputStream inputStream = connection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath);
BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream, 1024);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
System.out.println("文件已下载到 " + saveFilePath);
}
private FileDO getFileDO(String fileUrl) {
FilePageReqVO pageReqVO = new FilePageReqVO();
String lastSegment = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
pageReqVO.setPath(lastSegment);
PageResult<FileDO> filePage = fileService.getFilePage(pageReqVO);
FileDO fileDO = filePage.getList().get(0);
return fileDO;
}
@Override
public void updateTurnOver(TurnOverUpdateReqVO updateReqVO) {
// 校验存在

@ -77,4 +77,6 @@ public class ElectronicConsultationExportReqVO {
@Schema(description = "归档状态", example = "2")
private String fileStatus;
private Long recordId;
}

@ -76,5 +76,5 @@ public class ElectronicCustomerComplaintExportReqVO {
@Schema(description = "归档状态", example = "2")
private String fileStatus;
private Long recordId;
}

@ -62,5 +62,5 @@ public class ElectronicEmployeeExportReqVO {
@Schema(description = "归档状态", example = "2")
private String fileStatus;
private Long recordId;
}

Loading…
Cancel
Save