|
|
@@ -3,22 +3,31 @@ package com.zhongshu.card.server.core.service.school;
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
+import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.zhongshu.card.client.model.base.IDsParam;
|
|
|
+import com.zhongshu.card.client.model.base.OidModel;
|
|
|
+import com.zhongshu.card.client.model.base.ProjectOidParam;
|
|
|
import com.zhongshu.card.client.model.org.OidAboutInfo;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserSearch;
|
|
|
import com.zhongshu.card.client.model.school.*;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
import com.zhongshu.card.client.type.school.CardType;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
|
|
|
import com.zhongshu.card.server.core.dao.school.CardInfoPoolDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfoPool;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
+import com.zhongshu.card.server.core.util.ExcelUtils;
|
|
|
+import com.zhongshu.card.server.core.util.excel.CommonExeclParam;
|
|
|
+import com.zhongshu.card.server.core.util.excel.CommonExeclTd;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -26,6 +35,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
@@ -33,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -55,6 +66,9 @@ public class CardInfoPoolService extends SuperService {
|
|
|
@Autowired
|
|
|
OrganizationManagerServiceImpl organizationManagerService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrganizationUserDao organizationUserDao;
|
|
|
+
|
|
|
/**
|
|
|
* 保存卡片信息
|
|
|
*
|
|
|
@@ -90,15 +104,14 @@ public class CardInfoPoolService extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(temp)) {
|
|
|
return ResultContent.buildFail(String.format("卡号已存在:%s", param.getCode()));
|
|
|
}
|
|
|
+ entity.setIsUsed(Boolean.FALSE);
|
|
|
}
|
|
|
- BeanUtils.copyProperties(param, entity);
|
|
|
+ BeanUtils.copyProperties(param, entity, "isUsed");
|
|
|
+
|
|
|
+ entity.setOid(oid);
|
|
|
entity.setProjectOid(projectOid);
|
|
|
entity.setAboutAuthType(oidAboutInfo.getAuthType());
|
|
|
entity.setAboutOid(oidAboutInfo.getOid());
|
|
|
-
|
|
|
- if (entity.getIsUsed() == null) {
|
|
|
- entity.setIsUsed(Boolean.FALSE);
|
|
|
- }
|
|
|
cardInfoPoolDao.save(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -113,7 +126,6 @@ public class CardInfoPoolService extends SuperService {
|
|
|
public ResultContent<Page<CardInfoPoolModel>> page(CardInfoPoolSearch param, Pageable pageable) {
|
|
|
checkParamOid(param);
|
|
|
initOidSearchParamNoCheckOid(param);
|
|
|
-
|
|
|
Page<CardInfoPool> page = cardInfoPoolDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
@@ -196,22 +208,19 @@ public class CardInfoPoolService extends SuperService {
|
|
|
HttpServletRequest request,
|
|
|
HttpServletResponse response,
|
|
|
MultipartFile file,
|
|
|
- String oid
|
|
|
- ) {
|
|
|
- // 当前的机构
|
|
|
- if (StringUtils.isEmpty(oid)) {
|
|
|
- oid = getCurrentOid();
|
|
|
- }
|
|
|
+ OidModel param) {
|
|
|
+ String oid = param.getOid();
|
|
|
Assert.hasText(oid, "oid不能为空");
|
|
|
|
|
|
OidAboutInfo oidAboutInfo = organizationManagerService.getOidAboutInfo(oid);
|
|
|
String projectOid = oidAboutInfo.getProjectOid();
|
|
|
- String schoolOid = oidAboutInfo.getSchoolOid();
|
|
|
|
|
|
ImportResultModel model = new ImportResultModel();
|
|
|
try {
|
|
|
- int startRow = 2;
|
|
|
+ int startRow = 3;
|
|
|
ImportParams params = new ImportParams();
|
|
|
+ params.setHeadRows(1);
|
|
|
+ params.setTitleRows(1);
|
|
|
List<CardInfoPoolImportParam> list = ExcelImportUtil.importExcel(file.getInputStream(), CardInfoPoolImportParam.class, params);
|
|
|
model.setTotal(list.size());
|
|
|
|
|
|
@@ -230,6 +239,14 @@ public class CardInfoPoolService extends SuperService {
|
|
|
failDetails.add(String.format("第%d行卡片类型不能为空", startRow));
|
|
|
}
|
|
|
|
|
|
+ if (b && StringUtils.isNotEmpty(param1.getCardType())) {
|
|
|
+ CardType cardType = CommonUtil.getCardTypeByStr(param1.getCardType());
|
|
|
+ if (cardType == null) {
|
|
|
+ b = false;
|
|
|
+ failDetails.add(String.format("第%d行卡片类型不正确", startRow));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (b) {
|
|
|
// 检查是否已存在 code
|
|
|
boolean exit = cardInfoPoolDao.existsByCode(param1.getCode());
|
|
|
@@ -242,8 +259,9 @@ public class CardInfoPoolService extends SuperService {
|
|
|
// 验证通过
|
|
|
CardInfoPool pool = new CardInfoPool();
|
|
|
initEntity(pool);
|
|
|
+ param1.setCode(param1.getCode().trim());
|
|
|
BeanUtils.copyProperties(param1, pool, "cardType");
|
|
|
- pool.setSchoolOid(schoolOid);
|
|
|
+ pool.setSchoolOid("");
|
|
|
pool.setProjectOid(projectOid);
|
|
|
pool.setOid(oid);
|
|
|
pool.setAboutOid(oidAboutInfo.getOid());
|
|
|
@@ -268,6 +286,57 @@ public class CardInfoPoolService extends SuperService {
|
|
|
return ResultContent.buildSuccess(model);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出项目用户
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param param
|
|
|
+ */
|
|
|
+ public void exportProjectCard(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ CardInfoPoolSearch param) {
|
|
|
+ Assert.hasText(param.getOid(), "oid不能为空");
|
|
|
+
|
|
|
+ Organization organization = organizationDao.findTopByOid(param.getOid());
|
|
|
+ Pageable pageable = PageRequest.of(0, Integer.MAX_VALUE);
|
|
|
+ Page<CardInfoPool> page = cardInfoPoolDao.page(pageable, param);
|
|
|
+
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ if (page.getContent() != null) {
|
|
|
+ List<CardInfoPool> list = page.getContent();
|
|
|
+ maps = list.stream().map(it -> {
|
|
|
+ Map<String, Object> map = BeanUtil.bean2Map(it);
|
|
|
+ String cardStr = it.getCardType().getRemark();
|
|
|
+ map.put("cardStr", cardStr);
|
|
|
+ String useStr = "未使用";
|
|
|
+ if (it.getIsUsed() != null && it.getIsUsed()) {
|
|
|
+ useStr = "已使用";
|
|
|
+ }
|
|
|
+ map.put("useStr", useStr);
|
|
|
+ // 作废状态
|
|
|
+ String cancelStr = "";
|
|
|
+ if (it.getCardCancelState() != null) {
|
|
|
+ cancelStr = it.getCardCancelState().getRemark();
|
|
|
+ }
|
|
|
+ map.put("cancelStr", cancelStr);
|
|
|
+ return map;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ CommonExeclParam execlParam = new CommonExeclParam();
|
|
|
+ execlParam.setTitle(String.format("%s卡片数据", organization.getName()));
|
|
|
+ execlParam.setStartRow(2);
|
|
|
+ execlParam.setDatas(maps);
|
|
|
+
|
|
|
+ List<CommonExeclTd> tds = new ArrayList<>();
|
|
|
+ tds.add(CommonExeclTd.build("卡号", "code"));
|
|
|
+ tds.add(CommonExeclTd.build("卡片类型", "cardStr"));
|
|
|
+ tds.add(CommonExeclTd.build("使用状态", "useStr"));
|
|
|
+ tds.add(CommonExeclTd.build("作废状态", "cancelStr"));
|
|
|
+ execlParam.setTds(tds);
|
|
|
+ ExcelUtils.commonExecuteExcel(request, response, execlParam);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 搜索卡片
|
|
|
*
|