|
@@ -2,6 +2,10 @@ package com.zcxk.rmcp.pay.service.impl.pay;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.zcxk.rmcp.api.dto.install.InstallPlanDataDto;
|
|
|
+import com.zcxk.rmcp.api.dto.install.InstallPlanInputDto;
|
|
|
+import com.zcxk.rmcp.api.feign.SyncDataClient;
|
|
|
import com.zcxk.rmcp.pay.commom.model.AjaxMessage;
|
|
|
import com.zcxk.rmcp.pay.commom.model.ResultStatus;
|
|
|
import com.zcxk.rmcp.pay.commom.util.HttpRequest;
|
|
@@ -16,13 +20,13 @@ import com.zcxk.rmcp.pay.dto.pay.InstallPlanDataDTO;
|
|
|
import com.zcxk.rmcp.pay.dto.pay.InstallPlanInputDTO;
|
|
|
import com.zcxk.rmcp.pay.dto.pay.PayBaseAccountDto;
|
|
|
import com.zcxk.rmcp.pay.entity.Community;
|
|
|
-import com.zcxk.rmcp.pay.entity.Customer;
|
|
|
import com.zcxk.rmcp.pay.entity.Device;
|
|
|
import com.zcxk.rmcp.pay.entity.WaterMeterReplaceLog;
|
|
|
import com.zcxk.rmcp.pay.service.CommunityService;
|
|
|
import com.zcxk.rmcp.pay.service.pay.PayBaseAccountService;
|
|
|
import com.zcxk.rmcp.pay.service.pay.PayBaseConfigService;
|
|
|
import com.zcxk.rmcp.pay.service.pay.PaySyncDataService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -40,6 +44,7 @@ import static com.google.common.collect.Lists.newArrayList;
|
|
|
* Created by ZJY on 2020-09-27 15:29
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
@Autowired
|
|
|
private CommunityService communityService;
|
|
@@ -58,6 +63,8 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
|
|
|
@Resource
|
|
|
WaterMeterReplaceLogMapper waterMeterReplaceLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private SyncDataClient syncDataClient;
|
|
|
|
|
|
@Override
|
|
|
public AjaxMessage<List<AreaDto>> getAllArea(){
|
|
@@ -120,7 +127,32 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
return waterMeterReplaceLogMapper.insertSelective(waterMeterReplaceLog);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private void setPayBaseAccount(PayBaseAccountDto payBaseAccountDto,InstallPlanInputDTO installPlanInput,
|
|
|
+ String code,String userAddress,String strAccountNumber,InstallPlanDataDTO installPlanDoor){
|
|
|
+ long accountid = idWorker.nextId();
|
|
|
+ payBaseAccountDto.setId(BigInteger.valueOf(accountid));
|
|
|
+ payBaseAccountDto.setCalculateway(installPlanInput.getCalculateway_id());
|
|
|
+ payBaseAccountDto.setWaterpropertyId(installPlanInput.getWaterproperty_id());
|
|
|
+ payBaseAccountDto.setCommunityCode(code);
|
|
|
+ payBaseAccountDto.setAddress(userAddress);
|
|
|
+
|
|
|
+ payBaseAccountDto.setAccountnumber(strAccountNumber);
|
|
|
+
|
|
|
+ //保存模板导入的信息
|
|
|
+ payBaseAccountDto.setRemarks(installPlanDoor.getRemark());
|
|
|
+ payBaseAccountDto.setTelephone(installPlanDoor.getTelephone());
|
|
|
+ payBaseAccountDto.setIdcardno(installPlanDoor.getIdcardno());
|
|
|
+ payBaseAccountDto.setName(installPlanDoor.getUserName());
|
|
|
+ }
|
|
|
+ private String getBuildName(InstallPlanInputDTO installPlanInput,InstallPlanDataDTO installPlanBuilding,InstallPlanDataDTO installPlanUnit){
|
|
|
+ String buildingName = "";
|
|
|
+ if (installPlanInput.getEnableUnit() == 1) {
|
|
|
+ buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋" + installPlanUnit.getName() + "单元";
|
|
|
+ } else {
|
|
|
+ buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋";
|
|
|
+ }
|
|
|
+ return buildingName;
|
|
|
+ }
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public AjaxMessage addJF(InstallPlanInputDTO installPlanInput,LoginUser excelLoginUser){
|
|
@@ -130,34 +162,9 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
//异步批量导入无法获取loginUser
|
|
|
loginUser = excelLoginUser;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- Integer siteId = 1;
|
|
|
- if (loginUser.getSiteType() == 1) {
|
|
|
- siteId = loginUser.getSiteId();
|
|
|
- }
|
|
|
installPlanInput.setPlatformType(2);
|
|
|
|
|
|
//取客户编号
|
|
|
- String customerNo= "";
|
|
|
- Customer customer= customerMapper.findById(loginUser.getCustomerId());
|
|
|
- if(customer != null && customer.getCustomerNo() != null){
|
|
|
- customerNo = customer.getCustomerNo();
|
|
|
- }
|
|
|
-
|
|
|
-/* //取客户编号
|
|
|
- String customerNo="";
|
|
|
- List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("CUSTOMER_NO",loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
- if(payBaseConfigDtos.size() == 1){
|
|
|
- for (PayBaseConfigDto item : payBaseConfigDtos){
|
|
|
- customerNo = item.getValue();
|
|
|
- installPlanInput.setCustomerNo(customerNo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(customerNo == "")
|
|
|
- throw new ServiceException(-900,"客户编号参数未配置"); //客户编号对应抄表系统中的customer_id*/
|
|
|
-
|
|
|
//1、小区
|
|
|
Integer communityId ;
|
|
|
String code = "001";
|
|
@@ -165,46 +172,16 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
String communityAndBuildingAndUnitAddress=""; //小区 楼栋 单元地址
|
|
|
String floorAddress="";
|
|
|
String doorAddress="";
|
|
|
- if (installPlanInput.getCommunityId() == null) {
|
|
|
- Community community = communityService.findByNameV2(siteId,installPlanInput.getProvince(),installPlanInput.getCity(),installPlanInput.getRegion(), installPlanInput.getCommunityName());
|
|
|
- if (community != null) {
|
|
|
- communityId=community.getId();
|
|
|
- installPlanInput.setCommunityId(community.getId());
|
|
|
- code =String.format("%03d",Integer.valueOf(community.getCode()));
|
|
|
- } else {
|
|
|
- Community newCommunity = new Community();
|
|
|
- //获取小区最大值,然后加1
|
|
|
- List<Community> communities = communityService.getMaxCodeBySiteId(siteId);
|
|
|
- if(communities.size()==1)
|
|
|
- {
|
|
|
- if (communities.get(0) != null) {
|
|
|
- code =String.format("%03d",Integer.valueOf(communities.get(0).getCode()));
|
|
|
- }else {
|
|
|
- code = String.format("%03d",Integer.valueOf("1"));
|
|
|
- }
|
|
|
- }
|
|
|
- newCommunity.setCode(code);
|
|
|
- newCommunity.setSiteId(siteId);
|
|
|
- newCommunity.setName(installPlanInput.getCommunityName());
|
|
|
- newCommunity.setProvince(installPlanInput.getProvince());
|
|
|
- newCommunity.setCity(installPlanInput.getCity());
|
|
|
- newCommunity.setRegion(installPlanInput.getRegion());
|
|
|
- newCommunity.setAddress(installPlanInput.getAdrress());
|
|
|
- newCommunity.setCustomerId(installPlanInput.getCustomerId());
|
|
|
- newCommunity.setStatus(1);
|
|
|
- communityService.insert(newCommunity);
|
|
|
- communityId=newCommunity.getId();
|
|
|
- //installPlanInput.setCommunityId(newCommunity.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- communityId=installPlanInput.getCommunityId();
|
|
|
- Community community = communityService.findById(installPlanInput.getCommunityId());
|
|
|
- code =String.format("%03d",Integer.valueOf(community.getCode()));
|
|
|
- }
|
|
|
-
|
|
|
- //将小区置空,因为抄表系统小区与本系统中小区不一定要同
|
|
|
- installPlanInput.setCommunityId(null);
|
|
|
+ communityId=installPlanInput.getCommunityId();
|
|
|
+ Community community = communityService.findById(installPlanInput.getCommunityId());
|
|
|
+ String commuintyCode=community.getCode();
|
|
|
+ code =String.format("%03d",Integer.valueOf(commuintyCode));
|
|
|
+ String tenantId = loginUser.getTenantId();
|
|
|
+ Integer companyId = loginUser.getCompanyId();
|
|
|
+ Integer departmentId = loginUser.getDepartmentId();
|
|
|
+ installPlanInput.setTenantId(tenantId);
|
|
|
+ installPlanInput.setCompanyOrgId(companyId);
|
|
|
+ installPlanInput.setDeptOrgId(departmentId);
|
|
|
|
|
|
//取当前小区最大客户编号
|
|
|
int maxAccountNumber = payBaseAccountService.getMaxAccountNumber(code);
|
|
@@ -220,13 +197,9 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
for (InstallPlanDataDTO installPlanUnit : installPlanBuilding.getChildren()) {
|
|
|
|
|
|
//判断是否启动单元
|
|
|
- String buildingName = "";
|
|
|
- if (installPlanInput.getEnableUnit() == 1) {
|
|
|
- buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋" + installPlanUnit.getName() + "单元";
|
|
|
- } else {
|
|
|
- buildingName = installPlanInput.getCommunityName() + installPlanBuilding.getName() + "栋";
|
|
|
- }
|
|
|
- communityAndBuildingAndUnitAddress = buildingName;
|
|
|
+
|
|
|
+ communityAndBuildingAndUnitAddress = getBuildName(installPlanInput,installPlanBuilding,
|
|
|
+ installPlanUnit);
|
|
|
|
|
|
|
|
|
//安装楼层
|
|
@@ -237,29 +210,15 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
//安装清单
|
|
|
if (installPlanFloor.getChildren() != null && installPlanFloor.getChildren().size() > 0) {
|
|
|
for (InstallPlanDataDTO installPlanDoor : installPlanFloor.getChildren()) {
|
|
|
-
|
|
|
- //添加客户信息(水表用户)
|
|
|
- doorAddress = (installPlanDoor.getName());
|
|
|
- long accountid = idWorker.nextId();
|
|
|
- PayBaseAccountDto payBaseAccountDto = new PayBaseAccountDto();
|
|
|
- payBaseAccountDto.setId(BigInteger.valueOf(accountid));
|
|
|
- payBaseAccountDto.setCalculateway(installPlanInput.getCalculateway_id());
|
|
|
- if (installPlanInput.getWaterproperty_id() != null)
|
|
|
- payBaseAccountDto.setWaterpropertyId(installPlanInput.getWaterproperty_id());
|
|
|
- else
|
|
|
- payBaseAccountDto.setWaterpropertyId(null);
|
|
|
- payBaseAccountDto.setCommunityCode(code);
|
|
|
- payBaseAccountDto.setAddress(communityAndBuildingAndUnitAddress + floorAddress + doorAddress);
|
|
|
-
|
|
|
++maxAccountNumber;
|
|
|
String strAccountNumber = String.format("%s%07d", code, (maxAccountNumber));
|
|
|
- payBaseAccountDto.setAccountnumber(strAccountNumber);
|
|
|
+ //添加客户信息(水表用户)
|
|
|
+ doorAddress = (installPlanDoor.getName());
|
|
|
+ String userAddress=communityAndBuildingAndUnitAddress + floorAddress + doorAddress;
|
|
|
|
|
|
- //保存模板导入的信息
|
|
|
- payBaseAccountDto.setRemarks(installPlanDoor.getRemark());
|
|
|
- payBaseAccountDto.setTelephone(installPlanDoor.getTelephone());
|
|
|
- payBaseAccountDto.setIdcardno(installPlanDoor.getIdcardno());
|
|
|
- payBaseAccountDto.setName(installPlanDoor.getUserName());
|
|
|
+ PayBaseAccountDto payBaseAccountDto = new PayBaseAccountDto();
|
|
|
+ setPayBaseAccount(payBaseAccountDto,installPlanInput,code,userAddress,
|
|
|
+ strAccountNumber,installPlanDoor);
|
|
|
accountLists.add(payBaseAccountDto);
|
|
|
|
|
|
|
|
@@ -268,13 +227,12 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
Device device = new Device();
|
|
|
device.setId(deviceId);
|
|
|
device.setCommunityId(communityId);
|
|
|
-
|
|
|
+ device.setTenantId(tenantId);
|
|
|
+ device.setDeptOrgId(departmentId);
|
|
|
+ device.setCompanyOrgId(companyId);
|
|
|
device.setAccountId(payBaseAccountDto.getId());
|
|
|
- device.setSiteId(loginUser.getSiteId());
|
|
|
- device.setCustomerId(loginUser.getCustomerId());
|
|
|
device.setCurrStatus(0);
|
|
|
device.setStatus(1);
|
|
|
-
|
|
|
if(StringUtils.isBlank(installPlanDoor.getFileNo())){
|
|
|
installPlanDoor.setFileNo(strAccountNumber+"01");
|
|
|
device.setMetercode(payBaseAccountDto.getAccountnumber()+"01");
|
|
@@ -282,8 +240,6 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
else {
|
|
|
device.setMetercode(installPlanDoor.getFileNo());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
deviceList.add(device);
|
|
|
}
|
|
|
}
|
|
@@ -294,28 +250,56 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
|
|
|
}
|
|
|
|
|
|
//调用接口
|
|
|
- String url = SyncUrl + "/api/syncData/syncPlan";
|
|
|
+
|
|
|
try {
|
|
|
installPlanInput.setCustomerId(null);
|
|
|
- installPlanInput.setCustomerNo(new Integer(customerNo)); //传客户编号
|
|
|
- String json = JacksonUtil.obj2String(installPlanInput);
|
|
|
- String result = HttpRequest.doPost(url,json);
|
|
|
- AjaxMessage ajaxMessage = JacksonUtil.string2Obj(result,AjaxMessage.class);
|
|
|
- if(ajaxMessage != null && ajaxMessage.getStatus() == 0){
|
|
|
|
|
|
- //生成用户信息和预存账户
|
|
|
- accountLists.get(0).setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
- accountLists.get(0).setCustomerId(BigInteger.valueOf(loginUser.getCurrentSiteId()));
|
|
|
+ String installStr = JSONObject.toJSONString(installPlanInput);
|
|
|
+ InstallPlanInputDto installPlanInputDto=JSONObject.parseObject(installStr,InstallPlanInputDto.class);
|
|
|
+ InstallPlanInputDto dto = new InstallPlanInputDto();
|
|
|
+ dto.setTenantId("487170559310123008");
|
|
|
+ dto.setPlanName("测试");
|
|
|
+ dto.setCommunityId(10);
|
|
|
+ dto.setCompanyOrgId(443);
|
|
|
+ dto.setDeptOrgId(0);
|
|
|
+ dto.setProductId(1);
|
|
|
+ dto.setUnit("单元");
|
|
|
+ dto.setPrincipal("");
|
|
|
+ dto.setPhone("18588888888");
|
|
|
+ dto.setEnableUnit(0);
|
|
|
+ dto.setRemark("");
|
|
|
+ dto.setAdrress("地址");
|
|
|
+
|
|
|
+ InstallPlanDataDto b = new InstallPlanDataDto("建筑1");
|
|
|
|
|
|
- payBaseAccountService.batchInsert(accountLists, code,null);
|
|
|
+ InstallPlanDataDto u = new InstallPlanDataDto("单元1");
|
|
|
+ b.setChildren(Lists.newArrayList(u));
|
|
|
+
|
|
|
+ InstallPlanDataDto f = new InstallPlanDataDto("楼层1");
|
|
|
+ u.setChildren(Lists.newArrayList(f));
|
|
|
+
|
|
|
+ InstallPlanDataDto a = new InstallPlanDataDto("A1111","846164169");
|
|
|
+ f.setChildren(Lists.newArrayList(a));
|
|
|
+
|
|
|
+
|
|
|
+ syncDataClient.syncPlan(dto);
|
|
|
+ //syncDataClient.syncPlan(installPlanInputDto);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //payBaseAccountService.batchInsert(accountLists, code,null);
|
|
|
|
|
|
//生成水表信息(sc_device表)
|
|
|
- deviceMapper.insertList(deviceList);
|
|
|
+ //deviceMapper.insertList(deviceList);
|
|
|
+
|
|
|
+ return new AjaxMessage(ResultStatus.OK);
|
|
|
|
|
|
- return ajaxMessage;
|
|
|
- }
|
|
|
}
|
|
|
catch (Exception e){
|
|
|
+ log.error("同步安装计划失败",e);
|
|
|
return new AjaxMessage(ResultStatus.ERROR);
|
|
|
}
|
|
|
}
|