|
@@ -5,18 +5,19 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.sop.business.bean.dto.CrmDetailImportDto;
|
|
|
+import com.qmth.sop.business.bean.params.CrmDetailSopParam;
|
|
|
+import com.qmth.sop.business.bean.result.CrmProjectResult;
|
|
|
+import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
|
import com.qmth.sop.business.mapper.TBCrmDetailMapper;
|
|
|
-import com.qmth.sop.business.service.TBCrmDetailService;
|
|
|
-import com.qmth.sop.business.service.TBCrmService;
|
|
|
-import com.qmth.sop.business.service.TBServiceService;
|
|
|
-import com.qmth.sop.business.service.TFCustomFlowService;
|
|
|
+import com.qmth.sop.business.service.*;
|
|
|
import com.qmth.sop.business.util.excel.BasicExcelListener;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.sop.common.enums.FieldUniqueEnum;
|
|
|
import com.qmth.sop.common.enums.ProductTypeEnum;
|
|
|
import com.qmth.sop.common.enums.TFCustomTypeEnum;
|
|
|
+import com.qmth.sop.common.util.JacksonUtil;
|
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -57,19 +58,49 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
|
|
|
@Resource
|
|
|
TBServiceService tbServiceService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TDFormWidgetService tdFormWidgetService;
|
|
|
+
|
|
|
/**
|
|
|
- * 派单明细sop变量保存
|
|
|
+ * 查找派单sop信息
|
|
|
*
|
|
|
* @param crmNo
|
|
|
- * @param processVar
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CrmProjectResult sopVarInfo(String crmNo) {
|
|
|
+ CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(null, crmNo);
|
|
|
+ Objects.requireNonNull(crmProjectResult, "未找到派单信息");
|
|
|
+
|
|
|
+ TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
|
|
|
+ TBService tbService = tbServiceService.getById(tbCrm.getServiceId());
|
|
|
+ Objects.requireNonNull(tbService, "未找到服务单元");
|
|
|
+
|
|
|
+ if (Objects.isNull(crmProjectResult.getProcessVar())) {
|
|
|
+ if (tbService.getType() == ProductTypeEnum.OFFICE) {
|
|
|
+ List<FlowFormWidgetResult> flowFormWidgetResultList = tdFormWidgetService.flowWidgetQuery(
|
|
|
+ TFCustomTypeEnum.OFFICE_SOP_FLOW, 1, SystemConstant.OFFICE_COMMON_GROUP);
|
|
|
+ if (CollectionUtils.isEmpty(flowFormWidgetResultList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("教务处sop公用控件未设置");
|
|
|
+ }
|
|
|
+ crmProjectResult.setProcessVar(JacksonUtil.parseJson(flowFormWidgetResultList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return crmProjectResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 派单明细sop变量保存
|
|
|
+ *
|
|
|
+ * @param crmDetailSopParam
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public boolean sopVarSave(String crmNo, String processVar) {
|
|
|
+ public boolean sopVarSave(CrmDetailSopParam crmDetailSopParam) {
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
|
|
|
- tbCrm.updateProcessVar(processVar, sysUser.getId());
|
|
|
+ TBCrm tbCrm = tbCrmService.findByCrmNo(crmDetailSopParam.getCrmNo());
|
|
|
+ tbCrm.updateProcessVar(crmDetailSopParam.getProcessVar(), sysUser.getId());
|
|
|
return tbCrmService.updateById(tbCrm);
|
|
|
}
|
|
|
|
|
@@ -87,19 +118,7 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
|
|
|
- if (Objects.isNull(tbCrm.getProcessVar()) || Objects.equals(tbCrm.getProcessVar().trim(), "")) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("请先保存属性【部署方式】【阅卷方式】【扫描场地网络】");
|
|
|
- }
|
|
|
- TBService tbService = tbServiceService.getById(tbCrm.getServiceId());
|
|
|
- Objects.requireNonNull(tbService, "未找到服务单元");
|
|
|
-
|
|
|
- TFCustomFlow tfCustomFlow = null;
|
|
|
- if (tbService.getType() == ProductTypeEnum.OFFICE) {
|
|
|
- tfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, TFCustomTypeEnum.OFFICE_SOP_FLOW);
|
|
|
- }
|
|
|
- Objects.requireNonNull(tfCustomFlow, "未找到教务处流程");
|
|
|
-
|
|
|
+ TFCustomFlow tfCustomFlow = tbCrmDetailService.queryCustomFlow(crmNo);
|
|
|
Map<String, String> messageMap = new LinkedHashMap<>();
|
|
|
try {
|
|
|
StringJoiner errorData = new StringJoiner("");
|
|
@@ -166,4 +185,62 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
|
|
|
public IPage<TBCrmDetail> list(IPage<Map> iPage, String crmNo) {
|
|
|
return this.baseMapper.list(iPage, crmNo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建/编辑派单明细sop
|
|
|
+ *
|
|
|
+ * @param tbCrmDetail
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean sopSave(TBCrmDetail tbCrmDetail) {
|
|
|
+ try {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ if (Objects.isNull(tbCrmDetail.getId())) {//说明创建sop
|
|
|
+ TFCustomFlow tfCustomFlow = tbCrmDetailService.queryCustomFlow(tbCrmDetail.getCrmNo());
|
|
|
+ tbCrmDetail.createSop(tfCustomFlow.getFlowDeploymentId(), sysUser.getId());
|
|
|
+ } else {
|
|
|
+ tbCrmDetail.updateInfo(sysUser.getId());
|
|
|
+ }
|
|
|
+ return tbCrmDetailService.saveOrUpdate(tbCrmDetail);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
+ String[] strs = StringUtils.split(errorColumn, "-");
|
|
|
+ String[] columns = StringUtils.split(strs[strs.length - 1], "\\'");
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception(
|
|
|
+ FieldUniqueEnum.convertToTitle(columns[columns.length - 1]) + ":[" + columns[0] + "]数据不允许重复插入");
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
+ ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询自定义流程
|
|
|
+ *
|
|
|
+ * @param crmNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TFCustomFlow queryCustomFlow(String crmNo) {
|
|
|
+ TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
|
|
|
+ if (Objects.isNull(tbCrm.getProcessVar()) || Objects.equals(tbCrm.getProcessVar().trim(), "")) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请先保存属性【部署方式】【阅卷方式】【扫描场地网络】");
|
|
|
+ }
|
|
|
+ TBService tbService = tbServiceService.getById(tbCrm.getServiceId());
|
|
|
+ Objects.requireNonNull(tbService, "未找到服务单元");
|
|
|
+
|
|
|
+ TFCustomFlow tfCustomFlow = null;
|
|
|
+ if (tbService.getType() == ProductTypeEnum.OFFICE) {
|
|
|
+ tfCustomFlow = tfCustomFlowService.findMaxVersion(null, null, TFCustomTypeEnum.OFFICE_SOP_FLOW);
|
|
|
+ }
|
|
|
+ Objects.requireNonNull(tfCustomFlow, "未找到教务处流程");
|
|
|
+ return tfCustomFlow;
|
|
|
+ }
|
|
|
}
|