Compare commits

...

2 Commits

Author SHA1 Message Date
luozhun 2b3be91747 Merge remote-tracking branch 'origin/main' 2024-09-20 14:51:32 +08:00
luozhun 1e344ac66e 二维码分享表单录入 2024-09-20 14:51:27 +08:00
11 changed files with 86 additions and 5 deletions

View File

@ -41,6 +41,8 @@ public class WebConfig implements WebMvcConfigurer {
whiteList.add("/management/getCheckStatus"); whiteList.add("/management/getCheckStatus");
//微信小程序注册 //微信小程序注册
whiteList.add("/miniProgramUser/register"); whiteList.add("/miniProgramUser/register");
//二维码表单录入保安人员
whiteList.add("/miniProgramUser/qrCodeFormInputSecurityUser");
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package com.changhu.module.miniProgram.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody; import com.changhu.common.annotation.JsonBody;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService; import com.changhu.module.miniProgram.service.MiniProgramUserService;
@ -34,6 +35,12 @@ public class MiniProgramUserController {
miniProgramUserService.register(params); miniProgramUserService.register(params);
} }
@Operation(summary = "二维码表单录入保安人员")
@PostMapping("/qrCodeFormInputSecurityUser")
public void qrCodeFormInputSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) {
miniProgramUserService.qrCodeFormInputSecurityUser(params);
}
@Operation(summary = "服务项目保安人员分页") @Operation(summary = "服务项目保安人员分页")
@PostMapping("/securityUserPager") @PostMapping("/securityUserPager")
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(@RequestBody PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) { public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(@RequestBody PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {

View File

@ -9,7 +9,11 @@ import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -42,7 +46,15 @@ public class ProjectManageIndexController {
@Operation(summary = "保存或更新保安人员") @Operation(summary = "保存或更新保安人员")
@PostMapping("/saveOrUpdateSecurityUser") @PostMapping("/saveOrUpdateSecurityUser")
public void saveOrUpdateSecurityUser(@RequestBody SaveOrUpdateSecurityUserParams params) { public void saveOrUpdateSecurityUser(@RequestBody @Valid SaveOrUpdateSecurityUserParams params) {
projectManageIndexService.saveOrUpdateSecurityUser(params); projectManageIndexService.saveOrUpdateSecurityUser(params);
} }
@JsonBody(value = false)
@Operation(summary = "获取表单分享二维码")
@GetMapping(value = "/shareForm_QR_Code")
public ResponseEntity<Resource> shareForm_QR_Code(@Schema(description = "要生成的路径") @RequestParam String path,
@Schema(description = "生成二维码的宽度") @RequestParam(defaultValue = "430") Integer width) {
return projectManageIndexService.shareForm_QR_Code(path, width);
}
} }

View File

@ -23,6 +23,10 @@ public class SaveOrUpdateSecurityUserParams {
@Schema(description = "服务项目id") @Schema(description = "服务项目id")
private Long serviceProjectId; private Long serviceProjectId;
@NotNull(message = "保安单位不能为空")
@Schema(description = "保安单位id")
private Long securityUnitId;
@NotBlank(message = "名字不能为空") @NotBlank(message = "名字不能为空")
@Schema(description = "名称") @Schema(description = "名称")
private String name; private String name;

View File

@ -53,6 +53,8 @@ public class IndexServiceProjectListVo {
static class ServiceProjectVo { static class ServiceProjectVo {
@Schema(description = "服务项目id") @Schema(description = "服务项目id")
private Long snowFlakeId; private Long snowFlakeId;
@Schema(description = "保安单位id")
private Long securityUnitId;
@Schema(description = "项目经理信息") @Schema(description = "项目经理信息")
private Dict projectManagerMiniProgramUserInfo; private Dict projectManagerMiniProgramUserInfo;
@Schema(description = "服务项目名称") @Schema(description = "服务项目名称")

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser; import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams; import com.changhu.support.mybatisplus.pojo.params.PageParams;
@ -29,4 +30,11 @@ public interface MiniProgramUserService extends IService<MiniProgramUser> {
* @return 保安人员 * @return 保安人员
*/ */
Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams); Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams);
/**
* 二维码表单录入保安人员
*
* @param params 参数
*/
void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params);
} }

View File

@ -2,6 +2,9 @@ package com.changhu.module.miniProgram.service;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams; import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import java.util.List; import java.util.List;
@ -31,4 +34,9 @@ public interface ProjectManageIndexService {
* @param params 保安人员参数 * @param params 保安人员参数
*/ */
void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params); void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params);
/**
* 分享表单录入的二维码
*/
ResponseEntity<Resource> shareForm_QR_Code(String path, Integer width);
} }

View File

