Commit a5426261 authored by zhangzc's avatar zhangzc

添加评价功能

parent 839b6888
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.feign.DriverComplaintInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/29 17:30
* @version:1.0
*/
@FeignClient(value = "freight-tms-service")
public interface DriverComplaintInterface {
/**
* 分页查询
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/complaint/driver/list")
JSONObject list(JSONObject bodyJson);
/**
* 详情查询
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/complaint/driver/detail")
JSONObject detail(JSONObject bodyJson);
/**
* 新增投诉
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/complaint/driver/add")
JSONObject add(JSONObject bodyJson);
/**
* 编辑投诉
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/complaint/driver/edit")
JSONObject edit(JSONObject bodyJson);
/**
* 取消投诉
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/complaint/driver/cancel")
JSONObject cancel(JSONObject bodyJson);
}
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.feign.DriverEvaluateInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:15
* @version:1.0
*/
@FeignClient(value = "freight-tms-service")
public interface DriverEvaluateInterface {
/**
* 分页查询
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/driver/list")
JSONObject list(JSONObject bodyJson);
/**
* 评价详情
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/driver/detail")
JSONObject detail(JSONObject bodyJson);
/**
* 新增评价
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/driver/add")
JSONObject add(JSONObject bodyJson);
}
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.feign.OwnerEvaluateInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:15
* @version:1.0
*/
@FeignClient(value = "freight-tms-service")
public interface OwnerEvaluateInterface {
/**
* 分页查询
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/owner/list")
JSONObject list(JSONObject bodyJson);
/**
* 评价详情
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/owner/detail")
JSONObject detail(JSONObject bodyJson);
/**
* 新增评价
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/appraise/owner/add")
JSONObject add(JSONObject bodyJson);
}
package com.esv.freight.app.module.complaint.controller; package com.esv.freight.app.module.complaint.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.feign.DriverComplaintInterface;
import com.esv.freight.app.module.complaint.form.DriverComplaintForm;
import com.esv.freight.app.module.complaint.form.OwnerComplaintForm;
import com.esv.freight.app.module.complaint.pojo.OwnerComplaintAdvicePojo;
import com.esv.freight.app.module.complaint.vo.ComplaintDetailVO;
import com.esv.freight.app.module.complaint.vo.ComplaintListItemVO;
import com.esv.freight.app.module.complaint.vo.ComplaintListVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/** /**
* @description: 司机投诉Controller * @description: 司机投诉Controller
* @project: freight-app-service * @project: freight-app-service
* @name: com.esv.freight.app.module.complaint.controller.DriverComplaintController * @name: com.esv.freight.app.module.complaint.controller.DriverComplaintController
* @author: 张志臣 * @author: 张志臣
* @email: zhangzhichen@esvtek.com * @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/28 13:30 * @createTime: 2020/05/29 17:30
* @version:1.0 * @version:1.0
*/ */
@RestController @RestController
...@@ -19,4 +42,174 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -19,4 +42,174 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@Validated @Validated
public class DriverComplaintController { public class DriverComplaintController {
private DriverComplaintInterface driverComplaintInterface;
@Autowired
public DriverComplaintController(DriverComplaintInterface driverComplaintInterface) {
this.driverComplaintInterface = driverComplaintInterface;
}
/**
* description 获取投诉列表
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/29 18:00
**/
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) DriverComplaintForm complaintForm) {
// 调用投诉列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("driverName", complaintForm.getDriverName());
reqJson.put("pageNum", complaintForm.getPageNum());
reqJson.put("pageSize", complaintForm.getPageSize());
log.info(reqJson.toJSONString());
JSONObject result = driverComplaintInterface.list(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
ComplaintListVO pageResultVO = new ComplaintListVO();
JSONObject data = result.getJSONObject("data");
pageResultVO.setPageSize(data.getLong("pageSize"));
pageResultVO.setPageNum(data.getLong("pageNum"));
pageResultVO.setTotal(data.getLong("totalSize"));
pageResultVO.setRecordSize(data.getLong("recordSize"));
if(pageResultVO.getRecordSize() > 0) {
JSONArray items = data.getJSONArray("records");
List<ComplaintListItemVO> records = new ArrayList<>();
for(int i=0; i<items.size(); ++i) {
ComplaintListItemVO vo = new ComplaintListItemVO();
JSONObject object = items.getJSONObject(i);
vo.setId(object.getLong("id"));
vo.setComplaintNo(object.getString("complaintNo"));
vo.setWaybillId(object.getLong("waybillId"));
vo.setWaybillNo(object.getString("waybillNo"));
vo.setComplaintState(object.getInteger("state"));
records.add(vo);
}
pageResultVO.setRecord(records);
}
return EResponse.ok(pageResultVO);
}
/**
* description 获取投诉详情
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/29 18:00
**/
@RequestMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) DriverComplaintForm complaintForm) {
// 调用投诉详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", complaintForm.getId());
log.info(reqJson.toJSONString());
JSONObject result = driverComplaintInterface.detail(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
OwnerComplaintAdvicePojo ownerComplaintAdvicePojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), OwnerComplaintAdvicePojo.class);
ComplaintDetailVO complaintDetailVO = new ComplaintDetailVO();
BeanUtils.copyProperties(ownerComplaintAdvicePojo, complaintDetailVO);
complaintDetailVO.setComplaintState(ownerComplaintAdvicePojo.getState());
return EResponse.ok(complaintDetailVO);
}
/**
* description 添加投诉
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/29 18:00
**/
@RequestMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) DriverComplaintForm complaintForm) {
// 调用添加投诉接口
JSONObject reqJson = new JSONObject();
reqJson.put("complaintAdvice", 1);
reqJson.put("state", 1);
reqJson.put("driverId", complaintForm.getUserId());
reqJson.put("driverName", complaintForm.getDriverName());
reqJson.put("waybillId", complaintForm.getWaybillId());
reqJson.put("complaintObject", complaintForm.getComplaintObject());
reqJson.put("complaintContent", complaintForm.getComplaintContent());
if(!StringUtils.isEmpty(complaintForm.getPictureUrl01())) {
reqJson.put("pictureUrl01", complaintForm.getPictureUrl01());
}
if(!StringUtils.isEmpty(complaintForm.getPictureUrl02())) {
reqJson.put("pictureUrl02", complaintForm.getPictureUrl02());
}
log.info(reqJson.toJSONString());
JSONObject result = driverComplaintInterface.add(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
/**
* description 修改投诉
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/29 18:00
**/
@RequestMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) DriverComplaintForm complaintForm) {
// 调用编辑投诉接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", complaintForm.getId());
reqJson.put("driverId", complaintForm.getUserId());
reqJson.put("driverName", complaintForm.getDriverName());
reqJson.put("complaintContent", complaintForm.getComplaintContent());
log.info(reqJson.toJSONString());
JSONObject result = driverComplaintInterface.edit(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
/**
* description 取消投诉
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/29 18:00
**/
@RequestMapping("/cancel")
public EResponse cancel(@RequestBody @Validated(ValidatorDetail.class) DriverComplaintForm complaintForm) {
// 调用取消投诉接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", complaintForm.getId());
log.info(reqJson.toJSONString());
JSONObject result = driverComplaintInterface.cancel(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
} }
...@@ -9,7 +9,7 @@ import com.esv.freight.app.common.validator.groups.ValidatorInsert; ...@@ -9,7 +9,7 @@ import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList; import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate; import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.feign.OwnerComplaintInterface; import com.esv.freight.app.feign.OwnerComplaintInterface;
import com.esv.freight.app.module.complaint.form.ComplaintForm; import com.esv.freight.app.module.complaint.form.OwnerComplaintForm;
import com.esv.freight.app.module.complaint.pojo.OwnerComplaintAdvicePojo; import com.esv.freight.app.module.complaint.pojo.OwnerComplaintAdvicePojo;
import com.esv.freight.app.module.complaint.vo.ComplaintDetailVO; import com.esv.freight.app.module.complaint.vo.ComplaintDetailVO;
import com.esv.freight.app.module.complaint.vo.ComplaintListItemVO; import com.esv.freight.app.module.complaint.vo.ComplaintListItemVO;
...@@ -57,7 +57,7 @@ public class OwnerComplaintController { ...@@ -57,7 +57,7 @@ public class OwnerComplaintController {
* createTime 2020/05/28 14:30 * createTime 2020/05/28 14:30
**/ **/
@PostMapping("/list") @PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) ComplaintForm complaintForm) { public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) OwnerComplaintForm complaintForm) {
// 调用投诉列表分页查询接口 // 调用投诉列表分页查询接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -105,7 +105,7 @@ public class OwnerComplaintController { ...@@ -105,7 +105,7 @@ public class OwnerComplaintController {
* createTime 2020/05/28 14:30 * createTime 2020/05/28 14:30
**/ **/
@RequestMapping("/detail") @RequestMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) ComplaintForm complaintForm) { public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) OwnerComplaintForm complaintForm) {
// 调用投诉详情接口 // 调用投诉详情接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -133,7 +133,7 @@ public class OwnerComplaintController { ...@@ -133,7 +133,7 @@ public class OwnerComplaintController {
* createTime 2020/05/28 15:00 * createTime 2020/05/28 15:00
**/ **/
@RequestMapping("/add") @RequestMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) ComplaintForm complaintForm) { public EResponse add(@RequestBody @Validated(ValidatorInsert.class) OwnerComplaintForm complaintForm) {
// 调用添加投诉接口 // 调用添加投诉接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -170,7 +170,7 @@ public class OwnerComplaintController { ...@@ -170,7 +170,7 @@ public class OwnerComplaintController {
* createTime 2020/05/28 15:00 * createTime 2020/05/28 15:00
**/ **/
@RequestMapping("/edit") @RequestMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) ComplaintForm complaintForm) { public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) OwnerComplaintForm complaintForm) {
// 调用编辑投诉接口 // 调用编辑投诉接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
...@@ -198,7 +198,7 @@ public class OwnerComplaintController { ...@@ -198,7 +198,7 @@ public class OwnerComplaintController {
* createTime 2020/05/28 15:00 * createTime 2020/05/28 15:00
**/ **/
@RequestMapping("/cancel") @RequestMapping("/cancel")
public EResponse cancel(@RequestBody @Validated(ValidatorDetail.class) ComplaintForm complaintForm) { public EResponse cancel(@RequestBody @Validated(ValidatorDetail.class) OwnerComplaintForm complaintForm) {
// 调用取消投诉接口 // 调用取消投诉接口
JSONObject reqJson = new JSONObject(); JSONObject reqJson = new JSONObject();
......
package com.esv.freight.app.module.complaint.form;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.complaint.form.DriverComplaintForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/28 14:00
* @version:1.0
*/
@Data
public class DriverComplaintForm {
/**
* 主键
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class})
private Long id;
/**
* 账号ID
*/
@NotNull(message = "参数账号id不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private Long userId;
/**
* 运单ID
*/
@NotNull(message = "参数运单id不能为空", groups = {ValidatorInsert.class})
private Long waybillId;
/**
* 投诉对象,1-货主,2-平台,0-其他
*/
@NotNull(message = "参数投诉对象不能为空", groups = {ValidatorInsert.class})
@Range(min = 0, max = 2, message = "无效的投诉对象", groups = {ValidatorInsert.class})
private Integer complaintObject;
/**
* 投诉内容
*/
@NotNull(message = "参数投诉内容不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@Length(max = 1000, message = "参数投诉内容长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String complaintContent;
/**
* 照片01URL
*/
@Length(max = 200, message = "参数pictureUrl01长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String pictureUrl01;
/**
* 照片02URL
*/
@Length(max = 200, message = "参数pictureUrl02长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String pictureUrl02;
/**
* 司机姓名
*/
@Length(max = 64, message = "参数货主姓名长度不合法", groups = {ValidatorList.class, ValidatorUpdate.class})
@NotBlank(message = "参数货主姓名不能为空", groups = {ValidatorList.class, ValidatorUpdate.class})
private String driverName;
/**
* 当前页数
*/
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Long pageNum;
/**
* 每页显示记录数
*/
@Range(min = 1, max = 1000, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Long pageSize;
}
...@@ -16,14 +16,14 @@ import javax.validation.constraints.NotNull; ...@@ -16,14 +16,14 @@ import javax.validation.constraints.NotNull;
/** /**
* @description: * @description:
* @project: freight-app-service * @project: freight-app-service
* @name: com.esv.freight.app.module.complaint.form.ComplaintForm * @name: com.esv.freight.app.module.complaint.form.OwnerComplaintForm
* @author: 张志臣 * @author: 张志臣
* @email: zhangzhichen@esvtek.com * @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/28 14:00 * @createTime: 2020/05/28 14:00
* @version:1.0 * @version:1.0
*/ */
@Data @Data
public class ComplaintForm { public class OwnerComplaintForm {
/** /**
* 主键 * 主键
......
package com.esv.freight.app.module.evaluate.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.feign.DriverEvaluateInterface;
import com.esv.freight.app.feign.OwnerEvaluateInterface;
import com.esv.freight.app.module.evaluate.form.DriverEvaluateForm;
import com.esv.freight.app.module.evaluate.form.OwnerEvaluateForm;
import com.esv.freight.app.module.evaluate.pojo.DriverEvaluatePojo;
import com.esv.freight.app.module.evaluate.pojo.OwnerEvaluatePojo;
import com.esv.freight.app.module.evaluate.vo.DriverEvaluateDetailVO;
import com.esv.freight.app.module.evaluate.vo.EvaluateListItemVO;
import com.esv.freight.app.module.evaluate.vo.EvaluateListVO;
import com.esv.freight.app.module.evaluate.vo.OwnerEvaluateDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 司机评价Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.controller.DriverEvaluateController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:20
* @version:1.0
*/
@RestController
@RequestMapping("/driverBackend/evaluate")
@Slf4j
@Validated
public class DriverEvaluateController {
private DriverEvaluateInterface driverEvaluateInterface;
@Autowired
public DriverEvaluateController(DriverEvaluateInterface driverEvaluateInterface) {
this.driverEvaluateInterface = driverEvaluateInterface;
}
/**
* description 获取评价列表
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/06/01 13:10
**/
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) DriverEvaluateForm driverEvaluateForm) {
// 调用评价列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("driverName", driverEvaluateForm.getDriverName());
reqJson.put("pageNum", driverEvaluateForm.getPageNum());
reqJson.put("pageSize", driverEvaluateForm.getPageSize());
log.info(reqJson.toJSONString());
JSONObject result = driverEvaluateInterface.list(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
EvaluateListVO pageResultVO = new EvaluateListVO();
JSONObject data = result.getJSONObject("data");
pageResultVO.setPageSize(data.getLong("pageSize"));
pageResultVO.setPageNum(data.getLong("pageNum"));
pageResultVO.setTotal(data.getLong("totalSize"));
pageResultVO.setRecordSize(data.getLong("recordSize"));
if(pageResultVO.getRecordSize() > 0) {
JSONArray items = data.getJSONArray("records");
List<EvaluateListItemVO> records = new ArrayList<>();
for(int i=0; i<items.size(); ++i) {
EvaluateListItemVO vo = new EvaluateListItemVO();
JSONObject object = items.getJSONObject(i);
vo.setId(object.getLong("id"));
vo.setCustomerId(object.getLong("goodsOwnerId"));
vo.setCustomerName(object.getString("goodsOwnerName"));
vo.setWaybillId(object.getLong("waybillId"));
vo.setWaybillNo(object.getString("waybillNo"));
records.add(vo);
}
pageResultVO.setRecord(records);
}
return EResponse.ok(pageResultVO);
}
/**
* description 获取评价详情
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/06/01 13:10
**/
@RequestMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) DriverEvaluateForm driverEvaluateForm) {
// 调用评价详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", driverEvaluateForm.getId());
log.info(reqJson.toJSONString());
JSONObject result = driverEvaluateInterface.detail(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
DriverEvaluatePojo driverEvaluatePojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), DriverEvaluatePojo.class);
DriverEvaluateDetailVO driverEvaluateDetailVO = new DriverEvaluateDetailVO();
BeanUtils.copyProperties(driverEvaluatePojo, driverEvaluateDetailVO);
driverEvaluateDetailVO.setCustomerId(driverEvaluatePojo.getGoodsOwnerId());
driverEvaluateDetailVO.setCustomerName(driverEvaluatePojo.getGoodsOwnerName());
return EResponse.ok(driverEvaluateDetailVO);
}
/**
* description 添加评价
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/30 14:30
**/
@RequestMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) DriverEvaluateForm driverEvaluateForm) {
// 调用添加评价接口
JSONObject reqJson = new JSONObject();
reqJson.put("driverId", driverEvaluateForm.getDriverId());
reqJson.put("driverName", driverEvaluateForm.getDriverName());
reqJson.put("waybillId", driverEvaluateForm.getWaybillId());
reqJson.put("loadingConvenience", driverEvaluateForm.getLoadingConvenience());
reqJson.put("unloadingConvenience", driverEvaluateForm.getUnloadingConvenience());
reqJson.put("appraiseContent", driverEvaluateForm.getAppraiseContent());
log.info(reqJson.toJSONString());
JSONObject result = driverEvaluateInterface.add(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
}
package com.esv.freight.app.module.evaluate.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.feign.OwnerEvaluateInterface;
import com.esv.freight.app.module.evaluate.form.OwnerEvaluateForm;
import com.esv.freight.app.module.evaluate.pojo.OwnerEvaluatePojo;
import com.esv.freight.app.module.evaluate.vo.EvaluateListItemVO;
import com.esv.freight.app.module.evaluate.vo.EvaluateListVO;
import com.esv.freight.app.module.evaluate.vo.OwnerEvaluateDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 货主评价Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.controller.OwnerEvaluateController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:20
* @version:1.0
*/
@RestController
@RequestMapping("/ownerBackend/evaluate")
@Slf4j
@Validated
public class OwnerEvaluateController {
private OwnerEvaluateInterface ownerEvaluateInterface;
@Autowired
public OwnerEvaluateController(OwnerEvaluateInterface ownerEvaluateInterface) {
this.ownerEvaluateInterface = ownerEvaluateInterface;
}
/**
* description 获取评价列表
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/30 14:30
**/
@PostMapping("/list")
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) OwnerEvaluateForm ownerEvaluateForm) {
// 调用评价列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerName", ownerEvaluateForm.getGoodsOwnerName());
reqJson.put("pageNum", ownerEvaluateForm.getPageNum());
reqJson.put("pageSize", ownerEvaluateForm.getPageSize());
log.info(reqJson.toJSONString());
JSONObject result = ownerEvaluateInterface.list(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
EvaluateListVO pageResultVO = new EvaluateListVO();
JSONObject data = result.getJSONObject("data");
pageResultVO.setPageSize(data.getLong("pageSize"));
pageResultVO.setPageNum(data.getLong("pageNum"));
pageResultVO.setTotal(data.getLong("totalSize"));
pageResultVO.setRecordSize(data.getLong("recordSize"));
if(pageResultVO.getRecordSize() > 0) {
JSONArray items = data.getJSONArray("records");
List<EvaluateListItemVO> records = new ArrayList<>();
for(int i=0; i<items.size(); ++i) {
EvaluateListItemVO vo = new EvaluateListItemVO();
JSONObject object = items.getJSONObject(i);
vo.setId(object.getLong("id"));
vo.setCustomerId(object.getLong("driverId"));
vo.setCustomerName(object.getString("driverName"));
vo.setWaybillId(object.getLong("waybillId"));
vo.setWaybillNo(object.getString("waybillNo"));
records.add(vo);
}
pageResultVO.setRecord(records);
}
return EResponse.ok(pageResultVO);
}
/**
* description 获取评价详情
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/30 14:30
**/
@RequestMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) OwnerEvaluateForm ownerEvaluateForm) {
// 调用评价详情接口
JSONObject reqJson = new JSONObject();
reqJson.put("id", ownerEvaluateForm.getId());
log.info(reqJson.toJSONString());
JSONObject result = ownerEvaluateInterface.detail(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
OwnerEvaluatePojo ownerEvaluatePojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), OwnerEvaluatePojo.class);
OwnerEvaluateDetailVO ownerEvaluateDetailVO = new OwnerEvaluateDetailVO();
BeanUtils.copyProperties(ownerEvaluatePojo, ownerEvaluateDetailVO);
ownerEvaluateDetailVO.setCustomerId(ownerEvaluatePojo.getDriverId());
ownerEvaluateDetailVO.setCustomerName(ownerEvaluatePojo.getDriverName());
return EResponse.ok(ownerEvaluateDetailVO);
}
/**
* description 添加评价
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/30 14:30
**/
@RequestMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) OwnerEvaluateForm ownerEvaluateForm) {
// 调用添加评价接口
JSONObject reqJson = new JSONObject();
reqJson.put("goodsOwnerId", ownerEvaluateForm.getGoodsOwnerId());
reqJson.put("goodsOwnerName", ownerEvaluateForm.getGoodsOwnerName());
reqJson.put("waybillId", ownerEvaluateForm.getWaybillId());
reqJson.put("onTimeLoading", ownerEvaluateForm.getOnTimeLoading());
reqJson.put("onTimeUnloading", ownerEvaluateForm.getOnTimeUnloading());
reqJson.put("safeArrival", ownerEvaluateForm.getSafeArrival());
reqJson.put("serviceAttitude", ownerEvaluateForm.getServiceAttitude());
reqJson.put("appraiseContent", ownerEvaluateForm.getAppraiseContent());
log.info(reqJson.toJSONString());
JSONObject result = ownerEvaluateInterface.add(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
}
package com.esv.freight.app.module.evaluate.form;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.form.DriverEvaluateForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:00
* @version:1.0
*/
@Data
public class DriverEvaluateForm {
/**
* 主键
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class})
private Long id;
/**
* 司机ID
*/
@NotNull(message = "参数driverId不能为空", groups = {ValidatorInsert.class})
private Long driverId;
/**
* 司机姓名
*/
@Length(max = 64, message = "参数driverName长度不合法", groups = {ValidatorList.class})
private String driverName;
/**
* 运单ID
*/
@NotNull(message = "参数货主ID不能为空", groups = {ValidatorInsert.class})
private Long waybillId;
/**
* 装货便捷性评分
*/
@Range(min = 1, max = 50, message = "无效的装货便捷性评分", groups = {ValidatorList.class})
@NotNull(message = "参数loadingConvenience不能为空", groups = {ValidatorInsert.class})
private Integer loadingConvenience;
/**
* 卸货便捷性评分
*/
@Range(min = 1, max = 50, message = "无效的卸货便捷性评分", groups = {ValidatorList.class})
@NotNull(message = "参数unloadingConvenience不能为空", groups = {ValidatorInsert.class})
private Integer unloadingConvenience;
/**
* 评价描述
*/
@Length(max = 1000, message = "参数评价描述长度不合法", groups = {ValidatorInsert.class})
private String appraiseContent;
/**
* 当前页数
*/
@Range(min = 1, max = 65535, message = "无效的pageNum", groups = {ValidatorList.class})
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Long pageNum;
/**
* 每页显示记录数
*/
@Range(min = 1, max = 100, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Long pageSize;
}
package com.esv.freight.app.module.evaluate.form;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.form.OwnerEvaluateForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:00
* @version:1.0
*/
@Data
public class OwnerEvaluateForm {
/**
* 主键
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorDetail.class})
private Long id;
/**
* 货主ID
*/
@NotNull(message = "参数goodsOwnerId不能为空", groups = {ValidatorInsert.class})
private Long goodsOwnerId;
/**
* 货主姓名
*/
@Length(max = 64, message = "参数货主姓名长度不合法", groups = {ValidatorList.class})
private String goodsOwnerName;
/**
* 运单ID
*/
@NotNull(message = "参数货主ID不能为空", groups = {ValidatorInsert.class})
private Long waybillId;
/**
* 准时装货评分
*/
@Range(min = 1, max = 50, message = "无效的准时到达装货评分", groups = {ValidatorInsert.class})
@NotNull(message = "参数onTimeLoading不能为空", groups = {ValidatorInsert.class})
private Integer onTimeLoading;
/**
* 准时卸货评分
*/
@Range(min = 1, max = 50, message = "无效的准时到达卸货评分", groups = {ValidatorInsert.class})
@NotNull(message = "参数onTimeUnloading不能为空", groups = {ValidatorInsert.class})
private Integer onTimeUnloading;
/**
* 货物安全到达评分
*/
@Range(min = 1, max = 50, message = "无效的货物安全到达评分", groups = {ValidatorInsert.class})
@NotNull(message = "参数safeArrival不能为空", groups = {ValidatorInsert.class})
private Integer safeArrival;
/**
* 服务态度评分
*/
@Range(min = 1, max = 50, message = "无效的服务态度评分", groups = {ValidatorInsert.class})
@NotNull(message = "参数serviceAttitude不能为空", groups = {ValidatorInsert.class})
private Integer serviceAttitude;
/**
* 评价描述
*/
@Length(max = 1000, message = "参数评价描述长度不合法", groups = {ValidatorInsert.class})
private String appraiseContent;
/**
* 当前页数
*/
@Range(min = 1, max = 65535, message = "无效的pageNum", groups = {ValidatorList.class})
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Long pageNum;
/**
* 每页显示记录数
*/
@Range(min = 1, max = 100, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Long pageSize;
}
package com.esv.freight.app.module.evaluate.pojo;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.pojo.DriverEvaluatePojo
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/01 13:15
* @version:1.0
*/
@Data
public class DriverEvaluatePojo {
/**
* 主键
*/
private Long id;
/**
* 司机ID
*/
private Long driverId;
/**
* 司机姓名
*/
private String driverName;
/**
* 运单ID
*/
private Long waybillId;
/**
* 运单号
*/
private String waybillNo;
/**
* 货主ID
*/
private Long goodsOwnerId;
/**
* 货主姓名
*/
private String goodsOwnerName;
/**
* 装货便捷性评分
*/
private Integer loadingConvenience;
/**
* 卸货便捷性评分
*/
private Integer unloadingConvenience;
/**
* 评价内容
*/
private String appraiseContent;
/**
* 是否删除
*/
private Boolean deleted;
/**
* 租户ID
*/
private Long tenantId;
/**
* 部门ID
*/
private Long departmentId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 创建人
*/
private String createUser;
/**
* 更新人
*/
private String updateUser;
}
package com.esv.freight.app.module.evaluate.pojo;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.pojo.OwnerEvaluatePojo
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:30
* @version:1.0
*/
@Data
public class OwnerEvaluatePojo {
/**
* 主键
*/
private Long id;
/**
* 货主ID
*/
private Long goodsOwnerId;
/**
* 货主姓名
*/
private String goodsOwnerName;
/**
* 运单ID
*/
private Long waybillId;
/**
* 运单号
*/
private String waybillNo;
/**
* 司机ID
*/
private Long driverId;
/**
* 司机姓名
*/
private String driverName;
/**
* 准时装货评分
*/
private Integer onTimeLoading;
/**
* 准时卸货评分
*/
private Integer onTimeUnloading;
/**
* 货物安全到达
*/
private Integer safeArrival;
/**
* 服务态度
*/
private Integer serviceAttitude;
/**
* 评价内容
*/
private String appraiseContent;
/**
* 是否删除
*/
private Boolean deleted;
/**
* 租户ID
*/
private Long tenantId;
/**
* 部门ID
*/
private Long departmentId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 创建人
*/
private String createUser;
/**
* 更新人
*/
private String updateUser;
}
package com.esv.freight.app.module.evaluate.vo;
import lombok.Data;
import java.util.Date;
@Data
public class DriverEvaluateDetailVO {
/**
*
*/
private Long id;
/**
* 评价对象ID
*/
private Long customerId;
/**
* 评价对象姓名
*/
private String customerName;
/**
* 运单ID
*/
private Long waybillId;
/**
* 运单号
*/
private String waybillNo;
/**
* 创建时间
*/
private Date createTime;
/**
* 装货便捷性评分
*/
private Integer loadingConvenience;
/**
* 卸货便捷性评分
*/
private Integer unloadingConvenience;
/**
* 评价内容
*/
private String appraiseContent;
}
package com.esv.freight.app.module.evaluate.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.vo.EvaluateDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:00
* @version:1.0
*/
@Data
public class EvaluateListItemVO {
/**
*
*/
private Long id;
/**
* 评价对象ID
*/
private Long customerId;
/**
* 评价对象姓名
*/
private String customerName;
/**
* 运单ID
*/
private Long waybillId;
/**
* 运单号
*/
private String waybillNo;
}
package com.esv.freight.app.module.evaluate.vo;
import lombok.Data;
import java.util.List;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.vo.EvaluateDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:00
* @version:1.0
*/
@Data
public class EvaluateListVO {
/**
* 每页记录条数
**/
private Long pageSize;
/**
* 当前页码
**/
private Long pageNum;
/**
* 总记录条数
**/
private Long total;
/**
* 当前页的记录条数
**/
private Long recordSize;
/**
* 数据
**/
private List<EvaluateListItemVO> record;
}
package com.esv.freight.app.module.evaluate.vo;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.evaluate.vo.EvaluateDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/30 14:00
* @version:1.0
*/
@Data
public class OwnerEvaluateDetailVO {
/**
*
*/
private Long id;
/**
* 评价对象ID
*/
private Long customerId;
/**
* 评价对象姓名
*/
private String customerName;
/**
* 运单ID
*/
private Long waybillId;
/**
* 运单号
*/
private String waybillNo;
/**
* 创建时间
*/
private Date createTime;
/**
* 准时装货评分
*/
private Integer onTimeLoading;
/**
* 准时卸货评分
*/
private Integer onTimeUnloading;
/**
* 货物安全到达
*/
private Integer safeArrival;
/**
* 服务态度
*/
private Integer serviceAttitude;
/**
* 评价内容
*/
private String appraiseContent;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment