191 lines
6.9 KiB
Plaintext
191 lines
6.9 KiB
Plaintext
|
|
package com.nationalelectric.greenH5;
|
|||
|
|
|
|||
|
|
import java.text.SimpleDateFormat;
|
|||
|
|
import java.util.ArrayList;
|
|||
|
|
import java.util.Date;
|
|||
|
|
import java.util.HashMap;
|
|||
|
|
import java.util.List;
|
|||
|
|
import java.util.Map;
|
|||
|
|
|
|||
|
|
import javax.annotation.Resource;
|
|||
|
|
|
|||
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|||
|
|
import org.codehaus.jackson.type.TypeReference;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|||
|
|
import org.springframework.stereotype.Controller;
|
|||
|
|
import org.springframework.transaction.annotation.Transactional;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
|
|
|||
|
|
import com.jysoft.weChat.service.WechatService;
|
|||
|
|
import com.jysoft.weChat.vo.ContentVo;
|
|||
|
|
import com.nationalelectirc.Constant.Constant;
|
|||
|
|
import com.nationalelectirc.utils.RestResult;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenUserInfoBizc;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenApplyList;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenEAccount;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenLicenseplateApproval;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
|||
|
|
import com.nationalelectric.greenH5.po.Result;
|
|||
|
|
import com.nationalelectric.greenH5.service.EAccountService;
|
|||
|
|
import com.nationalelectric.greenH5.utils.AesEncryptUtil;
|
|||
|
|
import com.nationalelectric.greenH5.utils.Base64Utils;
|
|||
|
|
import com.sgcc.uap.persistence.IHibernateDao;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* <b>概述</b>:<br>
|
|||
|
|
* <p>
|
|||
|
|
* <b>功能</b>:<br>
|
|||
|
|
*
|
|||
|
|
* @author chenweikang
|
|||
|
|
*/
|
|||
|
|
@Controller
|
|||
|
|
@RequestMapping("/greenLicenseplateApproval")
|
|||
|
|
public class GreenLicenseplateApprovalController extends GreenBaseController {
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private BaseServiceImpl BaseService;
|
|||
|
|
/**
|
|||
|
|
* 访客预约service
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private WechatService wService;
|
|||
|
|
/**
|
|||
|
|
* 用户controller
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private GreenUserInfoController greenUserInfoController;
|
|||
|
|
/**
|
|||
|
|
* 用户service
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private IGreenUserInfoBizc greenuserinfoBizc;
|
|||
|
|
@Resource
|
|||
|
|
private GreenImageInfoController greenImageInfoController;
|
|||
|
|
@Autowired
|
|||
|
|
private EAccountService eAccountService;
|
|||
|
|
/**
|
|||
|
|
* HibernateDao逻辑构件
|
|||
|
|
*/
|
|||
|
|
@Autowired
|
|||
|
|
IHibernateDao hibernateDao;
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private BaseServiceImpl baseService;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询车牌审批记录
|
|||
|
|
*
|
|||
|
|
* @param result
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@SuppressWarnings("unchecked")
|
|||
|
|
@RequestMapping(value = "/getLpaList", method = RequestMethod.POST)
|
|||
|
|
public @ResponseBody RestResult getLpaList(@RequestBody Result result) {
|
|||
|
|
try {
|
|||
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|||
|
|
ArrayList<Object> params = new ArrayList<Object>();
|
|||
|
|
String orderBy = "";
|
|||
|
|
String sql = "select l.id,l.e_account_id,l.licenseplate1_status,l.licenseplate1,DATE_FORMAT(l.gmt_created,'%Y-%m-%d %H:%i') as gmt_created ,DATE_FORMAT(l.gmt_modified,'%Y-%m-%d %H:%i') as gmt_modified,e.`name` as real_name,e.department_name,e.user_type "
|
|||
|
|
+ "from green_licenseplate_approval l left join green_e_account e on l.e_account_id = e.id "
|
|||
|
|
+ "where l.is_deleted='N' ";
|
|||
|
|
if("1".equals(result.getType())){
|
|||
|
|
sql+="and l.licenseplate1_status='0'";
|
|||
|
|
orderBy = " l.gmt_created ";
|
|||
|
|
}else{
|
|||
|
|
sql+="and l.licenseplate1_status<>'0'";
|
|||
|
|
orderBy = " l.gmt_modified ";
|
|||
|
|
}
|
|||
|
|
String page = result.getPage();
|
|||
|
|
String pageSize = result.getPageSize();
|
|||
|
|
|
|||
|
|
if(page.matches("\\d+") && pageSize.matches("\\d+")){
|
|||
|
|
Integer x = Integer.valueOf(page);
|
|||
|
|
Integer y = Integer.valueOf(pageSize);
|
|||
|
|
params.add((x-1)*y);
|
|||
|
|
params.add(y);
|
|||
|
|
sql+=" ORDER BY "+orderBy+ " DESC LIMIT ?,?";
|
|||
|
|
}
|
|||
|
|
list = hibernateDao.queryForListWithSql(sql.toString(), params.toArray());
|
|||
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 车辆申请的审批
|
|||
|
|
*
|
|||
|
|
* @param GreenLicenseplateApproval
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
|
|||
|
|
@Transactional(rollbackFor = Exception.class)
|
|||
|
|
@RequestMapping(value = "/updatelicenseplateApprovalBatch", method = RequestMethod.POST)
|
|||
|
|
public @ResponseBody RestResult updatelicenseplateApproval(@RequestBody Object requestBody) {
|
|||
|
|
GreenLicenseplateApproval greenLicenseplateApproval = new ObjectMapper().convertValue(requestBody, new TypeReference<GreenLicenseplateApproval>() { });
|
|||
|
|
try {
|
|||
|
|
String tip="";
|
|||
|
|
String type = greenLicenseplateApproval.getLicenseplate1Status();
|
|||
|
|
String modifier = greenLicenseplateApproval.getModifier();
|
|||
|
|
Long id = greenLicenseplateApproval.getId();
|
|||
|
|
Long eaccountId = greenLicenseplateApproval.getEaccountId();
|
|||
|
|
if("2".equals(type)){//拒绝
|
|||
|
|
String updateSql = "UPDATE green_licenseplate_approval SET licenseplate1_status = '2' ,modifier =?,gmt_modified= sysdate() WHERE id = ? ";
|
|||
|
|
hibernateDao.executeSqlUpdate(updateSql,new Object[]{modifier,id });
|
|||
|
|
tip = "审批未通过";
|
|||
|
|
}else if("1".equals(type)){
|
|||
|
|
String updateSql = "UPDATE green_licenseplate_approval SET licenseplate1_status = '1',modifier =?,gmt_modified= sysdate() WHERE id = ? ";
|
|||
|
|
hibernateDao.executeSqlUpdate(updateSql,new Object[]{modifier,id });
|
|||
|
|
tip = "审批通过";
|
|||
|
|
}
|
|||
|
|
GreenEAccount eccount = eAccountService.getById(eaccountId);
|
|||
|
|
GreenUserInfo user = getUserInfo(eccount.getUserId());
|
|||
|
|
if (!tip.equals("")) {
|
|||
|
|
// 通知用户
|
|||
|
|
if (eccount != null) {
|
|||
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|||
|
|
Map<String, ContentVo> data = new HashMap<String, ContentVo>();
|
|||
|
|
data.put("first", new ContentVo("尊敬的用户,您的车辆信息审核结果已出", "#173177"));
|
|||
|
|
data.put("keyword1", new ContentVo(tip, "#black"));
|
|||
|
|
data.put("keyword2", new ContentVo(sdf.format(new Date()), "#black"));
|
|||
|
|
data.put("remark", new ContentVo("感谢您的参与和支持", "#173177"));
|
|||
|
|
wService.publishMsg(data, user.getWxOpenId(), 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return new RestResult(Constant.SUCCESS, "操作成功!");
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "处理失败");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询车牌审批记录
|
|||
|
|
*
|
|||
|
|
* @param result
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@SuppressWarnings("unchecked")
|
|||
|
|
@RequestMapping(value = "/getOwnLpList", method = RequestMethod.POST)
|
|||
|
|
public @ResponseBody RestResult getOwnLpList(@RequestBody Result result) {
|
|||
|
|
try {
|
|||
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|||
|
|
ArrayList<Object> params = new ArrayList<Object>();
|
|||
|
|
String sql = "select licenseplate1 from green_licenseplate_approval where user_id=? and is_deleted='N' and licenseplate1_status='1'";
|
|||
|
|
params.add(result.getUserId());
|
|||
|
|
list = hibernateDao.queryForListWithSql(sql, params.toArray());
|
|||
|
|
return new RestResult(Constant.SUCCESS, "查询成功", list);
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|