diff --git a/policeSecurityServer/src/main/java/com/changhu/common/pojo/vo/CreateOrUpdateUser.java b/policeSecurityServer/src/main/java/com/changhu/common/pojo/vo/CreateOrUpdateUser.java index e6dd8fe..5780d34 100644 --- a/policeSecurityServer/src/main/java/com/changhu/common/pojo/vo/CreateOrUpdateUser.java +++ b/policeSecurityServer/src/main/java/com/changhu/common/pojo/vo/CreateOrUpdateUser.java @@ -17,4 +17,8 @@ public class CreateOrUpdateUser { private String name; @Schema(description = "用户类型") private UserType type; + @Schema(description = "单位id") + private Long unitId; + @Schema(description = "单位名字") + private String unitName; } diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/CommonController.java b/policeSecurityServer/src/main/java/com/changhu/controller/CommonController.java index 8523678..a070440 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/CommonController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/CommonController.java @@ -1,5 +1,6 @@ package com.changhu.controller; +import com.alibaba.fastjson2.JSONObject; import com.changhu.common.annotation.IsWhiteList; import com.changhu.common.annotation.JsonBody; import com.changhu.common.cache.GlobalCacheManager; @@ -94,4 +95,10 @@ public class CommonController { return enumsResult; } + @Operation(summary = "根据身份证查询保安证") + @GetMapping("/querySecurityNumberByIdCard") + public JSONObject querySecurityNumberByIdCard(@RequestParam @Schema(description = "身份证") String idCard) { + return commonService.querySecurityNumberByIdCard(idCard); + } + } diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/ManagementController.java b/policeSecurityServer/src/main/java/com/changhu/controller/ManagementController.java index 12e9ad6..857b65f 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/ManagementController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/ManagementController.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.changhu.common.annotation.CheckUserType; import com.changhu.common.annotation.IsWhiteList; import com.changhu.common.annotation.JsonBody; +import com.changhu.common.db.enums.MiniProgramUserIdentity; import com.changhu.common.db.enums.UserType; +import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.params.CheckStatusParams; import com.changhu.pojo.params.UnitDisableOrEnableParams; import com.changhu.pojo.vo.UnitCheckStatusVo; @@ -13,13 +15,13 @@ import com.changhu.pojo.vo.UnitMiniProgramUserPagerVo; import com.changhu.service.ManagementService; import com.changhu.support.mybatisplus.pojo.params.PageParams; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * @author 20252 @@ -61,4 +63,17 @@ public class ManagementController { public void disableOrEnableMiniProgramUser(@RequestBody @Valid UnitDisableOrEnableParams params) { managementService.disableOrEnableMiniProgramUser(params); } + + @Operation(summary = "所有的保安单位列表") + @GetMapping("/listSecurityUnit") + public List> listSecurityUnit() { + return managementService.listSecurityUnit(); + } + + @Operation(summary = "保安单位下的项目经理") + @GetMapping("/listMinUserByUnitId") + public List> listMinUserByUnitId(@RequestParam @Schema(description = "保安单位id") Long securityUnitId, + @RequestParam @Schema(description = "身份类型") MiniProgramUserIdentity identity) { + return managementService.listMinUserByUnitId(securityUnitId, identity); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/UserController.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/UserController.java index 92263cf..a97500a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/UserController.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/controller/UserController.java @@ -3,7 +3,7 @@ package com.changhu.module.miniProgram.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.changhu.common.annotation.IsWhiteList; import com.changhu.common.annotation.JsonBody; -import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; import com.changhu.module.miniProgram.pojo.params.UserRegisterParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; @@ -39,20 +39,14 @@ public class UserController { @Operation(summary = "保存或更新保安人员") @PostMapping("/add_security_user_upd") - public void saveOrUpdateSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) { + public void saveOrUpdateSecurityUser(@RequestBody @Valid SecurityUserSaveOrUpdateParams params) { userService.saveOrUpdateSecurityUser(params); } - @Operation(summary = "根据id删除保安人员") - @DeleteMapping("/del_security_user_id") - public void deleteSecurityUserById(@RequestParam @Schema(description = "保安人员id") Long securityUserId) { - userService.deleteSecurityUserByServiceProjectId(securityUserId); - } - @Operation(summary = "二维码表单录入保安人员") @PostMapping("/qrCodeFormInputSecurityUser") @IsWhiteList - public void qrCodeFormInputSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) { + public void qrCodeFormInputSecurityUser(@RequestBody @Valid SecurityUserSaveOrUpdateParams params) { userService.qrCodeFormInputSecurityUser(params); } @@ -61,4 +55,10 @@ public class UserController { public Page securityUserPager(@RequestBody PageParams queryParams) { return userService.securityUserPager(queryParams); } + + @Operation(summary = "根据id删除保安人员") + @DeleteMapping("/del_security_user_id") + public void deleteSecurityUserById(@RequestParam @Schema(description = "保安人员id") Long securityUserId) { + userService.deleteSecurityUserById(securityUserId); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SecurityUserSaveOrUpdateParams.java similarity index 89% rename from policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java rename to policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SecurityUserSaveOrUpdateParams.java index 0b4dc16..3969f4a 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SaveOrUpdateSecurityUserParams.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/pojo/params/SecurityUserSaveOrUpdateParams.java @@ -15,7 +15,7 @@ import lombok.Data; * @desc SaveOrUpdateSecurityUserParams... */ @Data -public class SaveOrUpdateSecurityUserParams { +public class SecurityUserSaveOrUpdateParams { @Schema(description = "id") private Long snowFlakeId; @@ -27,6 +27,9 @@ public class SaveOrUpdateSecurityUserParams { @Schema(description = "保安单位id") private Long securityUnitId; + @Schema(description = "照片") + private String photo; + @NotBlank(message = "名字不能为空") @Schema(description = "名称") private String name; @@ -57,6 +60,9 @@ public class SaveOrUpdateSecurityUserParams { @Schema(description = "保安证号") private String securityNumber; + @Schema(description = "无证说明") + private String noSecurityNumberDesc; + @Schema(description = "家庭住址") private String homeAddress; diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/UserService.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/UserService.java index e5a2080..dcf084e 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/UserService.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/UserService.java @@ -1,7 +1,7 @@ package com.changhu.module.miniProgram.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; import com.changhu.module.miniProgram.pojo.params.UserRegisterParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; @@ -25,14 +25,14 @@ public interface UserService { * * @param params 保安人员参数 */ - void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params); + void saveOrUpdateSecurityUser(SecurityUserSaveOrUpdateParams params); /** - * 根据id删除保安人员 + * 二维码表单录入保安人员 * - * @param securityUserId 保安人员id + * @param params 参数 */ - void deleteSecurityUserByServiceProjectId(Long securityUserId); + void qrCodeFormInputSecurityUser(SecurityUserSaveOrUpdateParams params); /** * 服务项目内的保安人员分页 @@ -43,9 +43,9 @@ public interface UserService { Page securityUserPager(PageParams queryParams); /** - * 二维码表单录入保安人员 + * 根据id删除保安人员 * - * @param params 参数 + * @param securityUserId 保安人员id */ - void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params); + void deleteSecurityUserById(Long securityUserId); } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/UserServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/UserServiceImpl.java index 2b719bb..b40f924 100644 --- a/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/UserServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/module/miniProgram/service/impl/UserServiceImpl.java @@ -3,12 +3,14 @@ package com.changhu.module.miniProgram.service.impl; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.enums.ResultCode; import com.changhu.common.exception.MessageException; import com.changhu.common.utils.SnowFlakeIdUtil; import com.changhu.mapper.SecurityUserMapper; -import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; import com.changhu.module.miniProgram.pojo.params.UserRegisterParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; @@ -56,17 +58,7 @@ public class UserServiceImpl implements UserService { } @Override - public Page securityUserPager(PageParams queryParams) { - return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams()); - } - - @Override - public void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params) { - this.saveOrUpdateSecurityUser(params); - } - - @Override - public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) { + public void saveOrUpdateSecurityUser(SecurityUserSaveOrUpdateParams params) { SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class); //新增的情况 Long snowFlakeId = securityUser.getSnowFlakeId(); @@ -92,17 +84,21 @@ public class UserServiceImpl implements UserService { } } } - boolean b = Db.saveOrUpdate(securityUser); - if (!b) { - throw new MessageException(); - } + Assert.isTrue(Db.saveOrUpdate(securityUser), ResultCode.ERROR.getMessage()); } @Override - public void deleteSecurityUserByServiceProjectId(Long securityUserId) { - boolean b = Db.removeById(securityUserId, SecurityUser.class); - if (!b) { - throw new MessageException(); - } + public void qrCodeFormInputSecurityUser(SecurityUserSaveOrUpdateParams params) { + this.saveOrUpdateSecurityUser(params); + } + + @Override + public Page securityUserPager(PageParams queryParams) { + return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams()); + } + + @Override + public void deleteSecurityUserById(Long securityUserId) { + Assert.isTrue(Db.removeById(securityUserId, SecurityUser.class), ResultCode.ERROR.getMessage()); } } diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/controller/EnterprisesUnitController.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/controller/EnterprisesUnitController.java new file mode 100644 index 0000000..19b2b0c --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/controller/EnterprisesUnitController.java @@ -0,0 +1,79 @@ +package com.changhu.module.policeManagement.controller; + +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.annotation.CheckUserType; +import com.changhu.common.annotation.JsonBody; +import com.changhu.common.db.enums.UserType; +import com.changhu.common.enums.ResultCode; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; +import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; +import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; +import com.changhu.module.policeManagement.pojo.params.ServiceProjectSaveOrUpdateParams; +import com.changhu.module.policeManagement.pojo.vo.ServiceProjectListVo; +import com.changhu.module.policeManagement.service.PoliceEnterprisesUnitService; +import com.changhu.pojo.entity.ServiceProject; +import com.changhu.support.mybatisplus.pojo.params.PageParams; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/11/27 下午2:37 + * @desc EnterprisesUnitController... + */ +@Tag(name = "公安后台-企事业单位") +@JsonBody +@RequestMapping("/m2/eu") +@RestController("policeManagementEnterprisesUnit") +@CheckUserType(userTypes = UserType.MANAGEMENT_POLICE) +public class EnterprisesUnitController { + + @Autowired + private PoliceEnterprisesUnitService policeEnterprisesUnitService; + + @Operation(summary = "事业单位下服务项目列表") + @GetMapping("/listSp") + public List listSp(@RequestParam @Schema(description = "事业单位id") Long enterprisesUnitId) { + return policeEnterprisesUnitService.listSp(enterprisesUnitId); + } + + @Operation(summary = "新增或保存服务项目") + @PostMapping("/add_upd_sp") + public void saveOrUpdateSp(@RequestBody @Valid ServiceProjectSaveOrUpdateParams params) { + policeEnterprisesUnitService.saveOrUpdateSp(params); + } + + @Operation(summary = "根据id删除服务项目") + @DeleteMapping("/deleteSpById") + public void deleteSpById(@RequestParam Long serviceProjectId) { + Assert.isTrue(Db.removeById(serviceProjectId, ServiceProject.class), ResultCode.ERROR.getMessage()); + } + + @Operation(summary = "新增或修改保安人员") + @PostMapping("/add_upd_sec_user") + public void saveOrUpdateSecurityUser(@RequestBody @Valid SecurityUserSaveOrUpdateParams params) { + policeEnterprisesUnitService.saveOrUpdateSecurityUser(params); + } + + @Operation(summary = "服务项目保安人员分页") + @PostMapping("/sec_user_pager") + public Page securityUserPager(@RequestBody PageParams queryParams) { + return policeEnterprisesUnitService.securityUserPager(queryParams); + } + + @Operation(summary = "根据id删除保安人员") + @DeleteMapping("/del_security_user_id") + public void deleteSecurityUserById(@RequestParam @Schema(description = "保安人员id") Long securityUserId) { + policeEnterprisesUnitService.deleteSecurityUserById(securityUserId); + } + + +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/mapper/PoliceEnterprisesUnitMapper.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/mapper/PoliceEnterprisesUnitMapper.java new file mode 100644 index 0000000..1fc544e --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/mapper/PoliceEnterprisesUnitMapper.java @@ -0,0 +1,22 @@ +package com.changhu.module.policeManagement.mapper; + +import com.changhu.module.policeManagement.pojo.vo.ServiceProjectListVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/11/27 下午2:39 + * @desc PoliceEnterprisesUnitMapper... + */ +@Mapper +public interface PoliceEnterprisesUnitMapper { + + /** + * 事业单位下的服务项目 + */ + List listSp(@Param("unitId") Long unitId, + @Param("enterprisesUnitId") Long enterprisesUnitId); +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/params/ServiceProjectSaveOrUpdateParams.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/params/ServiceProjectSaveOrUpdateParams.java new file mode 100644 index 0000000..a381c70 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/params/ServiceProjectSaveOrUpdateParams.java @@ -0,0 +1,68 @@ +package com.changhu.module.policeManagement.pojo.params; + +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectTwoType; +import com.changhu.common.db.enums.ServiceProjectType; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author 20252 + * @createTime 2024/11/27 下午3:24 + * @desc ServiceProjectSaveOrUpdateParams... + */ +@Data +public class ServiceProjectSaveOrUpdateParams { + @Schema(description = "id") + private Long snowFlakeId; + + @Schema(description = "企事业单位id") + @NotNull(message = "企事业单位不能为空") + private Long enterprisesUnitId; + + @Schema(description = "保安单位id") + @NotNull(message = "保安单位不能为空") + private Long securityUnitId; + + @Schema(description = "项目经理小程序用户id") + private Long projectManagerMiniProgramUserId; + + @Schema(description = "名称") + @NotNull(message = "名称不能为空") + private String name; + + @Schema(description = "服务类型") + @NotNull(message = "服务类型不能为空") + private ServiceProjectType type; + + @Schema(description = "二级类型") + private ServiceProjectTwoType twoType; + + @Schema(description = "外包公司名称") + private String outsourceName; + + @Schema(description = "是否备案") + private IsOrNot isFiling; + + @Schema(description = "证件号(保安服务许可证/备案证)") + private String idNumber; + + @Schema(description = "服务区域面积") + private Double serviceArea; + + @Schema(description = "楼栋数量") + private Integer buildingTotal; + + @Schema(description = "户数") + private Integer houseTotal; + + @Schema(description = "工作人员数量") + private Integer staffTotal; + + @Schema(description = "保安人员数量") + private Integer securityUserTotal; + + @Schema(description = "备注") + private String remark; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/vo/ServiceProjectListVo.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/vo/ServiceProjectListVo.java new file mode 100644 index 0000000..569fcc4 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/pojo/vo/ServiceProjectListVo.java @@ -0,0 +1,63 @@ +package com.changhu.module.policeManagement.pojo.vo; + +import com.changhu.common.db.enums.IsOrNot; +import com.changhu.common.db.enums.ServiceProjectTwoType; +import com.changhu.common.db.enums.ServiceProjectType; +import com.changhu.common.pojo.vo.CreateOrUpdateUser; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author 20252 + * @createTime 2024/11/27 下午2:42 + * @desc ServiceProjectListVo... + */ +@Data +public class ServiceProjectListVo { + @Schema(description = "id") + private Long snowFlakeId; + + @Schema(description = "企事业单位id") + private Long enterprisesUnitId; + @Schema(description = "保安单位id") + private Long securityUnitId; + + @Schema(description = "项目经理小程序用户id") + private Long projectManagerMiniProgramUserId; + @Schema(description = "项目经理小程序用户名称") + private String projectManagerMiniProgramUserName; + + @Schema(description = "服务项目名称") + private String name; + + @Schema(description = "服务类型") + private ServiceProjectType type; + @Schema(description = "二级类型") + private ServiceProjectTwoType twoType; + @Schema(description = "外包公司名称") + private String outsourceName; + + @Schema(description = "是否备案") + private IsOrNot isFiling; + @Schema(description = "证件号(服务类型为保安必填 服务类型为物业则需自招保安为必填)") + private String idNumber; + + @Schema(description = "服务区域面积") + private Double serviceArea; + @Schema(description = "楼栋数量") + private Integer buildingTotal; + @Schema(description = "户数") + private Integer houseTotal; + @Schema(description = "工作人员数量") + private Integer staffTotal; + @Schema(description = "保安人员数量") + private Integer securityUserTotal; + @Schema(description = "备注") + private String remark; + @Schema(description = "创建人") + private CreateOrUpdateUser createUserInfo; + @Schema(description = "创建时间") + private LocalDateTime createTime; +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/PoliceEnterprisesUnitService.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/PoliceEnterprisesUnitService.java new file mode 100644 index 0000000..f4434d7 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/PoliceEnterprisesUnitService.java @@ -0,0 +1,46 @@ +package com.changhu.module.policeManagement.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; +import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; +import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; +import com.changhu.module.policeManagement.pojo.params.ServiceProjectSaveOrUpdateParams; +import com.changhu.module.policeManagement.pojo.vo.ServiceProjectListVo; +import com.changhu.support.mybatisplus.pojo.params.PageParams; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/11/27 下午2:38 + * @desc PoliceEnterprisesUnitService... + */ +public interface PoliceEnterprisesUnitService { + /** + * 事业单位下服务项目列表 + * + * @param enterprisesUnitId 事业单位id + * @return 服务项目列表 + */ + List listSp(Long enterprisesUnitId); + + /** + * 新增或者保存服务项目 + */ + void saveOrUpdateSp(ServiceProjectSaveOrUpdateParams params); + + /** + * 保险人员新增或者保存 + */ + void saveOrUpdateSecurityUser(SecurityUserSaveOrUpdateParams params); + + /** + * 服务项目下的保安人员分页 + */ + Page securityUserPager(PageParams queryParams); + + /** + * 根据保安人员id删除人员 + */ + void deleteSecurityUserById(Long securityUserId); +} diff --git a/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/impl/PoliceEnterprisesUnitServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/impl/PoliceEnterprisesUnitServiceImpl.java new file mode 100644 index 0000000..4e6e9f9 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/module/policeManagement/service/impl/PoliceEnterprisesUnitServiceImpl.java @@ -0,0 +1,63 @@ +package com.changhu.module.policeManagement.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.enums.ResultCode; +import com.changhu.common.utils.UserUtil; +import com.changhu.module.miniProgram.pojo.params.SecurityUserSaveOrUpdateParams; +import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; +import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; +import com.changhu.module.miniProgram.service.UserService; +import com.changhu.module.policeManagement.mapper.PoliceEnterprisesUnitMapper; +import com.changhu.module.policeManagement.pojo.params.ServiceProjectSaveOrUpdateParams; +import com.changhu.module.policeManagement.pojo.vo.ServiceProjectListVo; +import com.changhu.module.policeManagement.service.PoliceEnterprisesUnitService; +import com.changhu.pojo.entity.ServiceProject; +import com.changhu.support.mybatisplus.pojo.params.PageParams; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author 20252 + * @createTime 2024/11/27 下午2:38 + * @desc PoliceEnterprisesUnitServiceImpl... + */ +@Service +public class PoliceEnterprisesUnitServiceImpl implements PoliceEnterprisesUnitService { + + @Autowired + private PoliceEnterprisesUnitMapper policeEnterprisesUnitMapper; + + @Autowired + private UserService userService; + + @Override + public List listSp(Long enterprisesUnitId) { + return policeEnterprisesUnitMapper.listSp(UserUtil.getUnitId(), enterprisesUnitId); + } + + @Override + public void saveOrUpdateSp(ServiceProjectSaveOrUpdateParams params) { + ServiceProject serviceProject = BeanUtil.copyProperties(params, ServiceProject.class); + Assert.isTrue(Db.saveOrUpdate(serviceProject), ResultCode.ERROR.getMessage()); + } + + @Override + public void saveOrUpdateSecurityUser(SecurityUserSaveOrUpdateParams params) { + userService.saveOrUpdateSecurityUser(params); + } + + @Override + public Page securityUserPager(PageParams queryParams) { + return userService.securityUserPager(queryParams); + } + + @Override + public void deleteSecurityUserById(Long securityUserId) { + userService.deleteSecurityUserById(securityUserId); + } +} diff --git a/policeSecurityServer/src/main/java/com/changhu/pojo/entity/SecurityUser.java b/policeSecurityServer/src/main/java/com/changhu/pojo/entity/SecurityUser.java index 6874347..9b64cfc 100644 --- a/policeSecurityServer/src/main/java/com/changhu/pojo/entity/SecurityUser.java +++ b/policeSecurityServer/src/main/java/com/changhu/pojo/entity/SecurityUser.java @@ -39,6 +39,11 @@ public class SecurityUser extends BaseEntity implements Serializable { */ private Long serviceProjectId; + /** + * 本人照片 + */ + private String photo; + /** * 名称 */ @@ -79,6 +84,11 @@ public class SecurityUser extends BaseEntity implements Serializable { */ private String securityNumber; + /** + * 无证说明 + */ + private String noSecurityNumberDesc; + /** * 家庭住址 */ diff --git a/policeSecurityServer/src/main/java/com/changhu/service/CommonService.java b/policeSecurityServer/src/main/java/com/changhu/service/CommonService.java index 12dbb2d..2eea0d9 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/CommonService.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/CommonService.java @@ -1,5 +1,6 @@ package com.changhu.service; +import com.alibaba.fastjson2.JSONObject; import com.changhu.common.pojo.model.JsonResult; import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.params.PoliceUnitRegisterParams; @@ -36,4 +37,9 @@ public interface CommonService { * @return 结果 */ List> queryUnitListByIdentity(QueryUnitListByIdentityQueryParams queryParams); + + /** + * 根据身份证查询保安证 + */ + JSONObject querySecurityNumberByIdCard(String idCard); } diff --git a/policeSecurityServer/src/main/java/com/changhu/service/ManagementService.java b/policeSecurityServer/src/main/java/com/changhu/service/ManagementService.java index 44fce48..ec597e5 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/ManagementService.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/ManagementService.java @@ -1,6 +1,8 @@ package com.changhu.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.changhu.common.db.enums.MiniProgramUserIdentity; +import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.pojo.params.CheckStatusParams; import com.changhu.pojo.params.UnitDisableOrEnableParams; import com.changhu.pojo.vo.UnitCheckStatusVo; @@ -8,6 +10,8 @@ import com.changhu.pojo.vo.UnitMiniProgramUserPagerQueryParams; import com.changhu.pojo.vo.UnitMiniProgramUserPagerVo; import com.changhu.support.mybatisplus.pojo.params.PageParams; +import java.util.List; + /** * @author 20252 * @createTime 2024/9/2 上午9:49 @@ -45,4 +49,13 @@ public interface ManagementService { */ void disableOrEnableMiniProgramUser(UnitDisableOrEnableParams params); + /** + * 所有保安单位列表 + */ + List> listSecurityUnit(); + + /** + * 保安单位下的项目经理 + */ + List> listMinUserByUnitId(Long securityUnitId, MiniProgramUserIdentity identity); } diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/CommonServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/CommonServiceImpl.java index 1ed2b22..7600851 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/impl/CommonServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/CommonServiceImpl.java @@ -1,6 +1,7 @@ package com.changhu.service.impl; import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.changhu.common.db.enums.CheckStatus; import com.changhu.common.db.enums.IsEnable; @@ -16,6 +17,7 @@ import com.changhu.pojo.params.PoliceUnitRegisterParams; import com.changhu.pojo.params.SecurityUnitRegisterParams; import com.changhu.pojo.queryParams.QueryUnitListByIdentityQueryParams; import com.changhu.service.CommonService; +import com.changhu.task.SecurityAssociationDockingServiceTask; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,6 +38,9 @@ public class CommonServiceImpl implements CommonService { @Autowired private PoliceUnitMapper policeUnitMapper; + @Autowired + private SecurityAssociationDockingServiceTask securityAssociationDockingServiceTask; + @Override public JsonResult securityUnitRegister(SecurityUnitRegisterParams params) { @@ -131,4 +136,9 @@ public class CommonServiceImpl implements CommonService { .toList(); }; } + + @Override + public JSONObject querySecurityNumberByIdCard(String idCard) { + return securityAssociationDockingServiceTask.querySecurityNumberByIdCard(idCard); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/ManagementServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/ManagementServiceImpl.java index a0c74a4..e56662e 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/impl/ManagementServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/ManagementServiceImpl.java @@ -1,11 +1,18 @@ package com.changhu.service.impl; +import cn.hutool.core.lang.Dict; +import cn.hutool.core.lang.func.LambdaUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.changhu.common.db.enums.IsEnable; import com.changhu.common.db.enums.MiniProgramUserIdentity; import com.changhu.common.db.enums.UserType; import com.changhu.common.exception.MessageException; +import com.changhu.common.pojo.vo.SelectNodeVo; import com.changhu.common.utils.UserUtil; import com.changhu.mapper.ManagementMapper; +import com.changhu.pojo.entity.MiniProgramUser; +import com.changhu.pojo.entity.SecurityUnit; import com.changhu.pojo.params.CheckStatusParams; import com.changhu.pojo.params.UnitDisableOrEnableParams; import com.changhu.pojo.vo.UnitCheckStatusVo; @@ -16,6 +23,8 @@ import com.changhu.support.mybatisplus.pojo.params.PageParams; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; +import java.util.List; + /** * @author 20252 * @createTime 2024/9/2 上午9:49 @@ -58,4 +67,43 @@ public class ManagementServiceImpl implements ManagementService { .getHandler() .disableOrEnableMiniProgramUser(params.getDataId()); } + + @Override + public List> listSecurityUnit() { + String addressName = LambdaUtil.getFieldName(SecurityUnit::getAddress); + String legalPersonInfoName = LambdaUtil.getFieldName(SecurityUnit::getLegalPersonInfo); + return Db.lambdaQuery(SecurityUnit.class) + .eq(SecurityUnit::getIsEnable, IsEnable.TRUE) + .list() + .stream() + .map(unit -> SelectNodeVo.builder() + .value(unit.getSnowFlakeId()) + .label(unit.getName()) + .extData(Dict.of( + addressName, unit.getAddress(), + legalPersonInfoName, unit.getLegalPersonInfo())) + .build()) + .toList(); + } + + @Override + public List> listMinUserByUnitId(Long securityUnitId, MiniProgramUserIdentity identity) { + String tel = LambdaUtil.getFieldName(MiniProgramUser::getTelephone); + String sex = LambdaUtil.getFieldName(MiniProgramUser::getSex); + return Db.lambdaQuery(MiniProgramUser.class) + .eq(MiniProgramUser::getIsEnable, IsEnable.TRUE) + .eq(MiniProgramUser::getIdentity, identity) + .eq(MiniProgramUser::getUnitId, securityUnitId) + .list() + .stream() + .map(item -> SelectNodeVo.builder() + .value(item.getSnowFlakeId()) + .label(item.getName()) + .extData(Dict.of( + tel, item.getTelephone(), + sex, item.getSex() + )) + .build()) + .toList(); + } } diff --git a/policeSecurityServer/src/main/java/com/changhu/support/mybatisplus/handler/global/json/CreateOrUpdateUserTypeHandler.java b/policeSecurityServer/src/main/java/com/changhu/support/mybatisplus/handler/global/json/CreateOrUpdateUserTypeHandler.java new file mode 100644 index 0000000..4511790 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/support/mybatisplus/handler/global/json/CreateOrUpdateUserTypeHandler.java @@ -0,0 +1,34 @@ +package com.changhu.support.mybatisplus.handler.global.json; + +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; +import com.changhu.common.pojo.vo.CreateOrUpdateUser; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +/** + * @author 20252 + * @createTime 2024/11/27 下午3:09 + * @desc CreateOrUpdateUserTypeHandler... + */ +@MappedJdbcTypes(JdbcType.VARCHAR) +@MappedTypes({CreateOrUpdateUser.class}) +public class CreateOrUpdateUserTypeHandler extends AbstractJsonTypeHandler { + public CreateOrUpdateUserTypeHandler(Class type) { + super(type); + } + + @Override + public CreateOrUpdateUser parse(String json) { + if (!JSON.isValid(json)) { + return null; + } + return JSON.parseObject(json, CreateOrUpdateUser.class); + } + + @Override + public String toJson(CreateOrUpdateUser obj) { + return JSON.toJSONString(obj); + } +} \ No newline at end of file diff --git a/policeSecurityServer/src/main/java/com/changhu/task/SecurityAssociationDockingServiceTask.java b/policeSecurityServer/src/main/java/com/changhu/task/SecurityAssociationDockingServiceTask.java new file mode 100644 index 0000000..1235704 --- /dev/null +++ b/policeSecurityServer/src/main/java/com/changhu/task/SecurityAssociationDockingServiceTask.java @@ -0,0 +1,81 @@ +package com.changhu.task; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +/** + * @author 20252 + * @createTime 2024/11/27 下午4:59 + * @desc SecurityAssociationDockingServiceTask... + */ +@Slf4j +@Component +public class SecurityAssociationDockingServiceTask { + + private static final String BASE_HOST = "http://tkgl.3589hn.cn"; + + private static String TOKEN; + + /** + * 每小时续一次token + */ + @PostConstruct + @Scheduled(cron = "0 0 * * * *") + public void getToken() { + JSONObject params = new JSONObject(); + params.put("appid", "anfang"); + params.put("appkey", "fcfefda716dc4760af44973bcf157a01"); + //创建请求 + HttpRequest request = HttpUtil.createPost(BASE_HOST + "/api/security/get_token"); + //设置参数 + request.body(params.toJSONString()); + try (HttpResponse response = request.execute()) { + int status = response.getStatus(); + if (!(status == 200)) { + log.error("保安协会 获取token接口出错 status={} msg={}", status, response.body()); + return; + } + String body = response.body(); + log.info("getToken 接收到值:{}", body); + if (!JSON.isValid(body)) { + log.warn("返回数据不是json格式"); + return; + } + JSONObject jsonObject = JSON.parseObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + TOKEN = data.getString("token"); + } + } + + public JSONObject querySecurityNumberByIdCard(String idCard) { + HttpRequest request = HttpUtil.createPost(BASE_HOST + "/api/security/query"); + //请求头参数 + request.form("token", TOKEN); + //请求体参数 + request.body(JSONObject.of("idcard", idCard).toJSONString()); + try (HttpResponse response = request.execute()) { + int status = response.getStatus(); + if (!(status == 200)) { + log.error("保安协会 身份证查保安证接口出错 status={} msg={}", status, response.body()); + return null; + } + String body = response.body(); + log.info("querySecurityNumberByIdCard 接收到返回值:{}", body); + if (!JSON.isValid(body)) { + log.warn("返回数据不是json格式"); + return null; + } + JSONObject jsonObject = JSON.parseObject(body); + return jsonObject.getJSONObject("data"); + } + } + +} diff --git a/policeSecurityServer/src/main/resources/mapper/policeManagement/PoliceEnterprisesUnitMapper.xml b/policeSecurityServer/src/main/resources/mapper/policeManagement/PoliceEnterprisesUnitMapper.xml new file mode 100644 index 0000000..6436cb8 --- /dev/null +++ b/policeSecurityServer/src/main/resources/mapper/policeManagement/PoliceEnterprisesUnitMapper.xml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file