115 lines
4.9 KiB
Plaintext
115 lines
4.9 KiB
Plaintext
package com.nationalelectric.greenH5;
|
|
|
|
import java.io.Serializable;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.UUID;
|
|
|
|
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.RequestMethod;
|
|
|
|
import com.nationalelectirc.Constant.Constant;
|
|
import com.nationalelectirc.utils.RestResult;
|
|
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
|
|
import com.nationalelectric.greenH5.po.GreenInfoGrather;
|
|
import com.nationalelectric.greenH5.service.InfoGratherService;
|
|
import com.sgcc.uap.rest.annotation.RawResponseBody;
|
|
|
|
@Controller
|
|
@RequestMapping("/infoGrather")
|
|
public class GreenInfoGratherController {
|
|
|
|
@Autowired
|
|
private InfoGratherService iInfoGratherService;
|
|
@Autowired
|
|
private BaseServiceImpl baseService;
|
|
|
|
// 人员信息新增:名称 单位、部门、工号、姓名、电话、身份证号、人脸照片
|
|
@RequestMapping(value = "/insertInfoGrather", method = { RequestMethod.GET, RequestMethod.POST })
|
|
@RawResponseBody
|
|
public RestResult insertPepMessige(GreenInfoGrather greenInfoGrather) {
|
|
// 查询单位部门名称
|
|
try {
|
|
if (greenInfoGrather.getName() == null || greenInfoGrather.getName().equals("")) {
|
|
return new RestResult("0", "请填写姓名");
|
|
}
|
|
if (greenInfoGrather.getCompany() == null || greenInfoGrather.getCompany().equals("")) {
|
|
return new RestResult("0", "请选择单位");
|
|
}
|
|
if (greenInfoGrather.getDepartment() == null || greenInfoGrather.getDepartment().equals("")) {
|
|
return new RestResult("0", "请输入部门");
|
|
}
|
|
if (greenInfoGrather.getPhone() == null || greenInfoGrather.getPhone().equals("")) {
|
|
return new RestResult("0", "请输入手机号");
|
|
}
|
|
if (greenInfoGrather.getFaceImgUrl() == null || greenInfoGrather.getFaceImgUrl().equals("")) {
|
|
return new RestResult("0", "请上传证件照");
|
|
}
|
|
if (greenInfoGrather.getLifeImgUrl() == null || greenInfoGrather.getLifeImgUrl().equals("")) {
|
|
return new RestResult("0", "请上传自拍大头照");
|
|
}
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
|
String date = sdf1.format(new Date()) + "/";
|
|
// String uuid = date + UUID.randomUUID().toString().replaceAll("-","");
|
|
|
|
//证件照
|
|
String face = date + greenInfoGrather.getPhone() + "_face";
|
|
boolean flag1 = baseService.saveImgToIO("infoGrather/"+face+Constant.IMG_SUFFIX, greenInfoGrather.getFaceImgUrl());
|
|
greenInfoGrather.setFaceImgUrl("infoGrather/"+face+Constant.IMG_SUFFIX);
|
|
//生活照
|
|
String life = date + greenInfoGrather.getPhone() + "_life";
|
|
boolean flag2 = baseService.saveImgToIO("infoGrather/"+life+Constant.IMG_SUFFIX, greenInfoGrather.getLifeImgUrl());
|
|
greenInfoGrather.setLifeImgUrl("infoGrather/"+life+Constant.IMG_SUFFIX);
|
|
|
|
GreenInfoGrather grather = iInfoGratherService.getOne(greenInfoGrather.getName(), greenInfoGrather.getPhone());
|
|
if (grather == null) {
|
|
greenInfoGrather.setCreatedTime(new Date());
|
|
iInfoGratherService.insertInfoGrathe(greenInfoGrather);
|
|
} else {
|
|
greenInfoGrather.setId(grather.getId());
|
|
greenInfoGrather.setUpdateTime(new Date());
|
|
iInfoGratherService.update(greenInfoGrather);
|
|
}
|
|
return new RestResult("1", "提交成功"); // 正确提示
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return new RestResult("0", "提交失败"); // 错误提示
|
|
}
|
|
|
|
}
|
|
@RequestMapping(value = "/queryOne", method = { RequestMethod.GET, RequestMethod.POST })
|
|
@RawResponseBody
|
|
public RestResult queryOne(GreenInfoGrather greenInfoGrather){
|
|
try {
|
|
if (greenInfoGrather.getName() == null || greenInfoGrather.getName().equals("")) {
|
|
return new RestResult("0", "请填写姓名");
|
|
}
|
|
if (greenInfoGrather.getCompany() == null || greenInfoGrather.getCompany().equals("")) {
|
|
return new RestResult("0", "请选择单位");
|
|
}
|
|
if (greenInfoGrather.getDepartment() == null || greenInfoGrather.getDepartment().equals("")) {
|
|
return new RestResult("0", "请选择部门");
|
|
}
|
|
if (greenInfoGrather.getPhone() == null || greenInfoGrather.getPhone().equals("")) {
|
|
return new RestResult("0", "请填写手机号");
|
|
}
|
|
if (greenInfoGrather.getFaceImgUrl() == null || greenInfoGrather.getFaceImgUrl().equals("")) {
|
|
return new RestResult("0", "请上传证件照");
|
|
}
|
|
if (greenInfoGrather.getLifeImgUrl() == null || greenInfoGrather.getLifeImgUrl().equals("")) {
|
|
return new RestResult("0", "请上传生活照");
|
|
}
|
|
GreenInfoGrather grather = iInfoGratherService.getOne(greenInfoGrather.getName(), greenInfoGrather.getPhone());
|
|
if (grather != null) {
|
|
return new RestResult("2", "已有数据"); // 正确提示
|
|
}
|
|
return new RestResult("1", "无数据");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return new RestResult("0", "请求失败"); // 错误提示
|
|
}
|
|
}
|
|
}
|