343 lines
12 KiB
Java
343 lines
12 KiB
Java
package com.zcloud.controller.bus;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.zcloud.controller.base.BaseController;
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.service.bus.BlackListService;
|
||
import com.zcloud.service.bus.ForeignCarService;
|
||
import com.zcloud.service.bus.OutsidersDetailsService;
|
||
import com.zcloud.service.bus.OutsidersService;
|
||
import com.zcloud.service.system.DepartmentService;
|
||
import com.zcloud.service.system.UserExamineService;
|
||
import com.zcloud.util.DateUtil;
|
||
import com.zcloud.util.Jurisdiction;
|
||
import com.zcloud.util.Tools;
|
||
import net.sf.json.JSONArray;
|
||
import org.apache.commons.lang.StringUtils;
|
||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||
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 java.util.*;
|
||
|
||
/**
|
||
* 说明:外来人员管理
|
||
* 作者:yangming
|
||
* 时间:2022-04-09
|
||
* 官网:www.zcloudchina.com
|
||
*/
|
||
@Controller
|
||
@RequestMapping("/outsiders")
|
||
public class OutsidersController extends BaseController {
|
||
|
||
@Autowired
|
||
private OutsidersService outsidersService;
|
||
@Autowired
|
||
private DepartmentService departmentService;
|
||
@Autowired
|
||
private OutsidersDetailsService outsidersDetailsService;
|
||
@Autowired
|
||
private BlackListService blackListService;
|
||
@Autowired
|
||
private UserExamineService userExamineService;
|
||
|
||
/**新增
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/add")
|
||
@ResponseBody
|
||
public Object add() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
String ID = this.get32UUID();
|
||
String involvingCorps = pd.getString("INVOLVING_CORPS");
|
||
// 把自己添加到辖区单位
|
||
if (!pd.getString("INVOLVING_CORPS").contains(Jurisdiction.getCORPINFO_ID())) {
|
||
involvingCorps = Jurisdiction.getCORPINFO_ID()+","+involvingCorps;
|
||
}
|
||
pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
|
||
List<PageData> pageData = blackListService.findByPhonoNumber(pd);//判断是否黑名单中有此手机号
|
||
String DEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
|
||
pd.put("DEPARTMENT_ID",DEPARTMENT_ID);
|
||
if(pageData.size() > 0){
|
||
errInfo = "fail";
|
||
map.put("msg", "手机号【"+pd.getString("PHONO_NUMBER")+"】在黑名单中");
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}else {
|
||
if (pd.get("OTHER") != null && !pd.get("OTHER").equals("")) {
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("OTHER").toString());
|
||
for (JSONObject json : list) {
|
||
if (json.get("NAME") != null && json.get("NAME") != "" && json.get("PHONO_NUMBER") != null
|
||
&& json.get("PHONO_NUMBER") != "") {
|
||
PageData other = new PageData();
|
||
other.put("OUTSIDERS_DETAILS_ID",this.get32UUID());
|
||
other.put("OUTSIDERS_ID", ID); // 主键
|
||
other.put("NAME", json.get("NAME"));
|
||
other.put("PHONO_NUMBER", json.get("PHONO_NUMBER"));
|
||
PageData phono = new PageData();
|
||
phono.put("PHONO_NUMBER",json.get("PHONO_NUMBER"));
|
||
phono.put("CORPINFO_ID",pd.getString("CORPINFO_ID"));
|
||
List<PageData> pageData1 = blackListService.findByPhonoNumber(phono);
|
||
if(pageData1.size() > 0){
|
||
errInfo = "fail";
|
||
map.put("msg", "手机号【"+json.get("PHONO_NUMBER")+"】在黑名单中");
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}else{
|
||
outsidersDetailsService.save(other);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(pd.getString("NAME")!=null && pd.getString("NAME")!= "" && pd.getString("PHONO_NUMBER") !=null
|
||
&& pd.getString("PHONO_NUMBER")!= ""){
|
||
PageData other = new PageData();
|
||
other.put("OUTSIDERS_DETAILS_ID",this.get32UUID());
|
||
other.put("OUTSIDERS_ID", ID); // 主键
|
||
other.put("NAME", pd.getString("NAME"));
|
||
other.put("PHONO_NUMBER", pd.getString("PHONO_NUMBER"));
|
||
List<PageData> pageData2 = blackListService.findByPhonoNumber(pd);//判断是否黑名单中有此手机号
|
||
if(pageData2.size() > 0){
|
||
errInfo = "fail";
|
||
map.put("exception", "手机号【"+pd.getString("PHONO_NUMBER")+"】在黑名单中");
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}else{
|
||
outsidersDetailsService.save(other);
|
||
}
|
||
}
|
||
pd.put("DEPARTMENT_ID",Jurisdiction.getDEPARTMENT_ID());
|
||
pd.put("OUTSIDERS_ID", ID); //主键
|
||
// pd.put("STATE","1");
|
||
String start = pd.getString("APPLICATION_TIME[0]");
|
||
String end = pd.getString("APPLICATION_TIME[1]");
|
||
pd.put("APPLICATION_TIME",start+","+end);
|
||
pd.put("APPLY_SOURCE","PC端");
|
||
pd.put("APPLYTIME",DateUtil.date2Str(new Date()));
|
||
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"); //是否删除 1-是 0-否
|
||
pd.put("INVOLVING_CORPS",involvingCorps);
|
||
outsidersService.save(pd);
|
||
map.put("result", errInfo);
|
||
}
|
||
|
||
return map;
|
||
}
|
||
|
||
/**扫描登记新增外来人员申请
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/scanadd")
|
||
@ResponseBody
|
||
public Object scanadd() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
String ID = this.get32UUID();
|
||
if (pd.get("OTHER") != null && !pd.get("OTHER").equals("")) {
|
||
List<JSONObject> list = (List<JSONObject>) JSON.parse(pd.get("OTHER").toString());
|
||
for (JSONObject json : list) {
|
||
if (json.get("NAME") != null && json.get("NAME") != "" && json.get("PHONO_NUMBER") != null
|
||
&& json.get("PHONO_NUMBER") != "") {
|
||
PageData other = new PageData();
|
||
other.put("OUTSIDERS_DETAILS_ID",this.get32UUID());
|
||
other.put("OUTSIDERS_ID", ID); // 主键
|
||
other.put("NAME", json.get("NAME"));
|
||
other.put("PHONO_NUMBER", json.get("PHONO_NUMBER"));
|
||
outsidersDetailsService.save(other);
|
||
}
|
||
}
|
||
}
|
||
if(pd.getString("NAME")!=null && pd.getString("NAME")!= "" && pd.getString("PHONO_NUMBER") !=null
|
||
&& pd.getString("PHONO_NUMBER")!= ""){
|
||
PageData other = new PageData();
|
||
other.put("OUTSIDERS_DETAILS_ID",this.get32UUID());
|
||
other.put("OUTSIDERS_ID", ID); // 主键
|
||
other.put("NAME", pd.getString("NAME"));
|
||
other.put("PHONO_NUMBER", pd.getString("PHONO_NUMBER"));
|
||
outsidersDetailsService.save(other);
|
||
}
|
||
pd.put("STARTTIME",pd.getString("STARTTIME").trim());
|
||
pd.put("ENDTIME",pd.getString("ENDTIME").trim());
|
||
pd.put("STATE",'1');//提交后默认待审核状态
|
||
pd.put("DEPARTMENT_ID",pd.getString("DEPARTMENT_ID"));
|
||
pd.put("OUTSIDERS_ID", ID); //主键
|
||
pd.put("APPLY_SOURCE","扫码申请");
|
||
pd.put("APPLYTIME", DateUtil.date2Str(new Date()));
|
||
//pd.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||
//pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||
pd.put("ISDELETE", "0"); //是否删除 1-是 0-否
|
||
outsidersService.save(pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**去修改页面获取数据
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/goAdd")
|
||
@ResponseBody
|
||
public Object goAdd() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
// //获取部门下拉树
|
||
// List<PageData> zdepartmentPdList = new ArrayList<PageData>();
|
||
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
|
||
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
|
||
// PageData dept = new PageData();
|
||
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
|
||
// dept=this.departmentService.findById(dept);
|
||
|
||
//获取部门下拉树
|
||
List<PageData> zdepartmentPdList = new ArrayList<PageData>();
|
||
PageData dept = new PageData();
|
||
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
dept=this.departmentService.findByCorpId(dept);
|
||
String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID");
|
||
|
||
PageData node = new PageData();
|
||
node.put("id", dept.get("DEPARTMENT_ID"));
|
||
node.put("parentId", dept.get("PARENT_ID"));
|
||
node.put("name", dept.get("NAME"));
|
||
node.put("icon", "../../../assets/images/user.gif");
|
||
zdepartmentPdList.add(node);
|
||
JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList));
|
||
map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}"));
|
||
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**删除
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/delete")
|
||
@ResponseBody
|
||
public Object delete() throws Exception{
|
||
Map<String,String> map = new HashMap<String,String>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间getForeignCarById
|
||
outsidersService.delete(pd);
|
||
map.put("result", errInfo); //返回结果
|
||
return map;
|
||
}
|
||
|
||
/**修改
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/edit")
|
||
@ResponseBody
|
||
public Object edit() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
if(pd.getString("STATE").equals("6")){
|
||
pd.put("STATE","1");
|
||
}
|
||
String start = pd.getString("APPLICATION_TIME[0]");
|
||
String end = pd.getString("APPLICATION_TIME[1]");
|
||
pd.put("APPLICATION_TIME",start+","+end);
|
||
pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||
pd.put("APPLYTIME",DateUtil.date2Str(new Date()));
|
||
outsidersService.edit(pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**列表
|
||
* @param page
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/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();
|
||
if (!Jurisdiction.getDEPARTMENT_ID().equals(Jurisdiction.getCORPINFO_ID())) {
|
||
pd.put("CREATOR",Jurisdiction.getUSER_ID());
|
||
}
|
||
pd.put("DEPARTMENT_ID",Jurisdiction.getDEPARTMENT_ID());
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
page.setPd(pd);
|
||
List<PageData> varList = outsidersService.list(page); //列出RiskUnit列表
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**去修改页面获取数据
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/goEdit")
|
||
@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 = outsidersService.findById(pd); //根据ID读取
|
||
map.put("pd", pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**批量删除
|
||
* @param
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping(value="/deleteAll")
|
||
@ResponseBody
|
||
public Object deleteAll() throws Exception{
|
||
Map<String,Object> map = new HashMap<String,Object>();
|
||
String errInfo = "success";
|
||
String err="";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
String DATA_IDS = pd.getString("DATA_IDS");
|
||
if(Tools.notEmpty(DATA_IDS)){
|
||
String ArrayDATA_IDS[] = DATA_IDS.split(",");
|
||
for (String id : ArrayDATA_IDS) {
|
||
PageData unit = new PageData();
|
||
unit.put("RISKUNIT_ID", id);
|
||
pd.put("RISKUNIT_ID", id);
|
||
pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||
outsidersService.delete(pd);
|
||
}
|
||
// riskunitService.deleteAll(ArrayDATA_IDS);
|
||
errInfo = "success";
|
||
}else{
|
||
errInfo = "fail";
|
||
}
|
||
map.put("result", errInfo); //返回结果
|
||
return map;
|
||
}
|
||
}
|