|
|
@@ -0,0 +1,142 @@
|
|
|
+package com.java110.api.listener.ownerRepair;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.java110.api.bmo.ownerRepair.IOwnerRepairBMO;
|
|
|
+import com.java110.api.listener.AbstractServiceApiPlusListener;
|
|
|
+import com.java110.core.annotation.Java110Listener;
|
|
|
+import com.java110.core.context.DataFlowContext;
|
|
|
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
+import com.java110.dto.repair.RepairDto;
|
|
|
+import com.java110.dto.repair.RepairUserDto;
|
|
|
+import com.java110.intf.common.IFileInnerServiceSMO;
|
|
|
+import com.java110.intf.community.IRepairInnerServiceSMO;
|
|
|
+import com.java110.intf.community.IRepairUserInnerServiceSMO;
|
|
|
+import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IOwnerInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
|
|
|
+import com.java110.po.owner.RepairUserPo;
|
|
|
+import com.java110.utils.constant.BusinessTypeConstant;
|
|
|
+import com.java110.utils.constant.ServiceCodeRepairDispatchStepConstant;
|
|
|
+import com.java110.utils.util.Assert;
|
|
|
+import com.java110.utils.util.DateUtil;
|
|
|
+import com.java110.vo.ResultVo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 强制回单
|
|
|
+ * add by wuxw 2019-06-30
|
|
|
+ */
|
|
|
+@Java110Listener("repairForceFinishListener")
|
|
|
+public class RepairForceFinishListener extends AbstractServiceApiPlusListener {
|
|
|
+
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(RepairForceFinishListener.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerRepairBMO ownerRepairBMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRepairUserInnerServiceSMO repairUserInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRepairInnerServiceSMO repairInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFileInnerServiceSMO fileInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMO;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerInnerServiceSMO ownerInnerServiceSMO;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
|
|
|
+ Assert.hasKeyAndValue(reqJson, "repairId", "未包含报修单信息");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "context", "未包含派单内容");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
|
+ String userId = reqJson.getString("userId");
|
|
|
+ String userName = reqJson.getString("userName");
|
|
|
+
|
|
|
+ RepairDto repairDto = new RepairDto();
|
|
|
+ repairDto.setRepairId(reqJson.getString("repairId"));
|
|
|
+ repairDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ repairDto.setState(RepairDto.STATE_TAKING);
|
|
|
+ List<RepairDto> repairDtos = repairInnerServiceSMOImpl.queryRepairs(repairDto);
|
|
|
+ Assert.listOnlyOne(repairDtos, "当前没有需要处理订单");
|
|
|
+
|
|
|
+ //查询正在处理 工单的师傅
|
|
|
+ RepairUserDto repairUserDto = new RepairUserDto();
|
|
|
+ repairUserDto.setRepairId(reqJson.getString("repairId"));
|
|
|
+ repairUserDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ repairUserDto.setState(RepairDto.STATE_TAKING);
|
|
|
+ List<RepairUserDto> repairUserDtos = repairUserInnerServiceSMOImpl.queryRepairUsers(repairUserDto);
|
|
|
+
|
|
|
+ if (repairUserDtos != null && repairUserDtos.size() > 0) {
|
|
|
+ // 1.0 关闭自己订单
|
|
|
+ RepairUserPo repairUserPo = new RepairUserPo();
|
|
|
+ repairUserPo.setRuId(repairUserDtos.get(0).getRuId());
|
|
|
+ repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
|
|
|
+ repairUserPo.setState(RepairUserDto.STATE_CLOSE);
|
|
|
+ repairUserPo.setContext(userName + " 强制回单");
|
|
|
+ repairUserPo.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ super.update(context, repairUserPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_REPAIR_USER);
|
|
|
+
|
|
|
+ repairUserPo = new RepairUserPo();
|
|
|
+ repairUserPo.setRuId("-1");
|
|
|
+ repairUserPo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
|
|
|
+ repairUserPo.setState(RepairUserDto.STATE_EVALUATE);
|
|
|
+ repairUserPo.setRepairId(reqJson.getString("repairId"));
|
|
|
+ repairUserPo.setPreStaffId(repairUserDtos.get(0).getStaffId());
|
|
|
+ repairUserPo.setPreStaffName(repairUserDtos.get(0).getStaffName());
|
|
|
+ repairUserPo.setStaffId(userId);
|
|
|
+ repairUserPo.setStaffName(userName);
|
|
|
+ repairUserPo.setPreRuId(repairUserDtos.get(0).getRuId());
|
|
|
+ repairUserPo.setRepairEvent(RepairUserDto.REPAIR_EVENT_AUDIT_USER);
|
|
|
+ repairUserPo.setContext("");
|
|
|
+ repairUserPo.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ super.insert(context, repairUserPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_REPAIR_USER);
|
|
|
+ }
|
|
|
+
|
|
|
+ reqJson.put("state", RepairDto.STATE_RETURN_VISIT);
|
|
|
+ ownerRepairBMOImpl.modifyBusinessRepairDispatch(reqJson, context, RepairDto.STATE_RETURN_VISIT);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity = ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK);
|
|
|
+ context.setResponseEntity(responseEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getServiceCode() {
|
|
|
+ return ServiceCodeRepairDispatchStepConstant.BINDING_REPAIR_FORCE_FINISH;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpMethod getHttpMethod() {
|
|
|
+ return HttpMethod.POST;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getOrder() {
|
|
|
+ return DEFAULT_ORDER;
|
|
|
+ }
|
|
|
+
|
|
|
+ public IRepairInnerServiceSMO getRepairInnerServiceSMOImpl() {
|
|
|
+ return repairInnerServiceSMOImpl;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRepairInnerServiceSMOImpl(IRepairInnerServiceSMO repairInnerServiceSMOImpl) {
|
|
|
+ this.repairInnerServiceSMOImpl = repairInnerServiceSMOImpl;
|
|
|
+ }
|
|
|
+}
|