|
@@ -9,8 +9,8 @@ import com.bz.smart_city.dao.pay.PayMessagetemplateMapper;
|
|
|
import com.bz.smart_city.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
|
|
|
import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
|
|
|
import com.bz.smart_city.entity.Customer;
|
|
|
+import com.bz.smart_city.entity.Device;
|
|
|
import com.bz.smart_city.entity.SyncValveResult;
|
|
|
-import com.bz.smart_city.entity.SyncValveSend;
|
|
|
import com.bz.smart_city.entity.pay.PayControlRecord;
|
|
|
import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
|
|
|
import com.bz.smart_city.quartz.entity.QuartzEntity;
|
|
@@ -21,18 +21,10 @@ import com.bz.smart_city.service.pay.PayControlRecordService;
|
|
|
import com.bz.smart_city.service.pay.PayControlRuleService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.util.LinkedMultiValueMap;
|
|
|
-import org.springframework.util.MultiValueMap;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigInteger;
|
|
@@ -143,78 +135,90 @@ public class ControlDayServiceImpl implements ControlDayService, InitializingBea
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void start(int flag,BigInteger siteId,BigInteger customerId){
|
|
|
PayBaseCustomerandmeterrela customer = new PayBaseCustomerandmeterrela();
|
|
|
customer.setCustomerId(customerId);
|
|
|
customer.setSiteId(siteId);
|
|
|
List<PayBaseCustomerandmeterrela> payBaseCustomerandmeterrelaList = payBaseCustomerandmeterrelaMapper.findList(customer);
|
|
|
if(payBaseCustomerandmeterrelaList.size() > 0){
|
|
|
-
|
|
|
Customer customerNo = customerMapper.findById(customer.getCustomerId().intValue());
|
|
|
+ List<Integer> filterId = new ArrayList<>();
|
|
|
+ filterId.add(1);
|
|
|
+ filterId.add(3);
|
|
|
+ filterId.add(7);
|
|
|
for (PayBaseCustomerandmeterrela one: payBaseCustomerandmeterrelaList){
|
|
|
- String[] deviceType = StringUtils.split(one.getValveRuleId(),",");
|
|
|
- String[] deviceTypeName = StringUtils.split(one.getValveRuleName(),",");
|
|
|
- //循环用户关联的所有阀控规则
|
|
|
- Integer ControlResult = null;
|
|
|
- if(deviceType != null ){
|
|
|
- for (int i=0;i<deviceType.length;i++){
|
|
|
- //result执行动作,0关阀 1开阀
|
|
|
- List<Integer> filterId = new ArrayList<>();
|
|
|
- filterId.add(2);
|
|
|
- filterId.add(4);
|
|
|
- filterId.add(5);
|
|
|
- Integer result = payControlRuleService.GetConditionReusl(new Integer(deviceType[i]),one.getAccountId().toString(),flag,filterId);
|
|
|
- if(result != null){
|
|
|
- try {
|
|
|
- //后面规则执行动作与前面一样不操作
|
|
|
- if(ControlResult == result.intValue())
|
|
|
- continue;
|
|
|
- ControlResult = result;
|
|
|
-
|
|
|
- //最近一次阀控动作如果与当前一致则不操作
|
|
|
- PayControlRecord payControlRecordTemp = new PayControlRecord();
|
|
|
- payControlRecordTemp.setAccountId(one.getAccountId());
|
|
|
- PayControlRecord payControlRecordLast = payControlRecordService.getRecord(payControlRecordTemp);
|
|
|
- if(payControlRecordLast != null){
|
|
|
- if(payControlRecordLast.getType().intValue() == result){
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //执行动作与阀门当前状态一致不操作
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //调用阀门接口
|
|
|
- String url=SyncUrl + "/api/platform/sendCommond";
|
|
|
- String params = String.format("?customerNo=%s&meterNo=%s&type=%s",customerNo.getCustomerNo(),one.getMetercode(),result.toString());
|
|
|
- url += params;
|
|
|
- String postResult = HttpRequest.doPost(url ,"");
|
|
|
- SyncValveResult syncValveResult = JacksonUtil.string2Obj(postResult, SyncValveResult.class);
|
|
|
- Integer getResult = Integer.parseInt(syncValveResult.getStatus());
|
|
|
- if(getResult != null && getResult == 0){
|
|
|
- //插入数据库
|
|
|
- PayControlRecord payControlRecord = new PayControlRecord();
|
|
|
- payControlRecord.setAccountId(one.getAccountId());
|
|
|
- payControlRecord.setMeterId(one.getWatermeterId());
|
|
|
- payControlRecord.setType(result);
|
|
|
- payControlRecord.setControlRuleId(new Integer(deviceType[i]));
|
|
|
- payControlRecord.setControlRuleIdName(deviceTypeName[i]);
|
|
|
- payControlRecord.setDelFlag("0");
|
|
|
- payControlRecord.setCustomerId(customer.getCustomerId());
|
|
|
- payControlRecord.setSiteId(customer.getSiteId());
|
|
|
- payControlRecord.setCreateDate(LocalDateTime.now());
|
|
|
- payControlRecordMapper.add(payControlRecord);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ sendValve(customerNo.getCustomerNo(),flag,filterId,one);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param customerNo 客户编号
|
|
|
+ * @param flag 阀门动作
|
|
|
+ * @param ConditionIds 阀控条件
|
|
|
+ * @param one 开户信息
|
|
|
+ */
|
|
|
+ public void sendValve(String customerNo,int flag,List<Integer> ConditionIds,PayBaseCustomerandmeterrela one){
|
|
|
+
|
|
|
+ String[] deviceType = StringUtils.split(one.getValveRuleId(),",");
|
|
|
+ String[] deviceTypeName = StringUtils.split(one.getValveRuleName(),",");
|
|
|
+ //循环用户关联的所有阀控规则
|
|
|
+ Integer ControlResult = null;
|
|
|
+ if(deviceType != null ){
|
|
|
+ for (int i=0;i<deviceType.length;i++){
|
|
|
+ //result执行动作,0关阀 1开阀
|
|
|
+ Integer result = payControlRuleService.GetConditionReusl(new Integer(deviceType[i]),one.getAccountId().toString(),flag,ConditionIds);
|
|
|
+ if(result != null){
|
|
|
+ try {
|
|
|
+ //后面规则执行动作与前面一样不操作
|
|
|
+ if(ControlResult == result.intValue())
|
|
|
+ continue;
|
|
|
+ ControlResult = result;
|
|
|
+
|
|
|
+ //最近一次阀控动作如果与当前一致则不操作
|
|
|
+ PayControlRecord payControlRecordTemp = new PayControlRecord();
|
|
|
+ payControlRecordTemp.setAccountId(one.getAccountId());
|
|
|
+ PayControlRecord payControlRecordLast = payControlRecordService.getRecord(payControlRecordTemp);
|
|
|
+ if(payControlRecordLast != null){
|
|
|
+ if(payControlRecordLast.getType().intValue() == result){
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //执行动作与阀门当前状态一致不操作
|
|
|
+ Device device = payControlRuleService.findDevice(one.getWatermeterId());
|
|
|
+ if(device != null && device.getControlStatus() != null){
|
|
|
+ if(device.getControlStatus().intValue() == result)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //调用阀门接口
|
|
|
+ String url=SyncUrl + "/api/platform/sendCommond";
|
|
|
+ String params = String.format("?customerNo=%s&meterNo=%s&type=%s",customerNo,one.getMetercode(),result.toString());
|
|
|
+ url += params;
|
|
|
+ String postResult = HttpRequest.doPost(url ,"");
|
|
|
+ SyncValveResult syncValveResult = JacksonUtil.string2Obj(postResult, SyncValveResult.class);
|
|
|
+ Integer getResult = Integer.parseInt(syncValveResult.getStatus());
|
|
|
+ if(getResult != null && getResult == 0){
|
|
|
+ //插入数据库
|
|
|
+ PayControlRecord payControlRecord = new PayControlRecord();
|
|
|
+ payControlRecord.setAccountId(one.getAccountId());
|
|
|
+ payControlRecord.setMeterId(one.getWatermeterId());
|
|
|
+ payControlRecord.setType(result);
|
|
|
+ payControlRecord.setControlRuleId(new Integer(deviceType[i]));
|
|
|
+ payControlRecord.setControlRuleIdName(deviceTypeName[i]);
|
|
|
+ payControlRecord.setDelFlag("0");
|
|
|
+ payControlRecord.setCustomerId(one.getCustomerId());
|
|
|
+ payControlRecord.setSiteId(one.getSiteId());
|
|
|
+ payControlRecord.setCreateDate(LocalDateTime.now());
|
|
|
+ payControlRecordMapper.add(payControlRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|