135 lines
4.9 KiB
Plaintext
135 lines
4.9 KiB
Plaintext
|
|
package com.nationalelectric.greenH5;
|
||
|
|
|
||
|
|
import java.text.SimpleDateFormat;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
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;
|
||
|
|
|
||
|
|
import com.nationalelectirc.Constant.Constant;
|
||
|
|
import com.nationalelectirc.utils.RestResult;
|
||
|
|
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
|
||
|
|
import com.nationalelectric.greenH5.bizc.GreenLicenseplateApprovalBizc;
|
||
|
|
import com.nationalelectric.greenH5.bizc.IGreenLicenseplateApprovalBizc;
|
||
|
|
import com.nationalelectric.greenH5.po.GreenEAccount;
|
||
|
|
import com.nationalelectric.greenH5.po.GreenLicenseplateApproval;
|
||
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
||
|
|
import com.nationalelectric.greenH5.service.EAccountService;
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("/eAccount")
|
||
|
|
public class EAccountController extends GreenBaseController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private EAccountService eAccountService;
|
||
|
|
@Autowired
|
||
|
|
private BaseServiceImpl baseService;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private IGreenLicenseplateApprovalBizc greenLicenseplateApprovalBizc;
|
||
|
|
|
||
|
|
@RequestMapping("/getEAccount")
|
||
|
|
@ResponseBody
|
||
|
|
public RestResult getEAccount(String userId) {
|
||
|
|
GreenUserInfo userInfo = getUserInfo(userId);
|
||
|
|
if (userInfo == null) {
|
||
|
|
return new RestResult("0", "用户不存在");
|
||
|
|
}
|
||
|
|
GreenEAccount account = eAccountService.getOne(userId);
|
||
|
|
if (account != null) {
|
||
|
|
if (account.getImg() != null && !account.getImg().equals("")) {
|
||
|
|
account.setImg(baseService.getAppImgUrl()+account.getImg());
|
||
|
|
}
|
||
|
|
if (account.getLifeImg() != null && !account.getLifeImg().equals("")) {
|
||
|
|
account.setLifeImg(baseService.getAppImgUrl()+account.getLifeImg());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
||
|
|
map.put("userInfo", userInfo);
|
||
|
|
map.put("eAccount", account);
|
||
|
|
return new RestResult("1", map);
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("/saveOrUpdate")
|
||
|
|
@ResponseBody
|
||
|
|
public RestResult saveOrUpdate(GreenEAccount eAccount) {
|
||
|
|
try {
|
||
|
|
// if (eAccount.getName() == null || eAccount.getName().equals("")) {
|
||
|
|
// return new RestResult("0", "请填写姓名");
|
||
|
|
// }
|
||
|
|
// if (eAccount.getJobNum() == null || eAccount.getJobNum().equals(""))
|
||
|
|
// {
|
||
|
|
// return new RestResult("0", "请输入工号");
|
||
|
|
// }
|
||
|
|
// if (eAccount.getDepartmentName() == null ||
|
||
|
|
// eAccount.getDepartmentName().equals("")) {
|
||
|
|
// return new RestResult("0", "请选择部门");
|
||
|
|
// }
|
||
|
|
// if (eAccount.getPhoneNum() == null ||
|
||
|
|
// eAccount.getPhoneNum().equals("")) {
|
||
|
|
// return new RestResult("0", "请输入手机号");
|
||
|
|
// }
|
||
|
|
String carIdNumOneNew = eAccount.getCarIdNumOneNew();
|
||
|
|
String carIdNumOne = eAccount.getCarIdNumOne();
|
||
|
|
String carIdNumTwoNew = eAccount.getCarIdNumTwoNew();
|
||
|
|
String carIdNumTwo = eAccount.getCarIdNumTwo();
|
||
|
|
GreenEAccount account = eAccountService.getOne(eAccount.getUserId());
|
||
|
|
if (account != null) {
|
||
|
|
eAccount.setId(account.getId());
|
||
|
|
eAccount.setUpdateTime(new Date());
|
||
|
|
} else {
|
||
|
|
eAccount.setCreatedTime(new Date());
|
||
|
|
}
|
||
|
|
if (eAccount.getUserId() == null || eAccount.getUserId().equals("")) {
|
||
|
|
return new RestResult("0", "参数缺失userId");
|
||
|
|
}
|
||
|
|
if (eAccount.getImg() == null || eAccount.getImg().equals("")) {
|
||
|
|
return new RestResult("0", "请上传证件照");
|
||
|
|
}
|
||
|
|
if (eAccount.getLifeImg() == null || eAccount.getLifeImg().equals("")) {
|
||
|
|
return new RestResult("0", "请上传自拍大头照");
|
||
|
|
}
|
||
|
|
if(!carIdNumOneNew.equals(carIdNumOne)){
|
||
|
|
eAccount.setCarIdNumOne(carIdNumOneNew);
|
||
|
|
GreenLicenseplateApproval gsa = new GreenLicenseplateApproval();
|
||
|
|
gsa.setLicenseplate1(carIdNumOneNew);
|
||
|
|
gsa.setEaccountId(eAccount.getId());
|
||
|
|
gsa.setGmtCreated(new Date());
|
||
|
|
|
||
|
|
greenLicenseplateApprovalBizc.add(gsa);
|
||
|
|
}
|
||
|
|
if(!carIdNumTwoNew.equals(carIdNumTwo)){
|
||
|
|
eAccount.setCarIdNumTwo(carIdNumTwoNew);
|
||
|
|
GreenLicenseplateApproval gsa = new GreenLicenseplateApproval();
|
||
|
|
gsa.setLicenseplate1(carIdNumTwoNew);
|
||
|
|
gsa.setEaccountId(eAccount.getId());
|
||
|
|
gsa.setGmtCreated(new Date());
|
||
|
|
greenLicenseplateApprovalBizc.add(gsa);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
||
|
|
String date = sdf1.format(new Date()) + "/";
|
||
|
|
// 证件照
|
||
|
|
String face = date + eAccount.getPhoneNum() + "_face";
|
||
|
|
boolean flag1 = baseService.saveImgToIO("eAccount/" + face + Constant.IMG_SUFFIX, eAccount.getImg());
|
||
|
|
eAccount.setImg("eAccount/" + face + Constant.IMG_SUFFIX);
|
||
|
|
// 生活照
|
||
|
|
String life = date + eAccount.getPhoneNum() + "_life";
|
||
|
|
boolean flag2 = baseService.saveImgToIO("eAccount/" + life + Constant.IMG_SUFFIX, eAccount.getLifeImg());
|
||
|
|
eAccount.setLifeImg("eAccount/" + life + Constant.IMG_SUFFIX);
|
||
|
|
eAccountService.saveOrUpdate(eAccount);
|
||
|
|
|
||
|
|
return new RestResult("1","操作成功");
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
return new RestResult("0","服务异常");
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|