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

375 lines
13 KiB
Java
Raw Normal View History

2024-02-06 11:02:25 +08:00
package com.zcloud.controller.bus;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zcloud.service.bus.CorpInfoService;
import com.zcloud.service.bus.SpecialUserService;
import com.zcloud.util.Jurisdiction;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
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.RelevantUnitService;
/**
*
* luoxiaobao
* 2022-04-20
* www.zcloudchina.com
*/
@Controller
@RequestMapping("/relevantunit")
public class RelevantUnitController extends BaseController {
@Autowired
private RelevantUnitService relevantunitService;
@Autowired
private SpecialUserService specialuserService;
@Autowired
private CorpInfoService corpinfoService;
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/add")
@RequiresPermissions("relevantunit: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();
pd.put("RELEVANTUNIT_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");
relevantunitService.save(pd);
map.put("result", errInfo);
map.put("msg", "新增成功!");
return map;
}
/**
* @param out
* @throws Exception
*/
@RequestMapping(value="/delete")
@RequiresPermissions("relevantunit:del")
@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.getUSER_ID());
pd.put("OPERATTIME",DateUtil.date2Str(new Date()));
relevantunitService.delete(pd);
map.put("msg", "删除成功!");
map.put("result", errInfo); //返回结果
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
@RequiresPermissions("relevantunit: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();
pd.put("OPERATOR",Jurisdiction.getUSER_ID());
pd.put("OPERATTIME",DateUtil.date2Str(new Date()));
relevantunitService.edit(pd);
map.put("msg", "修改成功!");
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
@RequiresPermissions("relevantunit: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());
page.setPd(pd);
List<PageData> varList = relevantunitService.list(page); //列出RelevantUnit列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/goEdit")
@RequiresPermissions("relevantunit: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 = relevantunitService.findById(pd); //根据ID读取
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/deleteAll")
@RequiresPermissions("relevantunit:del")
@ResponseBody
public Object deleteAll() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
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(",");
relevantunitService.deleteAll(ArrayDATA_IDS);
errInfo = "success";
}else{
errInfo = "fail";
}
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("relevant_name"); //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("创建时间"); //10
titles.add("修改人"); //11
titles.add("修改时间"); //12
titles.add("spare1"); //13
titles.add("spare2"); //14
titles.add("spare3"); //15
titles.add("spare4"); //16
titles.add("spare5"); //17
dataMap.put("titles", titles);
List<PageData> varOList = relevantunitService.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("相关方单位名称")); //1
vpd.put("var2", varOList.get(i).getString("RELEVANT_CODE")); //2
vpd.put("var3", varOList.get(i).getString("PROVINCE")); //3
vpd.put("var4", varOList.get(i).getString("CITY")); //4
vpd.put("var5", varOList.get(i).getString("COUNTRY")); //5
vpd.put("var6", varOList.get(i).getString("VILLAGE")); //6
vpd.put("var7", varOList.get(i).getString(" PRINCIPAL_USER")); //7
vpd.put("var8", varOList.get(i).getString("PRINCIPAL_NUMBER")); //8
vpd.put("var9", varOList.get(i).getString("CREATOR")); //9
vpd.put("var10", varOList.get(i).getString("CREATTIME")); //10
vpd.put("var11", varOList.get(i).getString("OPERATOR")); //11
vpd.put("var12", varOList.get(i).getString("OPERATTIME")); //12
vpd.put("var13", varOList.get(i).getString("SPARE1")); //13
vpd.put("var14", varOList.get(i).getString("SPARE2")); //14
vpd.put("var15", varOList.get(i).getString("SPARE3")); //15
vpd.put("var16", varOList.get(i).getString("SPARE4")); //16
vpd.put("var17", varOList.get(i).getString("SPARE5")); //17
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();
String type = pd.getString("type");
if("1".equals(type)){ // 1.1.相关方单位名称。2统一社会信用代码
pd.put("RELEVANT_NAME",pd.getString("typeName"));
}else if("2".equals(type)){
pd.put("RELEVANT_CODE",pd.getString("typeName"));
}
Integer count = relevantunitService.hasState(pd);
if(count != 0){
map.put("pd",pd);
errInfo = "success";
}
map.put("result", errInfo); //返回结果
return map;
}
/**
* @throws Exception
*/
@RequestMapping(value="/listAllTree")
@ResponseBody
@Transactional
public Object listAllTree() 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());
List<PageData> unitAllList = relevantunitService.listNameAll(pd); //列出RelevantUnit列表
PageData corp = new PageData();
corp.put("RELEVANTUNIT_ID",Jurisdiction.getCORPINFO_ID());
corp.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
PageData corpName = corpinfoService.findById(corp);
corp.put("RELEVANT_NAME", corpName.getString("CORP_NAME"));
unitAllList.add(corp);
String endday = DateUtil.getDay();
PageData getPD = new PageData();
getPD.put("endday",endday);
List<PageData> userAllList = specialuserService.listAll(getPD);
if(!Tools.isEmpty(pd.get("CORPINFO_ID"))){
PageData corpinfo = new PageData();
corpinfo.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
corpinfo =corpinfoService.findById(corpinfo);
PageData addPd = new PageData();
addPd.put("RELEVANT_NAME",corpinfo.getString("CORP_NAME"));
addPd.put("RELEVANTUNIT_ID",corpinfo.getString("CORPINFO_ID"));
unitAllList.add(addPd);
}
Map<String,List> userMap = new HashMap<>();
for (PageData pageData:userAllList){
PageData chiMap = new PageData();
chiMap.put("id",pageData.getString("SPECIALUSER_ID"));
chiMap.put("pid",pageData.getString("UNIT_ID"));
chiMap.put("name",pageData.getString("USERNAME"));
chiMap.put("number",pageData.getString("SPECIAL_NUMBER"));
String key =pageData.getString("UNIT_ID");
List<PageData> mapValList = new ArrayList<>();
if(userMap.containsKey(key)){
mapValList = userMap.get(key);
}
mapValList.add(chiMap);
userMap.put(key,mapValList);
}
List<Map<String,Object>> valList = new ArrayList<>();
for (PageData pageData :unitAllList){
Map<String,Object> valMap = new HashMap<>();
String key = pageData.getString("RELEVANTUNIT_ID");
valMap.put("id",key);
valMap.put("pid","0");
valMap.put("name",pageData.getString("RELEVANT_NAME"));
valMap.put("children",new ArrayList<>());
if (userMap.containsKey(key)){
valMap.put("children",userMap.get(key));
}
valList.add(valMap);
}
JSONArray arr = JSONArray.fromObject(valList);
String json = arr.toString();
map.put("varList", json);
map.put("result", errInfo);
return map;
}
/**
* @throws Exception
*/
@RequestMapping(value="/listAllForHotWork")
@ResponseBody
@Transactional
public Object listAllForHotWork() 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());
List<PageData> unitAllList = relevantunitService.listNameAll(pd); //列出RelevantUnit列表
PageData corp = new PageData();
corp.put("RELEVANTUNIT_ID",Jurisdiction.getCORPINFO_ID());
corp.put("id",Jurisdiction.getCORPINFO_ID());
corp.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
PageData corpName = corpinfoService.findById(corp);
corp.put("RELEVANT_NAME", corpName.getString("CORP_NAME"));
corp.put("label", corpName.getString("CORP_NAME"));
corp.put("nodeLevel", "0");
unitAllList.add(corp);
String endday = DateUtil.getDay();
PageData getPD = new PageData();
getPD.put("endday",endday);
getPD.put("KEYWORDS",pd.getString("KEYWORDS"));
getPD.put("DEPT_IDS",pd.getString("DEPT_IDS"));
List<PageData> userAllList = specialuserService.listAll(getPD);
if(!Tools.isEmpty(pd.get("CORPINFO_ID"))){
PageData corpinfo = new PageData();
corpinfo.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
corpinfo =corpinfoService.findById(corpinfo);
PageData addPd = new PageData();
if (!corpinfo.getString("CORP_NAME").equals("唐山曹妃甸煤炭港务有限公司")) {
addPd.put("RELEVANT_NAME",corpinfo.getString("CORP_NAME"));
addPd.put("label",corpinfo.getString("CORP_NAME"));
addPd.put("nodeLevel","0");
addPd.put("RELEVANTUNIT_ID",corpinfo.getString("CORPINFO_ID"));
addPd.put("id",corpinfo.getString("CORPINFO_ID"));
unitAllList.add(addPd);
}
}
map.put("varList", userAllList);
map.put("deptList", unitAllList);
map.put("result", errInfo);
return map;
}
2024-02-06 11:02:25 +08:00
}