|
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -25,10 +27,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
@@ -92,14 +91,35 @@ public class ZsReportArchieveService {
|
|
|
}
|
|
|
//存放地点
|
|
|
if (StringUtils.isNotBlank(zsReportArchieve.getStoragePlace())){
|
|
|
- queryWrapper.eq("a.storage_place",zsReportArchieve.getStoragePlace());
|
|
|
+ queryWrapper.like("a.storage_place",zsReportArchieve.getStoragePlace());
|
|
|
}
|
|
|
//状态
|
|
|
if (StringUtils.isNotBlank(zsReportArchieve.getStatus())){
|
|
|
queryWrapper.eq("a.status",zsReportArchieve.getStatus());
|
|
|
}
|
|
|
IPage<ZsReportArchieve> list = reportArchieveMapper.findList(page,queryWrapper);
|
|
|
+ for (ZsReportArchieve record : list.getRecords()) {
|
|
|
+ if (StringUtils.isNotBlank(record.getStoragePlace())){
|
|
|
+ if (record.getStoragePlace().contains(",")){
|
|
|
+ String[] split = record.getStoragePlace().split(",");
|
|
|
+ StringBuilder vaBuilder = new StringBuilder();
|
|
|
+ for (String s : split) {
|
|
|
+ String placeValue = SpringUtil.getBean(IDictApi.class).getDictLabel(s, "storage_place", "");
|
|
|
+ if (StringUtils.isNotBlank(placeValue)) {
|
|
|
+ if (vaBuilder.length() > 0) {
|
|
|
+ vaBuilder.append(","); // 用逗号分隔每个拼接的值
|
|
|
+ }
|
|
|
+ vaBuilder.append(placeValue); // 拼接 value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setStoragePlace(vaBuilder.toString());
|
|
|
+ }else {
|
|
|
+ String placeValue = SpringUtil.getBean(IDictApi.class).getDictLabel(record.getStoragePlace(), "storage_place", "");
|
|
|
+ record.setStoragePlace(placeValue);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return list;
|
|
|
}
|
|
@@ -168,6 +188,28 @@ public class ZsReportArchieveService {
|
|
|
}
|
|
|
IPage<ZsReportArchieveExport> list = reportArchieveMapper.exportList(page,queryWrapper);
|
|
|
|
|
|
+ for (ZsReportArchieveExport record : list.getRecords()) {
|
|
|
+ if (StringUtils.isNotBlank(record.getStoragePlace())){
|
|
|
+ if (record.getStoragePlace().contains(",")){
|
|
|
+ String[] split = record.getStoragePlace().split(",");
|
|
|
+ StringBuilder vaBuilder = new StringBuilder();
|
|
|
+ for (String s : split) {
|
|
|
+ String placeValue = SpringUtil.getBean(IDictApi.class).getDictLabel(s, "storage_place", "");
|
|
|
+ if (StringUtils.isNotBlank(placeValue)) {
|
|
|
+ if (vaBuilder.length() > 0) {
|
|
|
+ vaBuilder.append(","); // 用逗号分隔每个拼接的值
|
|
|
+ }
|
|
|
+ vaBuilder.append(placeValue); // 拼接 label
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setStoragePlace(vaBuilder.toString());
|
|
|
+ }else {
|
|
|
+ String placeValue = SpringUtil.getBean(IDictApi.class).getDictLabel(record.getStoragePlace(), "storage_place", "");
|
|
|
+ record.setStoragePlace(placeValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return list;
|
|
|
|
|
@@ -207,49 +249,128 @@ public class ZsReportArchieveService {
|
|
|
}
|
|
|
//将数据进行保存
|
|
|
if (CollectionUtils.isNotEmpty(arrayList)){
|
|
|
- for (ZsReportArchieveExport reportArchieveDTO : arrayList) {
|
|
|
- add(reportArchieveDTO);
|
|
|
+ List<ZsReportArchieve> zsReportArchieves = createZsReportArchieve(arrayList);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(zsReportArchieves)){
|
|
|
+ // 每次最多插入 100 条数据
|
|
|
+ int batchSize = 100;
|
|
|
+ int totalSize = zsReportArchieves.size();
|
|
|
+
|
|
|
+ // 按批次处理插入
|
|
|
+ for (int i = 0; i < totalSize; i += batchSize) {
|
|
|
+ // 计算当前批次的结束位置
|
|
|
+ int endIndex = Math.min(i + batchSize, totalSize);
|
|
|
+ // 获取当前批次的子列表
|
|
|
+ List<ZsReportArchieve> batchList = zsReportArchieves.subList(i, endIndex);
|
|
|
+
|
|
|
+ // 执行批量插入
|
|
|
+ reportArchieveMapper.insertBatch(batchList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public void add(ZsReportArchieveExport reportArchieveDTO) throws Exception {
|
|
|
- ZsReportArchieve zsReportArchieve = new ZsReportArchieve();
|
|
|
- BeanUtils.copyProperties(reportArchieveDTO,zsReportArchieve);
|
|
|
- //业务类型
|
|
|
- if (StringUtils.isNotBlank(reportArchieveDTO.getBusinessType())){
|
|
|
- String dictValue = SpringUtil.getBean(IDictApi.class).getDictValue(reportArchieveDTO.getBusinessType(), "business_type", "");
|
|
|
- if (StringUtils.isNotBlank(dictValue)){
|
|
|
- zsReportArchieve.setBusinessType(dictValue);
|
|
|
- }
|
|
|
- }
|
|
|
- //报告文号类型
|
|
|
- String reportNo = reportArchieveDTO.getReportNo();
|
|
|
- String type = reportNo.substring(2, reportNo.lastIndexOf("("));
|
|
|
- String noType = SpringUtil.getBean(IDictApi.class).getDictValue(type, "report_no_type", "");
|
|
|
- if (StringUtils.isNotBlank(noType)){
|
|
|
- zsReportArchieve.setReportNoType(noType);
|
|
|
- }
|
|
|
- //流水号生成
|
|
|
- String currentToken = TokenProvider.getCurrentToken();
|
|
|
- OfficeDTO officeDTO = reportArchieveMapper.getOfficeDTOByName("中审江苏分所");
|
|
|
- String documentNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(officeDTO.getId(), ZsReportArchieve.BIZ_CODE,currentToken);
|
|
|
- zsReportArchieve.setArchieveNo(documentNo);
|
|
|
- //存放地点
|
|
|
- String place = reportArchieveDTO.getStoragePlace().replace(" ", "");
|
|
|
- String substring = place.substring(place.lastIndexOf("所") + 1, place.lastIndexOf("区"));
|
|
|
- String placeValue = SpringUtil.getBean(IDictApi.class).getDictValue(substring, "storage_place", "");
|
|
|
- zsReportArchieve.setStoragePlace(placeValue);
|
|
|
- //归档接收人
|
|
|
- zsReportArchieve.setArchieveResever("");
|
|
|
+ public List<ZsReportArchieve> createZsReportArchieve(ArrayList<ZsReportArchieveExport> reportArchieveExport) throws Exception {
|
|
|
+ List<ZsReportArchieve> zsReportArchieves = new ArrayList<>();
|
|
|
+ String businessTypeDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("business_type");
|
|
|
+ Map<String,Object> businessTypeValueDTOs = JSON.parseObject(businessTypeDatas, new TypeReference<Map<String,Object>>() {});
|
|
|
+
|
|
|
+ String storagePlaceDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("storage_place");
|
|
|
+ Map<String,Object> storagePlaceValueDTOs = JSON.parseObject(storagePlaceDatas, new TypeReference<Map<String,Object>>() {});
|
|
|
+
|
|
|
+ String reportNoTypeDatas = SpringUtil.getBean ( IDictApi.class ).getDictValueListMapByDict ("report_no_type");
|
|
|
+ Map<String,Object> reportNoTypeDTOs = JSON.parseObject(reportNoTypeDatas, new TypeReference<Map<String,Object>>() {});
|
|
|
|
|
|
- String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
- zsReportArchieve.setId(id);
|
|
|
|
|
|
- reportArchieveMapper.insert(zsReportArchieve);
|
|
|
+ for (ZsReportArchieveExport reportArchieveDTO : reportArchieveExport) {
|
|
|
+ ZsReportArchieve zsReportArchieve = new ZsReportArchieve();
|
|
|
+ BeanUtils.copyProperties(reportArchieveDTO,zsReportArchieve);
|
|
|
+ //业务类型
|
|
|
+ if (StringUtils.isNotBlank(reportArchieveDTO.getBusinessType())){
|
|
|
+ for (String key : businessTypeValueDTOs.keySet()) {
|
|
|
+ if(reportArchieveDTO.getBusinessType().equals(key)){
|
|
|
+ zsReportArchieve.setBusinessType(String.valueOf(businessTypeValueDTOs.get(key)));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //报告文号类型
|
|
|
+ String reportNo = reportArchieveDTO.getReportNo();
|
|
|
+ String type = reportNo.substring(2, reportNo.lastIndexOf("("));
|
|
|
+ if (StringUtils.isNotBlank(type)){
|
|
|
+ for (String key : reportNoTypeDTOs.keySet()) {
|
|
|
+ if(type.equals(key)){
|
|
|
+ zsReportArchieve.setReportNoType(String.valueOf(reportNoTypeDTOs.get(key)));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //流水号生成
|
|
|
+ String currentToken = TokenProvider.getCurrentToken();
|
|
|
+ OfficeDTO officeDTO = reportArchieveMapper.getOfficeDTOByName("中审江苏分所");
|
|
|
+ String documentNo = SpringUtil.getBean ( IWorkAttachmentApi.class ).genSerialNum(officeDTO.getId(), ZsReportArchieve.BIZ_CODE,currentToken);
|
|
|
+ zsReportArchieve.setArchieveNo(documentNo);
|
|
|
+ //存放地点
|
|
|
+ String place = reportArchieveDTO.getStoragePlace().replace(" ", "");
|
|
|
+ if (place.contains("江苏分所") && place.contains("区")){
|
|
|
+ String substring = place.substring(place.lastIndexOf("所") + 1, place.lastIndexOf("区"));
|
|
|
+ String placeValue = "";
|
|
|
+ //可能会存在多个区
|
|
|
+ if (substring.contains("区")){
|
|
|
+ String[] split = substring.split("区");
|
|
|
+ StringBuilder vaBuilder = new StringBuilder();
|
|
|
+ for (String s : split) {
|
|
|
+ String value = "";
|
|
|
+ if (StringUtils.isNotBlank(s)){
|
|
|
+ for (String key : storagePlaceValueDTOs.keySet()) {
|
|
|
+ if(s.equals(key)){
|
|
|
+ value = String.valueOf(storagePlaceValueDTOs.get(key));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(value)) {
|
|
|
+ if (vaBuilder.length() > 0) {
|
|
|
+ vaBuilder.append(","); // 用逗号分隔每个拼接的值
|
|
|
+ }
|
|
|
+ vaBuilder.append(value); // 拼接 value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ placeValue = vaBuilder.toString();
|
|
|
+ }else {
|
|
|
+ if (StringUtils.isNotBlank(substring)){
|
|
|
+ for (String key : storagePlaceValueDTOs.keySet()) {
|
|
|
+ if(substring.equals(key)){
|
|
|
+ placeValue = String.valueOf(storagePlaceValueDTOs.get(key));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ zsReportArchieve.setStoragePlace(placeValue);
|
|
|
+ }else {
|
|
|
+ zsReportArchieve.setStoragePlace("");
|
|
|
+ }
|
|
|
+
|
|
|
+ //归档接收人
|
|
|
+ zsReportArchieve.setArchieveResever("");
|
|
|
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ zsReportArchieve.setId(id);
|
|
|
+ zsReportArchieve.setCreateTime(new Date());
|
|
|
+ zsReportArchieve.setUpdateTime(new Date());
|
|
|
+ UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
+ zsReportArchieve.setCreateById(userDTO.getId());
|
|
|
+ zsReportArchieve.setUpdateById(userDTO.getId());
|
|
|
+ zsReportArchieve.setStatus("0");
|
|
|
+ zsReportArchieve.setTenantId(userDTO.getTenantDTO().getId());
|
|
|
+ zsReportArchieve.setDelFlag(0);
|
|
|
+ zsReportArchieves.add(zsReportArchieve);
|
|
|
+ }
|
|
|
|
|
|
+// reportArchieveMapper.insert(zsReportArchieve);
|
|
|
+ return zsReportArchieves;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -260,6 +381,18 @@ public class ZsReportArchieveService {
|
|
|
*/
|
|
|
public ZsReportArchieve findById(String id) {
|
|
|
ZsReportArchieve zsReportArchieve = reportArchieveMapper.findById(id);
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(zsReportArchieve)){
|
|
|
+ if (StringUtils.isNotBlank(zsReportArchieve.getStoragePlace())){
|
|
|
+ if (zsReportArchieve.getStoragePlace().contains(",")){
|
|
|
+ String[] split = zsReportArchieve.getStoragePlace().split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ strings.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ zsReportArchieve.setStoragePlaces(strings);
|
|
|
return zsReportArchieve;
|
|
|
}
|
|
|
|
|
@@ -349,6 +482,9 @@ public class ZsReportArchieveService {
|
|
|
UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
zsReportArchieve.setArchieveResever(userDTO.getId());
|
|
|
zsReportArchieve.setStatus("1");
|
|
|
+ //将存放区域转化
|
|
|
+ String result = String.join(",", reportArchieve.getStoragePlaces());
|
|
|
+ zsReportArchieve.setStoragePlace(result);
|
|
|
reportArchieveMapper.updateById(zsReportArchieve);
|
|
|
return "操作成功";
|
|
|
}
|