From 8b375fe00a241b3a769b82fe3dac8d1c9dce8a02 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 16 Jun 2022 14:36:07 +0800
Subject: [PATCH] 模拟考试修改
---
src/main/java/org/springblade/modules/social/controller/SocialController.java | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 114 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/springblade/modules/social/controller/SocialController.java b/src/main/java/org/springblade/modules/social/controller/SocialController.java
index efd7f61..44ae533 100644
--- a/src/main/java/org/springblade/modules/social/controller/SocialController.java
+++ b/src/main/java/org/springblade/modules/social/controller/SocialController.java
@@ -16,30 +16,43 @@
*/
package org.springblade.modules.social.controller;
+import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
+import org.apache.commons.codec.Charsets;
+import org.springblade.common.excel.RowWriteHandler;
+import org.springblade.common.utils.DesensitizedUtil;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.social.entity.Social;
import org.springblade.modules.social.excel.SocialExcel;
import org.springblade.modules.social.excel.SocialImporter;
import org.springblade.modules.social.service.ISocialService;
import org.springblade.modules.social.vo.SocialVO;
+import org.springblade.modules.system.excel.UserExcel;
+import org.springblade.modules.system.service.MyAsyncService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* 控制器
@@ -54,6 +67,8 @@
public class SocialController extends BladeController {
private final ISocialService socialService;
+
+ private final MyAsyncService myAsyncService;
/**
* 详情
@@ -95,8 +110,57 @@
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入social")
public R save(@Valid @RequestBody Social social) {
- socialService.upSoil(social.getCardid());
- return R.status(socialService.save(social));
+ //修改为已参保
+ socialService.upSoil(social.getNamb());
+ Social social1 = Objects.requireNonNull(BeanUtil.copy(social, Social.class));
+ //脱敏处理
+ if (null!=social.getNation() && !social.getNation().equals("")){
+ social1.setNation("***");
+ }
+ if (null!=social.getTelephone() && !social.getTelephone().equals("")){
+ social1.setTelephone(DesensitizedUtil.desensitizedPhoneNumber(social.getTelephone()));
+ }
+ if (null!=social.getCardid() && !social.getCardid().equals("")){
+ social1.setCardid(DesensitizedUtil.desensitizedIdNumberBy4(social.getCardid()));
+ }
+ if (null!=social.getResidence() && !social.getResidence().equals("")){
+ social1.setResidence(DesensitizedUtil.desensitizedAddress(social.getResidence()));
+ }
+ if (null!=social.getAddress() && !social.getAddress().equals("")){
+ social1.setAddress(DesensitizedUtil.desensitizedAddress(social.getAddress()));
+ }
+ if (null!=social.getNature() && !social.getNature().equals("")){
+ social1.setNature("***");
+ }
+ if (null!=social.getAmount()){
+ social1.setAmount(null);
+ }
+ if (null!=social.getInsuredtime()){
+ social1.setInsuredtime(null);
+ }
+ //新增社保记录
+ boolean save = socialService.save(social1);
+ if (save){
+ //内网同步
+ String s = "insert into sys_socil(" +
+ "id,namb,sex,nation,telephone,cardid,residence,address," +
+ "nature,amount,insuredtime,deptid) " +
+ "values(" + "'" + social1.getId() + "'" + "," +
+ "'" + social.getNamb() + "'" + "," +
+ "'" + social.getSex() + "'" + "," +
+ "'" + social.getNation() + "'" + "," +
+ "'" + social.getTelephone() + "'" + "," +
+ "'" + social.getCardid() + "'" + "," +
+ "'" + social.getResidence() + "'" + "," +
+ "'" + social.getAddress() + "'" + "," +
+ "'" + social.getNature() + "'" + "," +
+ "'" + social.getAmount() + "'" + "," +
+ "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(social.getInsuredtime()) + "'" +
+ "," + "'" + social.getDeptid() + "'"
+ + ")";
+ myAsyncService.FTP(s);
+ }
+ return R.status(save);
}
/**
@@ -127,6 +191,12 @@
@ApiOperationSupport(order = 8)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+ //内网同步
+ List<Long> list = Func.toLongList(ids);
+ list.forEach(id -> {
+ String s1 = "delete from sys_socil where id = " + "'" + id + "'";
+ myAsyncService.FTP(s1);
+ });
return R.status(socialService.removeByIds(Func.toLongList(ids)));
}
@@ -136,8 +206,8 @@
*/
@PostMapping("import-user")
@ApiOperationSupport(order = 12)
- public R importUser(MultipartFile file, Integer isCovered,String deptid) {
- SocialImporter socialImporter = new SocialImporter(socialService, isCovered == 0,deptid);
+ public R importUser(MultipartFile file,String deptid) {
+ SocialImporter socialImporter = new SocialImporter(socialService, false,deptid);
ExcelUtil.save(file, socialImporter, SocialExcel.class);
return R.success("操作成功");
}
@@ -148,8 +218,46 @@
@GetMapping("export-template")
@ApiOperationSupport(order = 14)
@ApiOperation(value = "导出模板")
- public void exportUser(HttpServletResponse response) {
+ public void exportUser(HttpServletResponse response) throws IOException, ParseException {
List<SocialExcel> list = new ArrayList<>();
- ExcelUtil.export(response, "社保数据模板", "社保数据模板", list, SocialExcel.class);
+ SocialExcel socialExcel = new SocialExcel();
+ socialExcel.setNamb("张三");
+ socialExcel.setSex("男");
+ socialExcel.setNation("汉");
+ socialExcel.setBirthday(new SimpleDateFormat("yyyy/MM/dd").parse("1999/5/1"));
+ socialExcel.setTelephone("13112341234");
+ socialExcel.setCardid("360XXX19XXXXXX****");
+ socialExcel.setResidence("江西省南昌市***********");
+ socialExcel.setAddress("江西省南昌市***********");
+ socialExcel.setNature("城镇");
+ socialExcel.setAmount("1000.00");
+ socialExcel.setInsuredtime(new SimpleDateFormat("yyyy/MM/dd").parse("2020/5/1"));
+ list.add(socialExcel);
+
+ SocialExcel socialExcel1 = new SocialExcel();
+ socialExcel1.setNamb("李四");
+ socialExcel1.setSex("女");
+ socialExcel1.setNation("汉");
+ socialExcel1.setBirthday(new SimpleDateFormat("yyyy/MM/dd").parse("1999/5/1"));
+ socialExcel1.setTelephone("13112341234");
+ socialExcel1.setCardid("360XXX19XXXXXX****");
+ socialExcel1.setResidence("江西省南昌市***********");
+ socialExcel1.setAddress("江西省南昌市***********");
+ socialExcel1.setNature("农村");
+ socialExcel1.setAmount("1000.00");
+ socialExcel1.setInsuredtime(new SimpleDateFormat("yyyy/MM/dd").parse("2020/5/1"));
+ list.add(socialExcel1);
+ String fileName = null;
+ try {
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
+ fileName = URLEncoder.encode("社保数据模板"+ DateUtil.time(), Charsets.UTF_8.name());
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+ //修改单元格格式为文本格式
+ EasyExcel.write(response.getOutputStream(), SocialExcel.class).sheet("社保数据模板").registerWriteHandler(new RowWriteHandler()).doWrite(list);
+ } catch (Throwable var6) {
+ throw var6;
+ }
+// ExcelUtil.export(response, "社保数据模板", "社保数据模板", list, SocialExcel.class);
}
}
--
Gitblit v1.9.3