|
@@ -0,0 +1,280 @@
|
|
|
|
+package com.ruoyi.wx.api.controller;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.img.ImgUtil;
|
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
+import com.ruoyi.common.utils.DictUtils;
|
|
|
|
+import com.ruoyi.hj.domain.*;
|
|
|
|
+import com.ruoyi.hj.service.*;
|
|
|
|
+import com.ruoyi.hj.utils.ReviewerStatus;
|
|
|
|
+import com.ruoyi.system.domain.SysNotice;
|
|
|
|
+import com.ruoyi.system.service.ISysConfigService;
|
|
|
|
+import com.ruoyi.system.service.ISysNoticeService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.util.ResourceUtils;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.awt.*;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@RestController
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/wx/api/veterans")
|
|
|
|
+public class VeteransController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Value("${ruoyi.path}")
|
|
|
|
+ private String path;
|
|
|
|
+
|
|
|
|
+ private String TEL = "hj.fwrx.tel";
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHjVeteransInfoService hjVeteransInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHjBasicsService hjBasicsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysConfigService configService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysNoticeService noticeService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHjRelationInfoService hjRelationInfoService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHjUserRelationService hjUserRelationService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHjMsgInfoService hjMsgInfoService;
|
|
|
|
+
|
|
|
|
+ @PostMapping("/addUserRelation")
|
|
|
|
+ public AjaxResult addUserRelation(@RequestBody HjUserRelation hjUserRelation) {//添加 军属的时候直接 添加一个 军人信息
|
|
|
|
+
|
|
|
|
+ HjVeteransInfo hjVeteransInfo = new HjVeteransInfo();
|
|
|
|
+ hjVeteransInfo.setVeteransIdcard(hjUserRelation.getUserIdcard());
|
|
|
|
+ List<HjVeteransInfo> tmpHjVeteransInfoList = hjVeteransInfoService.selectHjVeteransInfoListUnique(hjVeteransInfo);
|
|
|
|
+
|
|
|
|
+ List<HjUserRelation> tmpHjUserRelationList = hjUserRelationService.selectHjUserRelationList(hjUserRelation);
|
|
|
|
+
|
|
|
|
+ if (tmpHjVeteransInfoList.size() > 0 || tmpHjUserRelationList.size() > 0) {
|
|
|
|
+ return AjaxResult.error("身份号码 不能重复");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hjUserRelationService.insertHjUserRelation(hjUserRelation);//先增加一个军属
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/updateUserRelation")
|
|
|
|
+ public AjaxResult updateUserRelation(@RequestBody HjUserRelation hjUserRelation) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ HjVeteransInfo hjVeteransInfo = new HjVeteransInfo();
|
|
|
|
+ hjVeteransInfo.setVeteransIdcard(hjUserRelation.getUserIdcard());
|
|
|
|
+ List<HjVeteransInfo> tmpHjVeteransInfoList = hjVeteransInfoService.selectHjVeteransInfoListUnique(hjVeteransInfo);
|
|
|
|
+
|
|
|
|
+ List<HjUserRelation> tmpHjUserRelationList = hjUserRelationService.selectHjUserRelationList(hjUserRelation);
|
|
|
|
+
|
|
|
|
+ if (tmpHjVeteransInfoList.size() > 0 || tmpHjUserRelationList.size() > 0) {
|
|
|
|
+ if (tmpHjUserRelationList.get(0).getUserId() == hjUserRelation.getUserId() && tmpHjUserRelationList.get(0).getUserIdcard() == hjUserRelation.getUserIdcard()) {//ID 相同
|
|
|
|
+ return AjaxResult.success(hjUserRelationService.updateHjUserRelation(hjUserRelation));
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.error("身份号码 不能重复");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(hjUserRelationService.updateHjUserRelation(hjUserRelation));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getUserRelationInfo/{id}")
|
|
|
|
+ public AjaxResult getRelationInfoList(@PathVariable("id") Long id) {
|
|
|
|
+ return AjaxResult.success(hjUserRelationService.selectHjUserRelationByUserId(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/deleteUserRelationInfo/{id}")
|
|
|
|
+ public AjaxResult deleteUserRelationInfo(@PathVariable("id") Long id) {
|
|
|
|
+ hjUserRelationService.deleteHjUserRelationByUserId(id);
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/getUserRelationList")
|
|
|
|
+ public AjaxResult getUserRelationList(@RequestBody HjUserRelation hjUserRelation) {
|
|
|
|
+ return AjaxResult.success(hjUserRelationService.selectHjUserRelationList(hjUserRelation));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getRelationInfoList")
|
|
|
|
+ public AjaxResult getRelationInfoList() {
|
|
|
|
+ return AjaxResult.success(hjRelationInfoService.selectHjRelationInfoList(new HjRelationInfo()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getTelInfo")
|
|
|
|
+ public AjaxResult getTelInfo() {
|
|
|
|
+ return AjaxResult.success("操作成功", configService.selectConfigByKey(TEL));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getUserQrCode/{id}/{type}")
|
|
|
|
+ public AjaxResult getTelInfo(@PathVariable("id") String id, @PathVariable("type") String type, HttpServletResponse response) throws IOException {
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.set("id", id);
|
|
|
|
+ jsonObject.set("type", type);
|
|
|
|
+ jsonObject.set("time", formatter.format(new Date()));
|
|
|
|
+ File file= new File(path + "/logo.png");
|
|
|
|
+// Image src = ImageIO.read(new File("E:\\123456.png"));
|
|
|
|
+// return AjaxResult.success("操作成功", QrCodeUtil.generateAsBase64(jsonObject.toString(), QrConfig.create().setForeColor(new Color(46, 79, 28)), ImgUtil.IMAGE_TYPE_PNG, src));
|
|
|
|
+ QrConfig config = new QrConfig(500, 500);
|
|
|
|
+ //附带logo
|
|
|
|
+ config.setImg(file);
|
|
|
|
+ // 设置边距,既二维码和背景之间的边距
|
|
|
|
+// config.setMargin(3);
|
|
|
|
+ // 高纠错级别
|
|
|
|
+ config.setErrorCorrection(ErrorCorrectionLevel.H);
|
|
|
|
+ // 设置前景色,既二维码颜色(青色)
|
|
|
|
+ config.setForeColor(new Color(46, 79, 28).getRGB());
|
|
|
|
+ return AjaxResult.success("操作成功", QrCodeUtil.generateAsBase64(jsonObject.toString(), config.setForeColor(new Color(46, 79, 28)), ImgUtil.IMAGE_TYPE_PNG));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// public static void main(String[] args) {
|
|
|
|
+//
|
|
|
|
+// QrCodeUtil.generate("http://hutool.cn/", QrConfig.create().setForeColor( new Color(46,79,28) ), FileUtil.file("e:/qrcode.jpg"));
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/info/{id}/{type}")
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id, @PathVariable("type") int type) {
|
|
|
|
+ HjVeteransInfo tmp = new HjVeteransInfo();
|
|
|
|
+ if (type == 3) {
|
|
|
|
+
|
|
|
|
+ HjUserRelation tmpHjUserRelation = hjUserRelationService.selectHjUserRelationByUserId(id);
|
|
|
|
+ tmp.setVeteransName(tmpHjUserRelation.getUserName());
|
|
|
|
+ tmp.setVeteransStatus("2");
|
|
|
|
+ tmp.setVeteransIdcard(tmpHjUserRelation.getUserIdcard());
|
|
|
|
+ tmp.setVeteransTel(tmpHjUserRelation.getTel());
|
|
|
|
+ tmp.setAddress(tmpHjUserRelation.getAddress());
|
|
|
|
+
|
|
|
|
+ if (tmpHjUserRelation.getLevel() == null || tmpHjUserRelation.getLevel().equals("")) {
|
|
|
|
+ tmp.setLevel("空");
|
|
|
|
+ } else {
|
|
|
|
+ tmp.setLevel(DictUtils.getDictLabel("basics_level", tmpHjUserRelation.getLevel()));
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ;
|
|
|
|
+ tmp = hjVeteransInfoService.selectHjVeteransInfoByVeteransId(id.intValue());
|
|
|
|
+ if (tmp.getLevel() == null || tmp.getLevel().equals("")) {
|
|
|
|
+ tmp.setLevel("空");
|
|
|
|
+ } else {
|
|
|
|
+ tmp.setLevel(DictUtils.getDictLabel("basics_level", tmp.getLevel()));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/infoList")
|
|
|
|
+ public AjaxResult infoList(@RequestBody HjVeteransInfo hjVeteransInfo) {
|
|
|
|
+ return AjaxResult.success(hjVeteransInfoService.selectHjVeteransInfoList(hjVeteransInfo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据用户附近的人
|
|
|
|
+ @GetMapping("/nearby/{veteransId}")
|
|
|
|
+ public AjaxResult nearbyList(@PathVariable Long veteransId) {
|
|
|
|
+ return AjaxResult.success(hjVeteransInfoService.nearbyList(veteransId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/uploadInfo")
|
|
|
|
+ public AjaxResult uploadInfo(@RequestBody HjVeteransInfo hjVeteransInfo) {
|
|
|
|
+
|
|
|
|
+ if (!ReviewerStatus.REVIEWER_WAIT.getCode().equals(hjVeteransInfo.getVeteransStatus())) {//状态为尚未审核
|
|
|
|
+
|
|
|
|
+ HjMsgInfo hjMsgInfo = new HjMsgInfo();
|
|
|
|
+ hjMsgInfo.setRemark(hjVeteransInfo.getRemark());
|
|
|
|
+ hjMsgInfo.setMsgReviewer(String.valueOf(hjVeteransInfo.getVeteransReviewer()));
|
|
|
|
+ hjMsgInfo.setReviewerName(String.valueOf(hjVeteransInfo.getVeteransReviewer()));
|
|
|
|
+ hjMsgInfo.setMsgStatus(hjVeteransInfo.getVeteransStatus());
|
|
|
|
+ hjMsgInfo.setReviewerTime(new Date());
|
|
|
|
+ hjMsgInfo.setVeteransId(hjVeteransInfo.getVeteransId());
|
|
|
|
+ hjMsgInfo.setReviewerName(hjVeteransInfo.getVeteransName());
|
|
|
|
+ hjMsgInfo.setRemark(hjVeteransInfo.getRemark());
|
|
|
|
+ hjMsgInfo.setMsgType("1");
|
|
|
|
+ if (ReviewerStatus.REVIEWER_OK.getCode().equals(hjVeteransInfo.getVeteransStatus())) {
|
|
|
|
+ hjMsgInfo.setMsgInfo(" 您的身份认证信息 已经通过 ");
|
|
|
|
+ } else {
|
|
|
|
+ hjMsgInfo.setMsgInfo(" 您的身份认证信息 已经被拒绝 ");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hjMsgInfoService.insertHjMsgInfo(hjMsgInfo);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hjVeteransInfo.setVeteransTime(new Date());
|
|
|
|
+ return AjaxResult.success(hjVeteransInfoService.updateHjVeteransInfo(hjVeteransInfo));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/register")
|
|
|
|
+ public AjaxResult register(@RequestBody HjVeteransInfo hjVeteransInfo) {
|
|
|
|
+
|
|
|
|
+ List<HjVeteransInfo> hjVeteransInfoListTmp = hjVeteransInfoService.selectHjVeteransInfoListUnique(hjVeteransInfo);
|
|
|
|
+ if (hjVeteransInfoListTmp == null || hjVeteransInfoListTmp.size() == 0) {//身份证和手机号码不能重复
|
|
|
|
+
|
|
|
|
+ HjBasics tmpHjBasics = hjBasicsService.selectHjBasicsListUnique(hjVeteransInfo.getVeteransIdcard(), hjVeteransInfo.getVeteransName());
|
|
|
|
+
|
|
|
|
+ if (tmpHjBasics != null && ReviewerStatus.BASICS_WAIT.getCode().equals(tmpHjBasics.getBasicsStatus())) {//基础表中有 并且状态为没有审核
|
|
|
|
+ hjVeteransInfo.setVeteransStatus(ReviewerStatus.REVIEWER_OK.getCode());//审核通过
|
|
|
|
+ hjVeteransInfo.setRemark(" 系統自动审核 ");
|
|
|
|
+ hjVeteransInfo.setVeteransReviewer(Long.valueOf("1"));
|
|
|
|
+
|
|
|
|
+ hjVeteransInfoService.insertHjVeteransInfo(hjVeteransInfo);//
|
|
|
|
+ hjVeteransInfoListTmp = hjVeteransInfoService.selectHjVeteransInfoListUnique(hjVeteransInfo);
|
|
|
|
+
|
|
|
|
+ tmpHjBasics.setBasicsStatus(ReviewerStatus.BASICS_OK.getCode());
|
|
|
|
+ tmpHjBasics.setBasicsUserId(hjVeteransInfoListTmp.get(0).getVeteransId());
|
|
|
|
+ hjBasicsService.updateHjBasics(tmpHjBasics);
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ } else {
|
|
|
|
+ hjVeteransInfo.setVeteransStatus(ReviewerStatus.REVIEWER_WAIT.getCode());//审核通过
|
|
|
|
+ hjVeteransInfoService.insertHjVeteransInfo(hjVeteransInfo);
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return AjaxResult.error("您已认证,请登录");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/getNoticeServiceList")
|
|
|
|
+ public AjaxResult getNoticeServiceList(@RequestBody SysNotice sysNotice) {
|
|
|
|
+ return AjaxResult.success(noticeService.selectNoticeList(sysNotice));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getNoticeInfo/{id}")
|
|
|
|
+ public AjaxResult getNoticeInfo(@PathVariable("id") Long id) {
|
|
|
|
+ return AjaxResult.success(noticeService.selectNoticeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|