forked from integrated_whb/integrated_whb
247 lines
8.9 KiB
Java
247 lines
8.9 KiB
Java
package com.zcloud.controller.comprehensive;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.zcloud.controller.base.BaseController;
|
|
import com.zcloud.entity.Page;
|
|
import com.zcloud.entity.PageData;
|
|
import com.zcloud.service.comprehensive.TrafficDrivingCommitmentService;
|
|
import com.zcloud.service.comprehensive.TrafficDrivingTypeService;
|
|
import com.zcloud.service.comprehensive.TrafficSecurityCustomerManagementService;
|
|
import com.zcloud.service.comprehensive.TrafficSecurityWaybillRegistrationService;
|
|
import com.zcloud.service.system.UsersService;
|
|
import com.zcloud.util.*;
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
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.multipart.MultipartFile;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Controller
|
|
@RequestMapping("/waybillregistration")
|
|
public class TrafficSecurityWaybillRegistrationController extends BaseController {
|
|
|
|
@Autowired
|
|
private TrafficSecurityWaybillRegistrationService trafficSecurityWaybillRegistrationService;
|
|
@Autowired
|
|
private TrafficDrivingCommitmentService trafficDrivingCommitmentService;
|
|
@Autowired
|
|
private TrafficDrivingTypeService trafficDrivingTypeService;
|
|
|
|
@Autowired
|
|
private TrafficSecurityCustomerManagementService trafficSecurityCustomerManagementService;
|
|
|
|
|
|
@Autowired
|
|
private UsersService usersService;
|
|
|
|
@RequestMapping(value = "/listForSecurityWaybillre")
|
|
@ResponseBody
|
|
public Object listForSecurityWaybillRegistra(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 = trafficSecurityWaybillRegistrationService.listForSecurityWaybill(page);
|
|
map.put("varList", varList);
|
|
map.put("page", page);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* 查看详情
|
|
*
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "/getDetail")
|
|
@ResponseBody
|
|
public Object goEdit() throws Exception {
|
|
Map<String, Object> map = new HashMap<>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|
List<PageData> commitmentList = trafficDrivingCommitmentService.getDrivingCommitment(pd);
|
|
try {
|
|
pd = trafficDrivingTypeService.infoCategory(pd); //根据ID读取
|
|
// if(pd.getString("OPERATOR"))
|
|
// pd.put("a", "119.60436762");
|
|
// pd.put("b", "39.94546157");
|
|
errInfo = "success";
|
|
map.put("pd", pd);
|
|
map.put("result", errInfo);
|
|
map.put("msg", "数据获取成功");
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
map.put("result", errInfo);
|
|
map.put("msg", "数据获取失败");
|
|
}
|
|
map.put("commitmentList", commitmentList);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
|
|
//新增
|
|
@RequestMapping(value = "/add")
|
|
@ResponseBody
|
|
public Object add() throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
String waybillregistrationId = this.get32UUID();
|
|
|
|
pd.put("CREATOR", Jurisdiction.getUSER_ID()); // 创建人id
|
|
pd.put("CREATORNAME", Jurisdiction.getName()); // 创建人姓名
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); // 运输企业
|
|
pd.put("WAYBILLREGISTRATION_ID", waybillregistrationId); // 主键
|
|
pd.put("CREATETIME", DateUtil.date2Str(new Date())); // 添加时间
|
|
pd.put("ISDELETE", "0");
|
|
|
|
Date shippingDate = DateUtil.fomatDate(pd.getString("SHIPPINGDATE"));
|
|
if (shippingDate != null && shippingDate.after(new Date())) {
|
|
pd.put("WAYBILLSTATUS", "1");
|
|
} else {
|
|
pd.put("WAYBILLSTATUS", "0");
|
|
}
|
|
|
|
trafficSecurityWaybillRegistrationService.save(pd);
|
|
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
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.getName());//删除人姓名
|
|
pd.put("DELETETIME", DateUtil.date2Str(new Date()));//删除时间
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|
trafficSecurityWaybillRegistrationService.delete(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) {
|
|
pd.put("WAYBILLREGISTRATION_ID", id);
|
|
pd.put("DELETORNAME", Jurisdiction.getName());//删除人
|
|
pd.put("DELETETIME", DateUtil.date2Str(new Date()));//删除时间
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|
trafficSecurityWaybillRegistrationService.delete(pd);
|
|
}
|
|
errInfo = "success";
|
|
} else {
|
|
errInfo = "error";
|
|
}
|
|
map.put("result", errInfo);//返回结果
|
|
return map;
|
|
}
|
|
|
|
|
|
//详情
|
|
@RequestMapping(value = "/goEdit")
|
|
@ResponseBody
|
|
public Object getSecurityWaybillRegistrationInfo() 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());
|
|
pd = trafficSecurityWaybillRegistrationService.findById(pd);//根据ID读=
|
|
pd.put("ENTRUST_PERSON", pd.getString("CLIENTCONTACTPERSON"));
|
|
pd.put("CONFIRM_PERSON", pd.getString("CONFIRMINGPERSON"));
|
|
List<String> dispatchers = Arrays.stream(pd.getString("DISPATCHER").split(",")).collect(Collectors.toList());
|
|
List<PageData> names = new ArrayList<>();
|
|
dispatchers.forEach(data -> {
|
|
PageData user = new PageData();
|
|
user.put("USER_ID", data.trim());
|
|
PageData userInfo = null;
|
|
try {
|
|
userInfo = usersService.findById(user);
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
names.add(userInfo);
|
|
});
|
|
List<PageData> deptList = usersService.listUserbyDep(pd);
|
|
pd.put("deptList", deptList);
|
|
pd.put("names", names);
|
|
map.put("pd", pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/getPrincipalContactList")
|
|
@ResponseBody
|
|
public Object getPrincipalContactList() 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());
|
|
List<PageData> principalContactList = trafficSecurityCustomerManagementService.getPrincipalContactList(pd);
|
|
map.put("pd", principalContactList);
|
|
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())); // 修改时间
|
|
trafficSecurityWaybillRegistrationService.edit(pd);
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|