forked from integrated_whb/integrated_whb
213 lines
9.7 KiB
Java
213 lines
9.7 KiB
Java
package com.zcloud.controller.comprehensive;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
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.comprehensive.TrafficSecurityCustomerManagementService;
|
|
import com.zcloud.service.comprehensive.TrafficSecurityNoticeService;
|
|
import com.zcloud.util.Const;
|
|
import com.zcloud.util.DateUtil;
|
|
import com.zcloud.util.Jurisdiction;
|
|
import com.zcloud.util.Tools;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.shiro.util.CollectionUtils;
|
|
import org.apache.tomcat.util.json.JSONParser;
|
|
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.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Controller
|
|
@RequestMapping("/securitycustomer")
|
|
public class TrafficSecurityCustomerManagementController extends BaseController {
|
|
@Autowired
|
|
private TrafficSecurityCustomerManagementService customerManagementService;
|
|
|
|
|
|
//新增
|
|
@RequestMapping(value = "/add")
|
|
@ResponseBody
|
|
public Object add() throws Exception {
|
|
Map<String, Object> map = new HashMap<>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData(); // 获取页面提交的数据
|
|
|
|
String customermanagement_id = this.get32UUID(); // 生成主键ID
|
|
pd.put("CUSTOMERMANAGEMENT_ID", customermanagement_id); // 设置客户管理ID
|
|
pd.put("CUSTOMERNAME_ID", this.get32UUID());
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); // 设置运输公司ID
|
|
pd.put("CREATOR", Jurisdiction.getUSER_ID()); // 设置创建人ID
|
|
pd.put("CREATORNAME", Jurisdiction.getName()); // 设置创建人姓名
|
|
pd.put("CREATETIME", DateUtil.date2Str(new Date())); // 设置创建时间
|
|
pd.put("ISDELETE", "0"); // 设置删除标志
|
|
|
|
customerManagementService.save(pd);
|
|
|
|
if (pd.getString("contacts") != null && !pd.getString("contacts").isEmpty()) {
|
|
List<PageData> contacts = JSON.parseArray(pd.getString("contacts"), PageData.class);
|
|
for (PageData contact : contacts) {
|
|
PageData contactPd = new PageData();
|
|
contactPd.put("CUSTOMERCONTACT_ID", this.get32UUID());
|
|
contactPd.put("CONTACT_ID", this.get32UUID());
|
|
contactPd.put("CUSTOMERADDRESS_ID", this.get32UUID());
|
|
contactPd.put("CUSTOMERMANAGEMENT_ID", customermanagement_id);
|
|
contactPd.put("CREATOR", Jurisdiction.getUSER_ID()); // 设置创建人ID
|
|
contactPd.put("CREATORNAME", Jurisdiction.getName()); // 设置创建人姓名
|
|
contactPd.put("CREATETIME", DateUtil.date2Str(new Date())); // 设置创建时间
|
|
contactPd.put("CONTACT", contact.get("CONTACT"));
|
|
contactPd.put("CONTACTPHONE", contact.get("CONTACTPHONE"));
|
|
contactPd.put("CUSTOMERADDRESS", contact.get("CUSTOMERADDRESS"));
|
|
contactPd.put("ISDELETE", "0"); // 设置删除标志
|
|
|
|
customerManagementService.saveContact(contactPd);
|
|
}
|
|
}
|
|
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
|
|
@RequestMapping(value = "/listForSecurityCustomerManagement")
|
|
@ResponseBody
|
|
public Object listForSecurityCustomerManagement(Page page) throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = new PageData();
|
|
pd = this.getPageData();
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID
|
|
page.setPd(pd);
|
|
List<PageData> varList = customerManagementService.listForSecurityCustomerManagement(page);
|
|
|
|
map.put("varList", varList);
|
|
map.put("page", page);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*
|
|
* @return
|
|
* @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("DELETOR", Jurisdiction.getUSER_ID());//删除人id
|
|
pd.put("DELETORNAME", Jurisdiction.getUsername());//删除人姓名
|
|
pd.put("DELETETIME", DateUtil.date2Str(new Date()));//删除时间
|
|
customerManagementService.delete(pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
@RequestMapping(value = "/getTrafficCustomerSelectList")
|
|
@ResponseBody
|
|
public Object getTrafficCustomerSelectList() throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = new PageData();
|
|
pd = this.getPageData();
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID
|
|
List<PageData> varList = customerManagementService.getTrafficCustomerSelectList(pd);
|
|
map.put("varList", varList);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/getTrafficCustomerSelectView")
|
|
@ResponseBody
|
|
public Object getTrafficCustomerSelectView() throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = new PageData();
|
|
pd = this.getPageData();
|
|
pd = customerManagementService.getTrafficCustomerSelectView(pd); //根据ID读取客户管理信息
|
|
PageData pageData = new PageData();
|
|
pageData.put("CUSTOMERMANAGEMENT_ID", pd.getString("CUSTOMERMANAGEMENT_ID"));
|
|
List<PageData> customercontactList = customerManagementService.findByCustomerManagementId(pageData);
|
|
pd.put("customercontactList", customercontactList);
|
|
map.put("pd", pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
@RequestMapping(value = "/edit")
|
|
@ResponseBody
|
|
public Object edit() throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
|
|
pd.put("OPERATOR", Jurisdiction.getUSER_ID()); // 修改人id
|
|
pd.put("OPERATORNAME", Jurisdiction.getName()); // 修改人姓名
|
|
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间
|
|
// 修改 客户管理表
|
|
customerManagementService.edit(pd);
|
|
if (pd.getString("contacts") != null && !pd.getString("contacts").isEmpty()) {
|
|
List<PageData> contacts = JSONArray.parseArray(pd.getString("contacts"), PageData.class);
|
|
for (PageData contact : contacts) {
|
|
PageData contactInfo = customerManagementService.findByContactId(contact.getString("CUSTOMERCONTACT_ID"));
|
|
if (ObjectUtil.isEmpty(contactInfo)) {
|
|
PageData pageData = new PageData();
|
|
pageData.put("CUSTOMERADDRESS_ID", this.get32UUID());
|
|
pageData.put("ISDELETE", "0");
|
|
pageData.put("CUSTOMERCONTACT_ID", this.get32UUID());
|
|
pageData.put("CREATOR", Jurisdiction.getUSER_ID());
|
|
pageData.put("CREATORNAME", Jurisdiction.getUsername());
|
|
pageData.put("CUSTOMERMANAGEMENT_ID", pd.getString("CUSTOMERMANAGEMENT_ID"));
|
|
pageData.put("CONTACT_ID", this.get32UUID());
|
|
pageData.put("CREATETIME", DateUtil.date2Str(new Date()));
|
|
pageData.put("CONTACT", contact.getString("CONTACT"));
|
|
pageData.put("CUSTOMERADDRESS", contact.getString("CUSTOMERADDRESS"));
|
|
pageData.put("CONTACTPHONE", contact.getString("CONTACTPHONE"));
|
|
customerManagementService.saveContact(pageData);
|
|
} else {
|
|
if (!StringUtils.equals(contact.getString("CONTACT"), contactInfo.getString("CONTACT"))
|
|
|| !StringUtils.equals(contact.getString("CONTACTPHONE"), contactInfo.getString("CONTACTPHONE"))
|
|
|| !StringUtils.equals(contact.getString("CUSTOMERADDRESS"), contactInfo.getString("CUSTOMERADDRESS"))) {
|
|
contact.put("OPERATOR", Jurisdiction.getUSER_ID()); // 修改人id
|
|
contact.put("OPERATORNAME", Jurisdiction.getName()); // 修改人姓名
|
|
contact.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间
|
|
customerManagementService.editContactInfo(contact);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
|
|
@RequestMapping(value = "/deleteContactInfo")
|
|
@ResponseBody
|
|
public Object deleteContactInfo() throws Exception {
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
String errInfo = "success";
|
|
PageData pd = new PageData();
|
|
pd = this.getPageData();
|
|
pd.put("DELETOR", Jurisdiction.getUSER_ID());//删除人id
|
|
pd.put("DELETORNAME", Jurisdiction.getUsername());//删除人姓名
|
|
pd.put("DELETETIME", DateUtil.date2Str(new Date()));//删除时间
|
|
customerManagementService.deleteContactById(pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
}
|