qa-prevention-gwj/src/main/java/com/zcloud/controller/bus/SpecialUserController.java

413 lines
14 KiB
Java
Raw Normal View History

2024-02-06 11:02:25 +08:00
package com.zcloud.controller.bus;
import java.text.SimpleDateFormat;
2024-02-06 11:02:25 +08:00
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.zcloud.aspect.DockAnnotation;
import com.zcloud.service.system.UsersService;
import com.zcloud.util.Jurisdiction;
2024-06-19 11:36:09 +08:00
import org.apache.commons.lang.StringUtils;
2024-02-06 11:02:25 +08:00
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 org.springframework.web.servlet.ModelAndView;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.util.DateUtil;
import com.zcloud.util.ObjectExcelView;
import com.zcloud.util.Tools;
import com.zcloud.entity.PageData;
import com.zcloud.service.bus.SpecialUserService;
/**
*
* luoxiaobao
* 2022-04-20
* www.zcloudchina.com
*/
@Controller
@RequestMapping("/specialuser")
public class SpecialUserController extends BaseController {
@Autowired
private SpecialUserService specialuserService;
@Autowired
private UsersService usersService;
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/add")
@RequiresPermissions("specialuser:add")
@ResponseBody
@DockAnnotation(isAdd = true)
public Object add() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if (pd.getString("ISREVIEW").equals("true")) {
pd.put("ISREVIEW","1");
}else {
pd.put("ISREVIEW","0");
}
2024-02-06 11:02:25 +08:00
PageData dockData = new PageData(); // 主要对接数据
PageData blindPageData = new PageData(); // pd对接数据
pd.put("SPECIALUSER_ID", this.get32UUID()); //主键
pd.put("CREATOR", Jurisdiction.getUSER_ID());
pd.put("CREATTIME", DateUtil.date2Str(new Date()));
pd.put("OPERATOR",Jurisdiction.getUSER_ID());
pd.put("OPERATTIME",DateUtil.date2Str(new Date()));
pd.put("ISDELETE","0");
blindPageData.putAll(pd);
dockData.put("dockData", JSON.toJSONString(blindPageData));
specialuserService.save(pd);
map.put("dockData", JSON.toJSONString(dockData));
map.put("result", errInfo);
return map;
}
/**
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
@RequiresPermissions("specialuser:del")
@ResponseBody
@DockAnnotation
public Object delete() throws Exception{
Map<String,String> map = new HashMap<String,String>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData dockData = new PageData(); // 主要对接数据
// 修改与删除功能仅企业主账号可操作,并仅可修改与删除本单位添加的特种人员信息
String corpID = Jurisdiction.getCORPINFO_ID(); // 登录企业信息
PageData special = specialuserService.findById(pd); // 修改特种作业人员数据
PageData userPd = new PageData();
userPd.put("USER_ID",special.getString("CREATOR"));
PageData creatorUser = usersService.findById(userPd); // 获取添加人员信息
String creatorCorp = creatorUser.getString("CORPINFO_ID"); // 获取添加人企业信息
if(Tools.isEmpty(creatorUser)){
map.put("result", "error");
map.put("msg", "未找到添加人信息,请联系管理员!");
return map;
}
if(!creatorCorp.equals(corpID)){
map.put("result", "error");
map.put("msg", "改信息只有添加人员单位可以进行修改,请联系添加企业主账号进行修改!");
return map;
}
String isMain = Jurisdiction.getIS_MAIN();
if(!"1".equals(isMain)){
map.put("result", "error");
map.put("msg", "您不是企业主账号!请联系企业主账号进行修改!");
return map;
}
pd.put("CREATTIME", DateUtil.date2Str(new Date()));
pd.put("OPERATOR",Jurisdiction.getUSER_ID());
pd.put("ISDELETE","0");
pd = this.getPageData();
PageData blindPageData = new PageData(); // pd对接数据
blindPageData.putAll(pd);
dockData.put("dockData", JSON.toJSONString(blindPageData));
specialuserService.delete(pd);
map.put("dockData", JSON.toJSONString(dockData));
map.put("result", errInfo); //返回结果
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
@RequiresPermissions("specialuser:edit")
@ResponseBody
@DockAnnotation
public Object edit() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData dockData = new PageData();
if (pd.getString("ISREVIEW").equals("true")) {
pd.put("ISREVIEW","1");
}else {
pd.put("ISREVIEW","0");
}
2024-02-06 11:02:25 +08:00
// 修改与删除功能仅企业主账号可操作,并仅可修改与删除本单位添加的特种人员信息
String corpID = Jurisdiction.getCORPINFO_ID(); // 登录企业信息
PageData special = specialuserService.findById(pd); // 修改特种作业人员数据
PageData userPd = new PageData();
userPd.put("USER_ID",special.getString("CREATOR"));
PageData creatorUser = usersService.findById(userPd); // 获取添加人员信息
if(Tools.isEmpty(creatorUser)){
map.put("result", "error");
map.put("msg", "未找到添加人信息,请联系管理员!");
return map;
}
String creatorCorp = creatorUser.getString("CORPINFO_ID"); // 获取添加人企业信息
if(!creatorCorp.equals(corpID)){
map.put("result", "error");
map.put("msg", "改信息只有添加人员单位可以进行修改,请联系添加企业主账号进行修改!");
return map;
}
String isMain = Jurisdiction.getIS_MAIN();
if(!"1".equals(isMain)){
map.put("result", "error");
map.put("msg", "您不是企业主账号!请联系企业主账号进行修改!");
return map;
}
PageData blindPageData = new PageData(); // pd对接数据
blindPageData.putAll(pd);
dockData.put("dockData", JSON.toJSONString(blindPageData));
specialuserService.edit(pd);
map.put("dockData", JSON.toJSONString(dockData));
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
@RequiresPermissions("specialuser:list")
@ResponseBody
public Object list(Page page) throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
pd.put("keyTypeIn1And2","1");
page.setPd(pd);
List<PageData> varList = specialuserService.list(page); //列出SpecialUser列表
//判断证件是否有效(先判断有效期是否符合,再判断是否复审过)
for (PageData pageData : varList) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String validity_time_start = pageData.getString("VALIDITY_TIME_START");
Date startTime = sdf.parse(validity_time_start);
String validity_time_end = pageData.getString("VALIDITY_TIME_END");
Date endTime = sdf.parse(validity_time_end);
Date currentTime = new Date();
2024-06-19 11:36:09 +08:00
if (startTime.compareTo(currentTime) < 0 && currentTime.compareTo(endTime) < 0) {
if (StringUtils.equals("1",pageData.getString("ISREVIEW"))){
pageData.put("ISEFFECTIVE","是");
} else {
pageData.put("ISEFFECTIVE","否");
}
} else {
pageData.put("ISEFFECTIVE","否");
}
}
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/listByDept")
@RequiresPermissions("specialuser:list")
@ResponseBody
public Object listByDept(Page page) throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
pd.put("keyTypeIn1And2","1");
page.setPd(pd);
List<PageData> varList = specialuserService.listByDept(page); //列出SpecialUser列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/listByOperation")
@RequiresPermissions("specialuser:list")
@ResponseBody
public Object listByOperation(Page page) throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
pd.put("keyTypeIn1And2","1");
page.setPd(pd);
List<PageData> varList = specialuserService.listByOperation(page); //列出SpecialUser列表
2024-02-06 11:02:25 +08:00
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
@RequiresPermissions("specialuser:edit")
@ResponseBody
public Object goEdit() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd = specialuserService.findById(pd); //根据ID读取
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@RequiresPermissions("specialuser:del")
@ResponseBody
@DockAnnotation
public Object deleteAll() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
PageData dockData = new PageData();
PageData blindPageData = new PageData(); // pd对接数据
blindPageData.putAll(pd);
dockData.put("dockData", JSON.toJSONString(blindPageData));
String DATA_IDS = pd.getString("DATA_IDS");
if(Tools.notEmpty(DATA_IDS)){
String ArrayDATA_IDS[] = DATA_IDS.split(",");
specialuserService.deleteAll(ArrayDATA_IDS);
errInfo = "success";
}else{
errInfo = "fail";
}
map.put("dockData", JSON.toJSONString(dockData));
map.put("result", errInfo); //返回结果
return map;
}
/**excel
* @param
* @throws Exception
*/
@RequestMapping(value="/excel")
// @RequiresPermissions("toExcel")
public ModelAndView exportExcel() throws Exception{
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("姓名"); //1
titles.add("性别"); //2
titles.add("手机号"); //3
titles.add("身份证号"); //4
titles.add("作业类别"); //5
titles.add("操作项目"); //6
titles.add("发证机关"); //7
titles.add("有效期"); //8
titles.add("复审时间"); //9
titles.add("用户id"); //10
titles.add("人员类型"); //11
titles.add("CREATOR"); //12
titles.add("CREATTIME"); //13
titles.add("OPERATOR"); //14
titles.add("OPERATTIME"); //15
titles.add("SPARE1"); //16
titles.add("SPARE2"); //17
titles.add("SPARE3"); //18
titles.add("SPARE4"); //19
titles.add("SPARE5"); //20
dataMap.put("titles", titles);
List<PageData> varOList = specialuserService.listAll(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<varOList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", varOList.get(i).getString("USERNAME")); //1
vpd.put("var2", varOList.get(i).getString("SEX")); //2
vpd.put("var3", varOList.get(i).getString("PHONE")); //3
vpd.put("var4", varOList.get(i).getString("USER_ID_CARD")); //4
vpd.put("var5", varOList.get(i).getString("SPECIAL_TYPE")); //5
vpd.put("var6", varOList.get(i).getString("OPERATION_TYPE")); //6
vpd.put("var7", varOList.get(i).getString("ISSUING_AUTHORITY")); //7
vpd.put("var8", varOList.get(i).getString("VALIDITY_TIME")); //8
vpd.put("var9", varOList.get(i).getString("REVIEW_TIME")); //9
vpd.put("var10", varOList.get(i).getString("USER_ID")); //10
vpd.put("var11", varOList.get(i).get("USER_TYPE").toString()); //11
vpd.put("var12", varOList.get(i).getString("CREATOR")); //12
vpd.put("var13", varOList.get(i).getString("CREATTIME")); //13
vpd.put("var14", varOList.get(i).getString("OPERATOR")); //14
vpd.put("var15", varOList.get(i).getString("OPERATTIME")); //15
vpd.put("var16", varOList.get(i).getString("SPARE1")); //16
vpd.put("var17", varOList.get(i).getString("SPARE2")); //17
vpd.put("var18", varOList.get(i).getString("SPARE3")); //18
vpd.put("var19", varOList.get(i).getString("SPARE4")); //19
vpd.put("var20", varOList.get(i).getString("SPARE5")); //20
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView();
mv = new ModelAndView(erv,dataMap);
return mv;
}
/**
* @return
*/
@RequestMapping(value="/hasState")
@ResponseBody
public Object hasState() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
// 1 身份证 2 特种行业编码
String type = pd.getString("type");
if("1".equals(type)){ // 1.1.相关方单位名称。2统一社会信用代码
pd.put("USER_ID_CARD",pd.getString("typeName"));
}else if("2".equals(type)){
pd.put("SPECIAL_NUMBER",pd.getString("typeName"));
}
Integer count = specialuserService.hasState(pd);
if(count != 0){
map.put("pd",pd);
errInfo = "success";
}
map.put("result", errInfo); //返回结果
return map;
}
}