From df878618a8882fc057a5863738df43e1fcd878ea Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Wed, 14 Sep 2022 08:48:06 +0800
Subject: [PATCH] 密码修改

---
 src/main/java/org/springblade/modules/zc/controller/ZcController.java |  333 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 317 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/springblade/modules/zc/controller/ZcController.java b/src/main/java/org/springblade/modules/zc/controller/ZcController.java
index f6b4315..79d0cd6 100644
--- a/src/main/java/org/springblade/modules/zc/controller/ZcController.java
+++ b/src/main/java/org/springblade/modules/zc/controller/ZcController.java
@@ -22,12 +22,17 @@
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
+import org.springblade.common.utils.DesensitizedUtil;
+import org.springblade.common.vo.DeptVo;
 import org.springblade.core.boot.ctrl.BladeController;
 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.DigestUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.system.service.IDeptService;
 import org.springblade.modules.system.service.IUserService;
 import org.springblade.modules.zc.entity.Zc;
 import org.springblade.modules.zc.service.IZcService;
@@ -37,10 +42,12 @@
 
 import javax.validation.Valid;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 
 /**
- *  控制器
+ * 控制器
  *
  * @author BladeX
  * @since 2020-09-08
@@ -54,6 +61,8 @@
 	private final IZcService zcService;
 
 	private IUserService iUserService;
+
+	private final IDeptService deptFeignApi;
 
 	/**
 	 * 详情
@@ -84,8 +93,75 @@
 	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "分页", notes = "传入zc")
 	public R<IPage<ZcVO>> page(ZcVO zc, Query query) {
-		IPage<ZcVO> pages = zcService.selectZcPage(Condition.getPage(query), zc);
-		return R.data(pages);
+		//获取部门数据
+		List<DeptVo> deptVos = deptFeignApi.selDeptList();
+
+		//获取辖区数据
+		List<DeptVo> xqVos = deptFeignApi.selXQList();
+
+		IPage<ZcVO> page = zcService.selectZcPage(Condition.getPage(query), zc);
+		for (int j = 0; j < page.getRecords().size(); j++) {
+			if (page.getRecords().get(j).getDeptid() != null && !page.getRecords().get(j).getDeptid().equals("")) {
+				String[] split = page.getRecords().get(j).getDeptid().split(",");
+				List<String> list = Arrays.asList(split);
+				StringBuffer deptNameBuiffer = new StringBuffer();
+				//数据匹配封装
+				for (String deptId : list) {
+					for (DeptVo deptVo : deptVos) {
+						if (deptId.equals(deptVo.getId().toString())) {
+							deptNameBuiffer.append(deptVo.getDeptName()).append(",");
+						}
+					}
+				}
+				//封装部门名称数据
+				if (deptNameBuiffer.length() > 0) {
+					page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0, deptNameBuiffer.length() - 1));
+				}
+
+			}
+		}
+
+		for (int j = 0; j < page.getRecords().size(); j++) {
+			if (page.getRecords().get(j).getJurisdiction() != null && !page.getRecords().get(j).getJurisdiction().equals("")) {
+				String[] split = page.getRecords().get(j).getJurisdiction().split(",");
+				List<String> list = Arrays.asList(split);
+				StringBuffer deptNameBuiffer = new StringBuffer();
+				//数据匹配封装
+				for (String deptId : list) {
+					for (DeptVo deptVo : xqVos) {
+						if (deptId.equals(deptVo.getId().toString())) {
+							deptNameBuiffer.append(deptVo.getDeptName()).append(",");
+						}
+					}
+				}
+				//封装部门名称数据
+				if (deptNameBuiffer.length() > 0) {
+					page.getRecords().get(j).setXQName(deptNameBuiffer.substring(0, deptNameBuiffer.length() - 1));
+				}
+			}
+		}
+
+		for (int j = 0; j < page.getRecords().size(); j++) {
+			if (page.getRecords().get(j).getWorkjurisdiction() != null && !page.getRecords().get(j).getWorkjurisdiction().equals("")) {
+				String[] split = page.getRecords().get(j).getWorkjurisdiction().split(",");
+				List<String> list = Arrays.asList(split);
+				StringBuffer deptNameBuiffer = new StringBuffer();
+				//数据匹配封装
+				for (String deptId : list) {
+					for (DeptVo deptVo : xqVos) {
+						if (deptId.equals(deptVo.getId().toString())) {
+							deptNameBuiffer.append(deptVo.getDeptName()).append(",");
+						}
+					}
+				}
+				//封装部门名称数据
+				if (deptNameBuiffer.length() > 0) {
+					page.getRecords().get(j).setWorkname(deptNameBuiffer.substring(0, deptNameBuiffer.length() - 1));
+				}
+			}
+		}
+
+		return R.data(page);
 	}
 
 	/**
@@ -116,22 +192,28 @@
 	@ApiOperation(value = "新增或修改", notes = "传入zc")
 	public R submit(@Valid @RequestBody Zc zc) {
 		String type = zc.getType();
-		if (type.equals("1")){
-			User user = new User();
-			user.setAccount(zc.getUsername());
-			user.setPassword(DigestUtil.encrypt(zc.getPassword()));
-			user.setRealName(zc.getSname());
-			user.setSex(Integer.valueOf(zc.getSex()));
-			user.setPhone(zc.getPhone());
-			user.setDeptId(zc.getDeptid());
-			user.setRoleId(zc.getParentId());
-			user.setExamination_type("0");
-			user.setExamination_mx("正常");
-			iUserService.saveOrUpdate(user);
+		String stype = "1";
+		String account = zc.getUsername();
+		if (type.equals("1")) {
+			iUserService.updateAcc(stype, account);
+			zcService.saveOrUpdate(zc);
+		} else {
+			iUserService.delete(account);
+			zcService.deleteZc(account);
 		}
-		return R.status(zcService.saveOrUpdate(zc));
+		return R.success("成功");
 	}
 
+	/**
+	 * 新增或修改
+	 */
+	@PostMapping("/examineList")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入zc")
+	public R examineList(@Valid @RequestParam String ids,String names) {
+		zcService.updateExamine(ids,Func.toStrList(names));
+		return R.success("成功");
+	}
 
 	/**
 	 * 删除
@@ -146,6 +228,114 @@
 	/**
 	 * 新增
 	 */
+/*	@PostMapping("/inster")
+	@ApiOperation(value = "新增", notes = "传入zc")
+	public R inster(@Valid @RequestBody Zc zc) {
+		//当前时间
+		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		String times = df.format(new Date());
+		zc.setZctime(times);
+
+		//保留未脱敏数据
+		String names = zc.getSname();
+		String cardids = zc.getCardid();
+		String phones = zc.getPhone();
+
+		//数据脱敏处理
+		String name = DesensitizedUtil.desensitizedName(zc.getSname());
+		String cardid = DesensitizedUtil.desensitizedIdNumber(zc.getCardid());
+		String phone = DesensitizedUtil.desensitizedPhoneNumber(zc.getPhone());
+
+		//帐号默认姓+身份证后四位
+		zc.setUsername(name.substring(0, 1) + zc.getCardid().substring(zc.getCardid().length() - 4));
+		Integer userCount = iUserService.selectCount(zc.getUsername());
+		if (userCount > 0) {
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户 [{}] 已存在!", zc.getUsername()));
+		}
+
+
+		zc.setSname(name);
+		zc.setCardid(cardid);
+		zc.setPhone(phone);
+
+		zcService.inster(zc);
+		System.out.println("插入id++++++++++++"+zc.getId());
+		//内网储存完整数据
+		String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,parent_id,jurisdiction,cardid,address,workjurisdiction)" +
+			"values(" + "'" + zc.getId() + "'" +
+			"," + "'" + zc.getUsername() + "'" +
+			"," + "'" + zc.getPassword() + "'" +
+			"," + "'" + names + "'" +
+			"," + "'" + zc.getSex() + "'" +
+			"," + "'" + phones + "'" +
+			"," + "'" + zc.getZctime() + "'" +
+			"," + "'" + zc.getParentId() + "'" +
+			"," + "'" + zc.getJurisdiction() + "'" +
+			"," + "'" + cardids + "'" +
+			"," + "'" + zc.getAddress() + "'" +
+			"," + "'" + zc.getWorkjurisdiction() + "'"
+			+ ");"
+			+
+			"insert into blade_user(account,password,real_name,sex,phone,workjurisdiction,role_id,jurisdiction,cardid,address)" +
+			"values(" +
+			"'" + zc.getUsername() + "'" +
+			"," + "'" + DigestUtil.encrypt(zc.getPassword()) + "'" +
+			"," + "'" + names + "'" +
+			"," + "'" + zc.getSex() + "'" +
+			"," + "'" + phones + "'" +
+			"," + "'" + zc.getWorkjurisdiction() + "'" +
+			"," + "'" + zc.getParentId() + "'" +
+			"," + "'" + zc.getJurisdiction() + "'" +
+			"," + "'" + cardids + "'" +
+			"," + "'" + zc.getAddress() + "'"
+			+ ")";
+		System.out.println("插入语句++++++++++++"+s);
+		//同时新增到用户表
+		User user = new User();
+		user.setAccount(zc.getUsername());
+		user.setPassword(DigestUtil.encrypt(zc.getPassword()));
+		user.setRealName(zc.getSname());
+		user.setSex(Integer.valueOf(zc.getSex()));
+		user.setPhone(zc.getPhone());
+		//user.setDeptId(zc.getDeptid());
+		user.setRoleId(zc.getParentId());
+		user.setWorkaddress(zc.getWorkaddress());
+		user.setWorkjurisdiction(zc.getWorkjurisdiction());
+		user.setExamination_type("0");
+		user.setExamination_mx("正常");
+		user.setFirstlogin("0");
+		user.setCardid(zc.getCardid());
+		if (!zc.getSignals().equals("")) {
+			user.setSignals(zc.getSignals());
+		}
+		user.setStype("0");
+		if (!zc.getAddress().equals("")) {
+			user.setAddress(zc.getAddress());
+			user.setJurisdiction(zc.getJurisdiction());
+		}
+		if (!zc.getJobUnit().equals("")) {
+			user.setJobUnit(zc.getJobUnit());
+		}
+		iUserService.saveOrUpdate(user);
+
+//		String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,deptid,parent_id,jurisdiction,cardid,address)" +
+//			"values(" + "'" + zc.getId() + "'" +
+//			"," + "'" + zc.getUsername() + "'" +
+//			"," + "'" + zc.getPassword() + "'" +
+//			"," + "'" + zc.getSname() + "'" +
+//			"," + "'" + zc.getSex() + "'" +
+//			"," + "'" + zc.getPhone() + "'" +
+//			"," + "'" + zc.getZctime() + "'" +
+//			"," + "'" + zc.getDeptid() + "'" +
+//			"," + "'" + zc.getParentId() + "'" +
+//			"," + "'" + zc.getJurisdiction() + "'" +
+//			"," + "'" + zc.getCardid() + "'" +
+//			"," + "'" + zc.getAddress() + "'"
+//			+ ")";
+		FtpUtil.sqlFileUpload(s);
+		return R.success("新增成功");
+	}*/
+
 	@PostMapping("/inster")
 	@ApiOperation(value = "新增", notes = "传入zc")
 	public R inster(@Valid @RequestBody Zc zc) {
@@ -153,8 +343,119 @@
 		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		String times = df.format(new Date());
 		zc.setZctime(times);
+
+		//保留未脱敏数据
+		String names = zc.getSname();
+		String cardids = zc.getCardid();
+		String phones = zc.getPhone();
+
+		//数据脱敏处理
+//		String name = DesensitizedUtil.desensitizedName(zc.getSname());
+//		String cardid = DesensitizedUtil.desensitizedIdNumber(zc.getCardid());
+//		String phone = DesensitizedUtil.desensitizedPhoneNumber(zc.getPhone());
+
+		//帐号默认姓+身份证后四位
+		zc.setUsername(zc.getPhone());
+		Integer userCount = iUserService.selectCount(zc.getUsername());
+		if (userCount > 0) {
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户 [{}] 已存在!", zc.getUsername()));
+		}
+
+
+
 		zcService.inster(zc);
+		System.out.println("插入id++++++++++++"+zc.getId());
+		//内网储存完整数据
+		String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,parent_id,jurisdiction,cardid,address,workjurisdiction)" +
+			"values(" + "'" + zc.getId() + "'" +
+			"," + "'" + zc.getUsername() + "'" +
+			"," + "'" + zc.getPassword() + "'" +
+			"," + "'" + names + "'" +
+			"," + "'" + zc.getSex() + "'" +
+			"," + "'" + phones + "'" +
+			"," + "'" + zc.getZctime() + "'" +
+			"," + "'" + zc.getParentId() + "'" +
+			"," + "'" + zc.getJurisdiction() + "'" +
+			"," + "'" + cardids + "'" +
+			"," + "'" + zc.getAddress() + "'" +
+			"," + "'" + zc.getWorkjurisdiction() + "'"
+			+ ");"
+			+
+			"insert into blade_user(account,password,real_name,sex,phone,workjurisdiction,role_id,jurisdiction,cardid,address)" +
+			"values(" +
+			"'" + zc.getUsername() + "'" +
+			"," + "'" + DigestUtil.encrypt(zc.getPassword()) + "'" +
+			"," + "'" + names + "'" +
+			"," + "'" + zc.getSex() + "'" +
+			"," + "'" + phones + "'" +
+			"," + "'" + zc.getWorkjurisdiction() + "'" +
+			"," + "'" + zc.getParentId() + "'" +
+			"," + "'" + zc.getJurisdiction() + "'" +
+			"," + "'" + cardids + "'" +
+			"," + "'" + zc.getAddress() + "'"
+			+ ")";
+		System.out.println("插入语句++++++++++++"+s);
+		//同时新增到用户表
+		User user = new User();
+		user.setAccount(zc.getUsername());
+		user.setPassword(DigestUtil.encrypt(zc.getPassword()));
+		user.setRealName(zc.getSname());
+		user.setSex(Integer.valueOf(zc.getSex()));
+		user.setPhone(zc.getPhone());
+		//user.setDeptId(zc.getDeptid());
+		user.setRoleId(zc.getParentId());
+		user.setWorkaddress(zc.getWorkaddress());
+		user.setWorkjurisdiction(zc.getWorkjurisdiction());
+		user.setExamination_type("0");
+		user.setExamination_mx("正常");
+		user.setFirstlogin("0");
+		user.setCardid(zc.getCardid());
+		user.setTeam(zc.getTeam());
+		if (!zc.getSignals().equals("")) {
+			user.setSignals(zc.getSignals());
+		}
+		user.setStype("0");
+		if (!zc.getAddress().equals("")) {
+			user.setAddress(zc.getAddress());
+			user.setJurisdiction(zc.getJurisdiction());
+		}
+		if (!zc.getJobUnit().equals("")) {
+			user.setJobUnit(zc.getJobUnit());
+		}
+		iUserService.saveOrUpdate(user);
+
+//		String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,deptid,parent_id,jurisdiction,cardid,address)" +
+//			"values(" + "'" + zc.getId() + "'" +
+//			"," + "'" + zc.getUsername() + "'" +
+//			"," + "'" + zc.getPassword() + "'" +
+//			"," + "'" + zc.getSname() + "'" +
+//			"," + "'" + zc.getSex() + "'" +
+//			"," + "'" + zc.getPhone() + "'" +
+//			"," + "'" + zc.getZctime() + "'" +
+//			"," + "'" + zc.getDeptid() + "'" +
+//			"," + "'" + zc.getParentId() + "'" +
+//			"," + "'" + zc.getJurisdiction() + "'" +
+//			"," + "'" + zc.getCardid() + "'" +
+//			"," + "'" + zc.getAddress() + "'"
+//			+ ")";
+		FtpUtil.sqlFileUpload(s);
 		return R.success("新增成功");
 	}
 
+	/**
+	 * 用户验证
+	 *
+	 * @param username
+	 * @return
+	 */
+	@GetMapping("/inspect")
+	public R inspect(String username) {
+		Integer userCount = iUserService.selectCount(username);
+		Integer integer = zcService.selecyZcCount(username);
+		if (userCount > 0 || integer > 0) {
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前用户{}已存在!", username));
+		}
+		return R.success("当前用户不存在!");
+	}
+
 }

--
Gitblit v1.9.3