|
@@ -14,8 +14,12 @@ import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
+import com.zhongzheng.common.utils.file.FileUtils;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.wisdom.SignatureUtil;
|
|
|
+import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
+import com.zhongzheng.modules.alioss.vo.FileBean;
|
|
|
import com.zhongzheng.modules.alisms.vo.ResultBean;
|
|
|
import com.zhongzheng.modules.base.service.IProfileTpService;
|
|
|
import com.zhongzheng.modules.base.vo.ProfileTpVo;
|
|
@@ -107,11 +111,14 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -133,6 +140,8 @@ public class WisdomServiceImpl implements IWisdomService {
|
|
|
|
|
|
private String getCentersListUrl = "/exam/api/centers";
|
|
|
|
|
|
+ private String batchUserUrl = "/exam/api/examinees";
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
@@ -142,6 +151,9 @@ public class WisdomServiceImpl implements IWisdomService {
|
|
|
@Autowired
|
|
|
private IUserSubscribeService iUserSubscribeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OssService ossService;
|
|
|
+
|
|
|
@Override
|
|
|
public String authorization() {
|
|
|
String key = "WISDOM_AUTH_CODE";
|
|
@@ -206,7 +218,6 @@ public class WisdomServiceImpl implements IWisdomService {
|
|
|
|
|
|
@Override
|
|
|
public void syncApplyUserInfo(Long applyId) {
|
|
|
-
|
|
|
List<UserSubscribeVo> list = iUserSubscribeService.selectApplyUserList(applyId);
|
|
|
Map<Long,CenterVo> cMap = new HashMap<>();
|
|
|
List<CenterVo> cList = new ArrayList<>();
|
|
@@ -235,6 +246,7 @@ public class WisdomServiceImpl implements IWisdomService {
|
|
|
centerVo.setExaminees(examinees);
|
|
|
centerVo.setCenterId(vo.getCenterId());
|
|
|
centerVo.setExamCode(vo.getSiteCode());
|
|
|
+ centerVo.setZipFileName(vo.getApplyName()+"考生证件照");
|
|
|
cMap.put(vo.getCenterId(),centerVo);
|
|
|
}
|
|
|
}
|
|
@@ -242,11 +254,59 @@ public class WisdomServiceImpl implements IWisdomService {
|
|
|
while (iterator.hasNext()) {
|
|
|
Long key = iterator.next();
|
|
|
CenterVo vo = cMap.get(key);
|
|
|
- for(ExamineesVo userVo : vo.getExaminees()){
|
|
|
-
|
|
|
+ String filename = FileUtils.encodingZipFilename(vo.getZipFileName());
|
|
|
+ String zipFile = FileUtils.getZipAbsoluteFile(filename);
|
|
|
+ System.out.println(zipFile);
|
|
|
+ try {
|
|
|
+ ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream(zipFile));
|
|
|
+ List<FileBean> fileBeanList = new ArrayList<>();
|
|
|
+ for(ExamineesVo userVo : vo.getExaminees()){
|
|
|
+ FileBean f1 = new FileBean();
|
|
|
+ f1.setPath(userVo.getIdCardImg1());
|
|
|
+ f1.setFileName(userVo.getExamineeCode()+"_0.jpg");
|
|
|
+ FileBean f2 = new FileBean();
|
|
|
+ f2.setPath(userVo.getIdCardImg2());
|
|
|
+ f2.setFileName(userVo.getExamineeCode()+"_1.jpg");
|
|
|
+ fileBeanList.add(f1);
|
|
|
+ fileBeanList.add(f2);
|
|
|
+ }
|
|
|
+ System.out.println(fileBeanList);
|
|
|
+ ossService.zipWisdomDownload(fileBeanList,outStream);
|
|
|
+ outStream.close();
|
|
|
+ byte[] dataByte = ToolsUtils.getBytesByFile(zipFile);
|
|
|
+ // vo.setExamineeZipFiles();
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println(e.getMessage() + "压缩");
|
|
|
}
|
|
|
cList.add(vo);
|
|
|
}
|
|
|
+ String url = host + batchUserUrl;
|
|
|
+ String auth_code = authorization();
|
|
|
+ List<Map<String, Object>> paramMapList = new ArrayList<>();
|
|
|
+ for(CenterVo vo : cList){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("centerId",vo.getCenterId());
|
|
|
+ map.put("examCode",vo.getExamCode());
|
|
|
+ map.put("examinees",vo.getExaminees());
|
|
|
+ map.put("zipFileName",vo.getZipFileName());
|
|
|
+ // map.put("examineeZipFiles",vo.getExamineeZipFiles());
|
|
|
+ paramMapList.add(map);
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ String signature = SignatureUtil.createSignature(paramMapList, appid);
|
|
|
+ /*JSONObject obj = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ jsonArray.add(paramMapList);*/
|
|
|
+ Map<String, String> hearders = new HashMap<>();
|
|
|
+ hearders.put("auth_code", auth_code);
|
|
|
+ hearders.put("appid", appid);
|
|
|
+ hearders.put("sign", signature);
|
|
|
+ System.out.println(signature);
|
|
|
+ String result = HttpUtils.sendPostJsonHeader(url,JSON.toJSONString(paramMapList),hearders);
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|