diff --git a/src/main/java/com/zcloud/controller/positioning/UserCardController.java b/src/main/java/com/zcloud/controller/positioning/UserCardController.java index 5784cf8..ff19b8b 100644 --- a/src/main/java/com/zcloud/controller/positioning/UserCardController.java +++ b/src/main/java/com/zcloud/controller/positioning/UserCardController.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONObject; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; +import com.zcloud.service.system.UsersService; import com.zcloud.util.Jurisdiction; import com.zcloud.util.PLSUtil; import com.zcloud.util.ReturnMap; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -22,6 +24,10 @@ import java.util.List; @RequestMapping("/deploy/card") public class UserCardController extends BaseController { + + @Autowired + private UsersService usersService; + /** * @Description: 人员卡管理 * @Author: dearLin @@ -61,6 +67,8 @@ public class UserCardController extends BaseController { JSONObject body = PLSUtil.GeneralPut("/deploy/card", pageData, Jurisdiction.getCORPINFO_ID()); if (body != null) { returnMap.putAll(body); + if (!"200".equals(body.getString("code"))) return ReturnMap.error(body.getString("msg")); + usersService.editUserCardNoByPid(pageData); } return returnMap; } @@ -117,6 +125,8 @@ public class UserCardController extends BaseController { ReturnMap returnMap = new ReturnMap(); JSONObject body = PLSUtil.GeneralDelete("/deploy/card/", pageData.getString("DATA_IDS"), Jurisdiction.getCORPINFO_ID()); if (body != null) { + if (!"200".equals(body.getString("code"))) return ReturnMap.error(body.getString("msg")); + returnMap.putAll(body); } return returnMap; @@ -138,6 +148,11 @@ public class UserCardController extends BaseController { if (body != null) { if (!"200".equals(body.getString("code"))) return ReturnMap.error(body.getString("msg")); returnMap.putAll(body); + // 人员表里给 对应卡号得人 得 卡移除掉 + String[] dataIds = pageData.getString("DATA_IDS").split(","); + pageData.put("USER_IDS", dataIds); + pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + usersService.removeCardNoUser(pageData); } return returnMap; } diff --git a/src/main/java/com/zcloud/controller/system/UsersController.java b/src/main/java/com/zcloud/controller/system/UsersController.java index 32b16ea..8e7a057 100644 --- a/src/main/java/com/zcloud/controller/system/UsersController.java +++ b/src/main/java/com/zcloud/controller/system/UsersController.java @@ -1400,7 +1400,7 @@ public class UsersController extends BaseController { for (PageData lpd : listPd) { number++; for (int i = 0; i < 7; i++) { - if (i == 1 || i == 6) { + if (i == 1 || i == 5 || i == 6) { continue; } if (Tools.isEmpty(lpd.get("var" + i))) { @@ -1418,10 +1418,13 @@ public class UsersController extends BaseController { Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX); Pattern patternRardNo = Pattern.compile(RegexPatterns.VERIFY_CARDNO_REGEX); Matcher matcher = patternPhone.matcher(lpd.getString("var2")); - Matcher matcherRardNo = patternRardNo.matcher(lpd.getString("var5")); - if (!matcherRardNo.matches()) { - errorStr.append("第" + number + "行,"); - errorStr.append("定位卡号" + CardNo + "格式不正确,请重新确认数据;\n"); + Matcher matcherRardNo = patternRardNo.matcher(CardNo); + if (Tools.notEmpty(CardNo)) { + // 现在卡号可以为空 不为空得话进入正则 + if (!matcherRardNo.matches()) { + errorStr.append("第" + number + "行,"); + errorStr.append("定位卡号" + CardNo + "格式不正确(非负正整数),请重新确认数据;\n"); + } } if (!matcher.matches()) { errorStr.append("第" + number + "行,"); diff --git a/src/main/java/com/zcloud/mapper/datasource/system/UsersMapper.java b/src/main/java/com/zcloud/mapper/datasource/system/UsersMapper.java index 2e9ac35..e11aa1e 100644 --- a/src/main/java/com/zcloud/mapper/datasource/system/UsersMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/system/UsersMapper.java @@ -259,4 +259,8 @@ public interface UsersMapper { List selectUserListByUserIds(PageData pd); PageData getUserByCardNo(PageData pageData); + + void removeCardNoUser(PageData pageData); + + void editUserCardNoByPid(PageData pageData); } diff --git a/src/main/java/com/zcloud/service/system/UsersService.java b/src/main/java/com/zcloud/service/system/UsersService.java index 9896f78..a1910a2 100644 --- a/src/main/java/com/zcloud/service/system/UsersService.java +++ b/src/main/java/com/zcloud/service/system/UsersService.java @@ -305,4 +305,7 @@ public interface UsersService { */ PageData getUserByCardNo(PageData pageData); + void removeCardNoUser(PageData pageData); + + void editUserCardNoByPid(PageData pageData); } diff --git a/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java b/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java index 9f58f2b..e6b05ab 100644 --- a/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java +++ b/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java @@ -284,7 +284,15 @@ public class UsersServiceImpl implements UsersService { return usersMapper.getUserByCardNo(pageData); } + @Override + public void removeCardNoUser(PageData pageData) { + usersMapper.removeCardNoUser(pageData); + } + @Override + public void editUserCardNoByPid(PageData pageData) { + usersMapper.editUserCardNoByPid(pageData); + } @Override @@ -358,6 +366,7 @@ public class UsersServiceImpl implements UsersService { PageData response = PLSUtil.saveUser(pd); if ("200".equals(response.getString("code"))) { pd.put("PLS_ID", response.getString("data")); + if (Tools.isEmpty(pd.getString("CARDNO"))) pd.put("CARDNO",null); usersMapper.saveUser(pd); FHLOG.save(Jurisdiction.getUsername(), "新增用户:" + pd.getString("USERNAME")); return ReturnMap.ok(); diff --git a/src/main/java/com/zcloud/util/PLSUtil.java b/src/main/java/com/zcloud/util/PLSUtil.java index a911be9..420c5ca 100644 --- a/src/main/java/com/zcloud/util/PLSUtil.java +++ b/src/main/java/com/zcloud/util/PLSUtil.java @@ -470,6 +470,7 @@ public class PLSUtil { * @Return: void */ public static boolean hasCardNumber(PageData user) throws Exception { + if (Tools.isEmpty(user.getString("CARDNO"))) {return true;} // 根据 定位卡号获取对应的人 String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); PageData response = sendGetHttpRequest(url, null, getToken(Jurisdiction.getCORPINFO_ID())); diff --git a/src/main/java/com/zcloud/util/RegexPatterns.java b/src/main/java/com/zcloud/util/RegexPatterns.java index 2a80383..6ed37d6 100644 --- a/src/main/java/com/zcloud/util/RegexPatterns.java +++ b/src/main/java/com/zcloud/util/RegexPatterns.java @@ -23,7 +23,7 @@ public class RegexPatterns { * 验证码正则, 6位数字或字母 */ public static final String VERIFY_CODE_REGEX = "^[a-zA-Z\\d]{6}$"; - public static final String VERIFY_CARDNO_REGEX = "^[0-9]{5}$"; + public static final String VERIFY_CARDNO_REGEX = "^[1-9][0-9]*$"; /** * 身份证号正则, 15位或者18位,最后一位可以为字母 */ diff --git a/src/main/resources/mybatis/datasource/system/UsersMapper.xml b/src/main/resources/mybatis/datasource/system/UsersMapper.xml index 44cfd6c..0bbaa32 100644 --- a/src/main/resources/mybatis/datasource/system/UsersMapper.xml +++ b/src/main/resources/mybatis/datasource/system/UsersMapper.xml @@ -1280,6 +1280,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and CORPINFO_ID = #{CORPINFO_ID} + + update + + set + CARDNO = null + where + CORPINFO_ID = #{CORPINFO_ID} and + CARDNO in + #{item} + + + + update + + set + CARDNO = #{cardNo} + where + PLS_ID = #{psnId} +