|
@@ -1,6 +1,7 @@
|
|
|
package com.gree.mall.manager.logic.quality;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
@@ -9,19 +10,27 @@ import com.gree.mall.manager.bean.quality.QualityFeedbackCountBean;
|
|
|
import com.gree.mall.manager.bean.quality.QualityFeedbackVO;
|
|
|
import com.gree.mall.manager.commonmapper.CommonMapper;
|
|
|
import com.gree.mall.manager.enums.quality.ExamineQualityFeedbackStatusEnum;
|
|
|
+import com.gree.mall.manager.enums.quality.QualityFeedbackTypeEnum;
|
|
|
+import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.plus.entity.QualityFeedback;
|
|
|
import com.gree.mall.manager.plus.entity.QualityFeedbackItem;
|
|
|
+import com.gree.mall.manager.plus.service.AdminWebsitService;
|
|
|
import com.gree.mall.manager.plus.service.QualityFeedbackItemService;
|
|
|
import com.gree.mall.manager.plus.service.QualityFeedbackService;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -32,6 +41,7 @@ public class QualityFeedbackLogic {
|
|
|
private final CommonMapper commonMapper;
|
|
|
private final QualityFeedbackService qualityFeedbackService;
|
|
|
private final QualityFeedbackItemService qualityFeedbackItemService;
|
|
|
+ private final AdminWebsitService adminWebsitService;
|
|
|
|
|
|
public IPage<QualityFeedbackVO> list(ZfireParamBean zfireParamBean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
@@ -74,12 +84,184 @@ public class QualityFeedbackLogic {
|
|
|
return bean;
|
|
|
}
|
|
|
|
|
|
- public void add(QualityFeedbackCountBean bean) {
|
|
|
+ public void add(QualityFeedbackBean bean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ this.checkRequireParams(bean);
|
|
|
+ bean.setStatus(ExamineQualityFeedbackStatusEnum.SAVE.getKey());
|
|
|
+ bean.insert();
|
|
|
+ for (QualityFeedbackItem item : bean.getItems()) {
|
|
|
+ item.setQualityFeedbckId(bean.getId());
|
|
|
+ }
|
|
|
+ qualityFeedbackItemService.saveBatch(bean.getItems());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkRequireParams(QualityFeedbackBean bean) {
|
|
|
+ if (StringUtils.isBlank(bean.getWebsitId()) || StringUtils.isBlank(bean.getWebsitName())) {
|
|
|
+ throw new RemoteServiceException("反馈网点不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getTitle())) {
|
|
|
+ throw new RemoteServiceException("反馈主题不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getOrderNo())) {
|
|
|
+ throw new RemoteServiceException("云售后4.0工单号不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getWorkerName())) {
|
|
|
+ throw new RemoteServiceException("工程师名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getWorkerMobie())) {
|
|
|
+ throw new RemoteServiceException("工程师电话不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getCustomerName())) {
|
|
|
+ throw new RemoteServiceException("客户名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getCustomerMobile())) {
|
|
|
+ throw new RemoteServiceException("客户电话不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getProvince())) {
|
|
|
+ throw new RemoteServiceException("省份不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getCity())) {
|
|
|
+ throw new RemoteServiceException("城市不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getArea())) {
|
|
|
+ throw new RemoteServiceException("县区不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getStreet())) {
|
|
|
+ throw new RemoteServiceException("街道不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getAddress())) {
|
|
|
+ throw new RemoteServiceException("详细地址不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getMainId()) || StringUtils.isBlank(bean.getMainName())) {
|
|
|
+ throw new RemoteServiceException("产品大类不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getSmallId()) || StringUtils.isBlank(bean.getSmallName())) {
|
|
|
+ throw new RemoteServiceException("产品小类不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getSeriesName())) {
|
|
|
+ throw new RemoteServiceException("系列名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getProductName())) {
|
|
|
+ throw new RemoteServiceException("机型名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getInsideCode())) {
|
|
|
+ throw new RemoteServiceException("内机条码不能为空");
|
|
|
+ }
|
|
|
+ Integer count = qualityFeedbackService.lambdaQuery()
|
|
|
+ .eq(QualityFeedback::getInsideCode, bean.getInsideCode())
|
|
|
+ .ne(StringUtils.isNotBlank(bean.getId()), QualityFeedback::getId, bean.getId())
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("内机条码在系统里已存在");
|
|
|
+ }
|
|
|
+ if ("空调,空气能热水器".contains(bean.getMainName()) && StringUtils.isBlank(bean.getOutCode())) {
|
|
|
+ throw new RemoteServiceException("外机条码不能为空");
|
|
|
+ }
|
|
|
+ if ("空调,空气能热水器".contains(bean.getMainName())) {
|
|
|
+ count = qualityFeedbackService.lambdaQuery()
|
|
|
+ .eq(QualityFeedback::getOutCode, bean.getOutCode())
|
|
|
+ .ne(StringUtils.isNotBlank(bean.getId()), QualityFeedback::getId, bean.getId())
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("外机条码在系统里已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getNum())) {
|
|
|
+ throw new RemoteServiceException("发生数量不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getUseDate())) {
|
|
|
+ throw new RemoteServiceException("安装或使用日期不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getRepairDate())) {
|
|
|
+ throw new RemoteServiceException("报修或发生日期不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getIsPartSend())) {
|
|
|
+ throw new RemoteServiceException("有无配件寄回不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getBugPartCode())) {
|
|
|
+ throw new RemoteServiceException("故障代码不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getIsNeedPlan())) {
|
|
|
+ throw new RemoteServiceException("是否需要处理方案不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(bean.getSupplyDate())) {
|
|
|
+ throw new RemoteServiceException("要求提供日期不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getBugRemark())) {
|
|
|
+ throw new RemoteServiceException("故障描述不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getWebsitAnalyse())) {
|
|
|
+ throw new RemoteServiceException("网点人析不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(bean.getWebsitHandleMethod())) {
|
|
|
+ throw new RemoteServiceException("网点处理方法不能为空");
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isEmpty(bean.getItems())) {
|
|
|
+ throw new RemoteServiceException("明细不能为空");
|
|
|
+ }
|
|
|
+ final Map<String, QualityFeedbackItem> itemMap = bean.getItems().stream()
|
|
|
+ .collect(Collectors.toMap(QualityFeedbackItem::getType, Function.identity(), (key1, key2) -> key2));
|
|
|
+ if (!itemMap.containsKey(QualityFeedbackTypeEnum.INSIDE_CODE.getKey())) {
|
|
|
+ throw new RemoteServiceException("上传图片内机条码图不能为空");
|
|
|
+ }
|
|
|
+ if ("空调,空气能热水器".contains(bean.getMainName())
|
|
|
+ && !itemMap.containsKey(QualityFeedbackTypeEnum.INSIDE_CODE.getKey())) {
|
|
|
+ throw new RemoteServiceException("上传图片外机条码图不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public void update(QualityFeedbackCountBean bean) {
|
|
|
+ public void update(QualityFeedbackBean bean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ QualityFeedback old = qualityFeedbackService.getById(bean.getId());
|
|
|
+
|
|
|
+ if (old.getStatus().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey())
|
|
|
+ || old.getStatus().equals(ExamineQualityFeedbackStatusEnum.OK.getKey())
|
|
|
+ || old.getStatus().equals(ExamineQualityFeedbackStatusEnum.FAIL.getKey())) {
|
|
|
+ throw new RemoteServiceException("单据状态非“保存”或“驳回可修改”不能修改");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bean.getStatus().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey())) {
|
|
|
+ bean.setSubmitBy(adminUser.getNickName())
|
|
|
+ .setSubmitTime(DateUtil.date());
|
|
|
+ }
|
|
|
+ bean.updateById();
|
|
|
+ qualityFeedbackService.lambdaUpdate()
|
|
|
+ .set(QualityFeedback::getConfirmBy, null)
|
|
|
+ .set(QualityFeedback::getConfirmTime, null)
|
|
|
+ .eq(QualityFeedback::getId, bean.getId())
|
|
|
+ .update();
|
|
|
+ qualityFeedbackItemService.lambdaUpdate()
|
|
|
+ .eq(QualityFeedbackItem::getQualityFeedbckId, bean.getId())
|
|
|
+ .remove();
|
|
|
+ for (QualityFeedbackItem item : bean.getItems()) {
|
|
|
+ item.setQualityFeedbckId(bean.getId());
|
|
|
+ }
|
|
|
+ qualityFeedbackItemService.saveBatch(bean.getItems());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void confirm(String id, String remark, ExamineQualityFeedbackStatusEnum status) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ if (adminUser.getType().equals(1)) {
|
|
|
+ throw new RemoteServiceException("非中心账号,审核失败");
|
|
|
+ }
|
|
|
+ if (status.getKey().equals(ExamineQualityFeedbackStatusEnum.SAVE.getKey())
|
|
|
+ || status.getKey().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey()) ) {
|
|
|
+ throw new RemoteServiceException("审核异常");
|
|
|
+ }
|
|
|
+ qualityFeedbackService.lambdaUpdate()
|
|
|
+ .set(QualityFeedback::getConfirmBy, adminUser.getNickName())
|
|
|
+ .set(QualityFeedback::getConfirmTime, DateUtil.date())
|
|
|
+ .set(QualityFeedback::getRemark, remark)
|
|
|
+ .eq(QualityFeedback::getId, id)
|
|
|
+ .eq(QualityFeedback::getStatus, ExamineQualityFeedbackStatusEnum.WAIT.getKey())
|
|
|
+ .update();
|
|
|
}
|
|
|
|
|
|
- public void confirm(String id, ExamineQualityFeedbackStatusEnum status) {
|
|
|
+ public void updateUpload(List<String> ids) {
|
|
|
+ qualityFeedbackService.lambdaUpdate()
|
|
|
+ .set(QualityFeedback::getId, ids)
|
|
|
+ .set(QualityFeedback::getIsUpload, true)
|
|
|
+ .ne(QualityFeedback::getStatus, ExamineQualityFeedbackStatusEnum.SAVE.getKey())
|
|
|
+ .update();
|
|
|
}
|
|
|
}
|