Commit 4f452ff9 by 翁国栋

8小时后台--

异常输出记录到日志
parent 902d8608
......@@ -197,3 +197,4 @@ ALTER TABLE `insure_product`
ALTER TABLE `insure_policy`
ADD COLUMN `policy_pay_type` int(11) NOT NULL DEFAULT 1 COMMENT '1在线支付 2预付款 3线下支付' AFTER `create_time`,
ADD COLUMN `pay_id` int(11) NULL DEFAULT NULL COMMENT 'insure_pay表的id' AFTER `policy_pay_type`;
......@@ -58,5 +58,5 @@ public class AttendanceAssistant implements Serializable{
int restdayclock;//休息日打卡
String PagetransferDate;//页面传输修改日期
String transferDate;//页面传输修改日期
}
......@@ -160,7 +160,7 @@ public class CallBackContorll {
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("增员核保回调异常:",e);
throw new CustomException("增员核保回调异常");
} finally {
Map trueMap = Maps.newHashMap();
......@@ -256,7 +256,7 @@ public class CallBackContorll {
insurePolicy.updateById();
} catch (Exception e) {
e.printStackTrace();
log.error("保全增员申请回调异常:",e);
throw new CustomException("保全增员申请回调异常");
} finally {
Map trueMap = Maps.newHashMap();
......@@ -328,7 +328,7 @@ public class CallBackContorll {
.returnCode(dataMap.get("errcode").toString()).policyId(insurePay.getPolicyId()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
}
} catch (Exception e) {
e.printStackTrace();
log.error("投保支付收银台回调异常:",e);
throw new CustomException("投保支付收银台回调异常");
} finally {
Map map = Maps.newHashMap();
......@@ -383,7 +383,7 @@ public class CallBackContorll {
InsureLog.builder().type(7).createTime(new Date()).requestType(1).returnBody(sb.toString()).requestPath(getPolicyUrl)
.returnCode(callBack.getStatus()).policyId(insurePay.getPolicyId()).returnMsg(callBack.getErr_msg()).build().insert();
} catch (Exception e) {
e.printStackTrace();
log.error("保单出单回调:",e);
throw new CustomException("保单出单回调");
} finally {
Map map = Maps.newHashMap();
......@@ -415,7 +415,7 @@ public class CallBackContorll {
InsureLog.builder().type(7).createTime(new Date()).requestType(1).returnBody(sb.toString()).requestPath(base_api_url + "/callBack/policy/batchPayCallback")
.returnCode(callBack.getPay_status()).policyId(insurePay.getPolicyId()).returnMsg("确认支付成功,支付方式:" + insurePay.getPayType() + ",支付金额:" + insurePay.getAmount()).build().insert();
} catch (Exception e) {
e.printStackTrace();
log.error("增员支付回调异常:",e);
throw new CustomException("增员支付回调异常");
} finally {
Map map = Maps.newHashMap();
......
......@@ -46,6 +46,7 @@ import org.springframework.web.multipart.MultipartFile;
@Transactional
@RequestMapping(value = "/insureApplicant", produces = {"application/json"})
public class InsureApplicantController {
private static final Logger log = LoggerFactory.getLogger(InsureApplicantController.class);
@PostMapping("/insureApplicationSetting")
@ApiOperation(value = "设置投保人", httpMethod = "POST", notes = "投保申请")
......@@ -56,7 +57,7 @@ public class InsureApplicantController {
params.updateById();
return ResultUtil.data(params);
} catch (Exception e) {
e.printStackTrace();
log.error("设置投保人异常:",e);
throw new CustomException("设置投保人异常");
}
}
......@@ -75,7 +76,7 @@ public class InsureApplicantController {
}
return ResultUtil.data(insureApplicant);
} catch (Exception e) {
e.printStackTrace();
log.error("获取投保人异常:",e);
throw new CustomException("获取投保人异常");
}
}
......@@ -107,7 +108,7 @@ public class InsureApplicantController {
}
return ResultUtil.data(insureApplicant);
} catch (Exception e) {
e.printStackTrace();
log.error("获取投保人异常:",e);
throw new CustomException("获取投保人异常");
}
}
......
......@@ -399,7 +399,7 @@ public class InsureContorll {
}
return ResultUtil.error("投保错误");
}catch (Exception e){
e.printStackTrace();
log.error("投保异常:",e);
throw new CustomException("投保异常");
}
}
......@@ -468,7 +468,6 @@ public class InsureContorll {
.createTime(new Date())
.insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
log.info("增员异常:policyDateStart:"+insureDto.getPolicyDateStart()+"policyDateEnd:"+insureDto.getPolicyDateEnd());
throw new CustomException("增员异常");
}
......@@ -486,7 +485,7 @@ public class InsureContorll {
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).build().insert();
return ResultUtil.error(dataMap.get("errmsg").toString());
}catch (Exception e){
e.printStackTrace();
log.error("增员异常:",e);
throw new CustomException("增员异常");
}
}
......@@ -501,7 +500,7 @@ public class InsureContorll {
map.put("total", insurePolicyMapper.totalPolicy(policyDto));
return ResultUtil.data(map);
}catch (Exception e){
e.printStackTrace();
log.error("获取保单列表异常:",e);
throw new CustomException("获取保单列表异常");
}
}
......@@ -524,7 +523,7 @@ public class InsureContorll {
// map.put("category",categoryList.stream().map(InsureUser::getBenefitOccupationCategory).toArray());
return ResultUtil.data(policyDto);
}catch (Exception e){
e.printStackTrace();
log.error("获取保单信息异常:",e);
throw new CustomException("获取保单信息异常");
}
}
......@@ -615,7 +614,7 @@ public class InsureContorll {
.createTime(new Date())
.status("1").insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
log.error("获取保单信息异常:",e);
}
y.setIsInsure(1);
y.insertOrUpdate();
......@@ -630,7 +629,7 @@ public class InsureContorll {
}
return ResultUtil.data("成功");
}catch (Exception e){
e.printStackTrace();
log.error("保全替换异常:",e);
throw new CustomException("保全替换异常");
}
}
......@@ -661,20 +660,20 @@ public class InsureContorll {
sos.write(b);
}
} catch (MalformedURLException e) {
e.printStackTrace();
log.error("下载电子保单:",e);
} catch (IOException e) {
e.printStackTrace();
log.error("下载电子保单:",e);
} finally {
try {
sos.close();
} catch (IOException e) {
e.printStackTrace();
log.error("下载电子保单:",e);
}
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
log.error("下载电子保单:",e);
}
}
}
......@@ -740,7 +739,7 @@ public class InsureContorll {
return ResultUtil.success();
}catch (Exception e){
e.printStackTrace();
log.error("一键校验异常:",e);
throw new CustomException("一键校验异常");
}
}
......@@ -814,7 +813,8 @@ public class InsureContorll {
try {
y.setBirthday(dtf.parse(idNo.substring(6, 14)));
} catch (ParseException e) {
e.printStackTrace();
log.error("一键校验异常:",e);
throw new CustomException("一键校验异常");
}
y.setZjNum(idNo);
break;
......@@ -849,7 +849,8 @@ public class InsureContorll {
List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, orgCode));
} catch (IOException e) {
e.printStackTrace();
log.error("一键校验异常:",e);
throw new CustomException("一键校验异常");
}
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) {
......@@ -916,7 +917,8 @@ public class InsureContorll {
try {
y.setBirthday(dtf.parse(idNo.substring(6, 14)));
} catch (ParseException e) {
e.printStackTrace();
log.error("导入用户:",e);
throw new CustomException("导入用户");
}
y.setZjNum(idNo);
break;
......@@ -951,7 +953,8 @@ public class InsureContorll {
List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, userBean.getOrgCode()));
} catch (IOException e) {
e.printStackTrace();
log.error("导入用户:",e);
throw new CustomException("导入用户");
}
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) {
......@@ -1145,7 +1148,8 @@ public class InsureContorll {
InsureLog.builder().requestParam(JSONObject.toJSONString(map)).type(9).createTime(new Date()).requestType(2).returnBody(data).requestPath(policyDetailUrl)
.returnCode(returnMap.get("errcode").toString()).returnMsg(returnMap.get("errmsg").toString()).policyId(policy.getId()).build().insert();
} catch (IOException e) {
e.printStackTrace();
log.error("导入保单:",e);
throw new CustomException("导入保单");
}
return ResultUtil.data("成功导入");
}
......@@ -1251,11 +1255,11 @@ public class InsureContorll {
}
return ResultUtil.data(userList);
} catch (IOException e) {
e.printStackTrace();
log.error("导入被保人异常:",e);
}
return ResultUtil.error("导入失败");
}catch (Exception e) {
e.printStackTrace();
log.error("导入被保人异常:",e);
throw new CustomException("导入被保人异常");
}
}
......@@ -1294,7 +1298,7 @@ public class InsureContorll {
.returnMsg("请求投保支付").policyId(insurePolicy.getId()).build().insert();
return ResultUtil.data(builder.build());
} catch (URISyntaxException e) {
e.printStackTrace();
log.error("请求错误:",e);
return ResultUtil.error("请求错误");
}
} else {
......@@ -1313,7 +1317,7 @@ public class InsureContorll {
return ResultUtil.data(importPayInfo.get("pay_url").toString() + "&jump_url=" + base_api_url + "/callBack/policy/payStatus?policyId=" + insurePolicy.getId() + "&notify_url=" + base_api_url + "/callBack/policy/batchPayCallback");
}
}catch (Exception e){
e.printStackTrace();
log.error("重新发起支付异常:",e);
throw new CustomException("重新发起支付异常");
}
......@@ -1371,8 +1375,8 @@ public class InsureContorll {
/*生成一个支付链接返回到前台*/
return ResultUtil.error("取消失败,请重新再来");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("重新发起支付异常");
log.error("取消支付异常:",e);
throw new CustomException("取消支付异常");
}
}
......@@ -1425,13 +1429,15 @@ public class InsureContorll {
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
log.error("生成投保文件异常:",e);
throw new CustomException("生成投保文件异常");
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
log.error("生成投保文件异常:",e);
throw new CustomException("生成投保文件异常");
}
}
......@@ -1483,13 +1489,15 @@ public class InsureContorll {
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
log.error("生成保全增员文件异常:",e);
throw new CustomException("生成保全增员文件异常");
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
log.error("生成保全增员文件异常:",e);
throw new CustomException("生成保全增员文件异常");
}
}
return url;
......@@ -1554,13 +1562,15 @@ public class InsureContorll {
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
log.error("生成保全替换文件异常:",e);
throw new CustomException("生成保全替换文件异常");
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
log.error("生成保全替换文件异常:",e);
throw new CustomException("生成保全替换文件异常");
}
}
return url;
......
......@@ -504,7 +504,7 @@ public class ExcelUtils {
} else if (xssfCell.getCellTypeEnum() == CellType.BOOLEAN) {
return String.valueOf(xssfCell.getBooleanCellValue());
} else {
return xssfCell.getStringCellValue();
return xssfCell.getStringCellValue().trim();
}
}
}
......
......@@ -8,11 +8,15 @@ import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import cn.timer.api.config.sftp.SftpConfiguration;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jcraft.jsch.ChannelSftp;
import io.swagger.models.auth.In;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.jce.exception.ExtIOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
......@@ -77,6 +81,11 @@ public class OSSUtil {
@Value("${zip.path}")
private String zipPath;
@Autowired
private SftpConfiguration config;
/**
* 1.创建储存空间 sout控制台輸出 储存空间名
*
......@@ -594,10 +603,10 @@ public class OSSUtil {
String Suffix;
try {
File folder = new File(zipPath);
if(!folder.exists()&& !folder .isDirectory()){
if (!folder.exists() && !folder.isDirectory()) {
folder.mkdirs();
}
fos = new FileOutputStream(zipPath+fileName);
fos = new FileOutputStream(zipPath + fileName);
zos = new ZipOutputStream(fos);
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
for (String m : urlMap.keySet()) {
......@@ -641,4 +650,68 @@ public class OSSUtil {
}
return fileName;
}
/**
* @Author wgd
* @Description 获取OSS文件字符流
* @Date 2021/12/2 18:06
**/
private Map getOssFileList(Map<String, String> urlMap) throws IOException {
Map<String, InputStream> map = Maps.newHashMap();
BufferedInputStream inputStream;
OSSObject ossObject;
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
for (String m : urlMap.keySet()) {
ossObject = ossClient.getObject(bucketName, urlMap.get(m));
inputStream = new BufferedInputStream(ossObject.getObjectContent());
String suffix = urlMap.get(m).substring(urlMap.get(m).lastIndexOf("."));
map.put(m + urlMap.get(m), inputStream);
}
ossClient.shutdown();
return map;
}
private Map getFtpFileList(Map<String, String> urlMap) throws IOException {
Map<String, InputStream> map = Maps.newHashMap();
InputStream inputStream;
for (String m : urlMap.keySet()) {
File file = new File(urlMap.get(m));
inputStream = new FileInputStream(file);
map.put(m, inputStream);
}
return map;
}
public String newZip(Map<String, String> ossMap, Map<String, String> ftpMap) throws IOException {
Map<String, InputStream> ossNewMap = getOssFileList(ossMap);
Map<String, InputStream> ftpNewMap = getFtpFileList(ftpMap);
ossNewMap.putAll(ftpNewMap);
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String fileName = dateFormat.format(new Date()) + ".zip";
FileOutputStream fos = null;
ZipOutputStream zos = null;
InputStream inputStream = null;
for (String m : ossNewMap.keySet()) {
ZipEntry entry = new ZipEntry(m);
try {
zos.putNextEntry(entry);
int nNumber;
byte[] buffer = new byte[4096];
while ((nNumber = ossNewMap.get(m).read(buffer)) > 0) {
zos.write(buffer, 0, nNumber);
}
} catch (IOException e) {
throw new IOException("写入失败");//TODO 应作为自定义异常
} finally {
try {
inputStream.close();
} catch (IOException e) {
throw new IOException("关闭失败");//TODO 应作为自定义异常
}
}
}
return fileName;
}
}
spring:
profiles:
active: test
active: dev
#active: '@environment@'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment