UpdateFeeOwnerInfoAdapt.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.java110.job.adapt.fee;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.java110.entity.order.Business;
  5. import com.java110.job.adapt.DatabusAdaptImpl;
  6. import com.java110.job.adapt.fee.asyn.IUpdateFeeOwnerInfo;
  7. import com.java110.po.owner.OwnerPo;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Component;
  10. import java.util.List;
  11. /**
  12. * 修改业主时 刷新费用信息
  13. *
  14. * @ClassName UpdateFeeOwnerInfoAdapt
  15. * @Description TODO
  16. * @Author wuxw
  17. * @Date 2021/10/7 20:50
  18. * @Version 1.0
  19. * add by wuxw 2021/10/7
  20. **/
  21. @Component(value = "updateFeeOwnerInfoAdapt")
  22. public class UpdateFeeOwnerInfoAdapt extends DatabusAdaptImpl {
  23. @Autowired
  24. private IUpdateFeeOwnerInfo updateFeeOwnerInfoImpl;
  25. /**
  26. * accessToken={access_token}
  27. * &extCommunityUuid=01000
  28. * &extCommunityId=1
  29. * &devSn=111111111
  30. * &name=设备名称
  31. * &positionType=0
  32. * &positionUuid=1
  33. *
  34. * @param business 当前处理业务
  35. * @param businesses 所有业务信息
  36. */
  37. @Override
  38. public void execute(Business business, List<Business> businesses) {
  39. JSONObject data = business.getData();
  40. if (data.containsKey(OwnerPo.class.getSimpleName())) {
  41. Object bObj = data.get(OwnerPo.class.getSimpleName());
  42. JSONArray businessMachines = null;
  43. if (bObj instanceof JSONObject) {
  44. businessMachines = new JSONArray();
  45. businessMachines.add(bObj);
  46. } else if (bObj instanceof List) {
  47. businessMachines = JSONArray.parseArray(JSONObject.toJSONString(bObj));
  48. } else {
  49. businessMachines = (JSONArray) bObj;
  50. }
  51. for (int bOwnerIndex = 0; bOwnerIndex < businessMachines.size(); bOwnerIndex++) {
  52. JSONObject businessOwner = businessMachines.getJSONObject(bOwnerIndex);
  53. doOwnerInfo(business, businessOwner);
  54. }
  55. }else {
  56. if (data instanceof JSONObject) {
  57. doOwnerInfo(business, data);
  58. }
  59. }
  60. }
  61. private void doOwnerInfo(Business business, JSONObject businessOwner) {
  62. updateFeeOwnerInfoImpl.doUpdate(business, businessOwner);
  63. }
  64. }