@ -13,9 +13,11 @@ import com.changhu.module.miniProgram.mapper.SecurityUserMapper;
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser; import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
import com.changhu.module.miniProgram.pojo.entity.SecurityUser; import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams; import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams;
import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams; import com.changhu.module.miniProgram.pojo.queryParams.ServiceProjectSecurityUserPagerQueryParams;
import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo; import com.changhu.module.miniProgram.pojo.vo.ServiceProjectSecurityUserPagerVo;
import com.changhu.module.miniProgram.service.MiniProgramUserService; import com.changhu.module.miniProgram.service.MiniProgramUserService;
import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import com.changhu.support.mybatisplus.pojo.params.PageParams; import com.changhu.support.mybatisplus.pojo.params.PageParams;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +37,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
@Autowired @Autowired
private SecurityUserMapper securityUserMapper; private SecurityUserMapper securityUserMapper;
@Autowired
private ProjectManageIndexService projectManageIndexService;
@Override @Override
public void register(MiniProgramUserRegisterParams params) { public void register(MiniProgramUserRegisterParams params) {
MiniProgramUser miniProgramUser = BeanUtil.copyProperties(params, MiniProgramUser.class); MiniProgramUser miniProgramUser = BeanUtil.copyProperties(params, MiniProgramUser.class);
@ -61,4 +66,9 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) { public Page<ServiceProjectSecurityUserPagerVo> securityUserPager(PageParams<ServiceProjectSecurityUserPagerQueryParams, ServiceProjectSecurityUserPagerVo> queryParams) {
return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams()); return securityUserMapper.securityUserPager(queryParams.getPage(), queryParams.getParams());
} }
@Override
public void qrCodeFormInputSecurityUser(SaveOrUpdateSecurityUserParams params) {
projectManageIndexService.saveOrUpdateSecurityUser(params);
}
} }

View File

@ -1,5 +1,7 @@
package com.changhu.module.miniProgram.service.impl; package com.changhu.module.miniProgram.service.impl;
import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.toolkit.Db; import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
@ -10,9 +12,18 @@ import com.changhu.module.miniProgram.pojo.params.SaveOrUpdateSecurityUserParams
import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo; import com.changhu.module.miniProgram.pojo.vo.IndexServiceProjectListVo;
import com.changhu.module.miniProgram.service.ProjectManageIndexService; import com.changhu.module.miniProgram.service.ProjectManageIndexService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.*;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -21,12 +32,16 @@ import java.util.Optional;
* @createTime 2024/9/10 下午3:50 * @createTime 2024/9/10 下午3:50
* @desc ProjectManageIndexServiceImpl... * @desc ProjectManageIndexServiceImpl...
*/ */
@Slf4j
@Service @Service
public class ProjectManageIndexServiceImpl implements ProjectManageIndexService { public class ProjectManageIndexServiceImpl implements ProjectManageIndexService {
@Autowired @Autowired
private ServiceProjectMapper serviceProjectMapper; private ServiceProjectMapper serviceProjectMapper;
@Autowired
private WxMaService wxMaService;
@Override @Override
public List<IndexServiceProjectListVo> getMyServiceProjectList() { public List<IndexServiceProjectListVo> getMyServiceProjectList() {
return serviceProjectMapper.getServiceProjectList(null, UserUtil.getUserId()); return serviceProjectMapper.getServiceProjectList(null, UserUtil.getUserId());
@ -43,8 +58,6 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService
@Override @Override
public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) { public void saveOrUpdateSecurityUser(SaveOrUpdateSecurityUserParams params) {
SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class); SecurityUser securityUser = BeanUtil.copyProperties(params, SecurityUser.class);
//填充保安单位
securityUser.setSecurityUnitId(UserUtil.getUnitId());
//新增的情况 //新增的情况
Long snowFlakeId = securityUser.getSnowFlakeId(); Long snowFlakeId = securityUser.getSnowFlakeId();
if (snowFlakeId == null) { if (snowFlakeId == null) {
@ -74,4 +87,18 @@ public class ProjectManageIndexServiceImpl implements ProjectManageIndexService
throw new MessageException(); throw new MessageException();
} }
} }
@Override
public ResponseEntity<Resource> shareForm_QR_Code(String path, Integer width) {
WxMaQrcodeService qrcodeService = wxMaService.getQrcodeService();
try {
File qrcodeFile = qrcodeService.createQrcode(path, width);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + qrcodeFile.getName())
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(new FileSystemResource(qrcodeFile));
} catch (WxErrorException e) {
throw new MessageException("生成表单二维码失败:{}", e.getMessage());
}
}
} }

View File

@ -144,9 +144,9 @@ sa-token:
wx: wx:
miniapp: miniapp:
#微信小程序的appid #微信小程序的appid
appid: wx8902ddbfddb820d1 appid: wx0acd1c4fcf94bdd3
#微信小程序的Secret #微信小程序的Secret
secret: 8674decea33df3362245937444944596 secret: 4b700dbacb42ef258537ddc61d964a17
msgDataFormat: JSON msgDataFormat: JSON
project: project:

View File

@ -48,6 +48,7 @@
ad4.name as 'streetName', ad4.name as 'streetName',
JSON_ARRAYAGG(JSON_OBJECT( JSON_ARRAYAGG(JSON_OBJECT(
'snowFlakeId', sp.snow_flake_id, 'snowFlakeId', sp.snow_flake_id,
'securityUnitId',sp.security_unit_id,
'name', sp.name, 'name', sp.name,
'type', sp.type, 'type', sp.type,
'isRecruitSecurity', sp.is_recruit_security, 'isRecruitSecurity', sp.is_recruit_security,