LAPTOP-FO2T5SIU\35838 7 mesi fa
parent
commit
0fccbb60a9

+ 2 - 0
pro-base/src/main/java/com/idea/buildManage/mapper/MnpBuildingExtendMapper.java

@@ -17,4 +17,6 @@ public interface MnpBuildingExtendMapper {
 
     List<MnpBuilding> selectByContractId(String contractId);
 
+    List<MnpBuilding> selectNeedSendList();
+
 }

+ 3 - 0
pro-base/src/main/java/com/idea/buildManage/mapper/ParkRoomExtendMapper.java

@@ -20,5 +20,8 @@ public interface ParkRoomExtendMapper {
 
     List<ParkRoomResponse> getFullNames(List<String> houseIds);
 
+    List<ParkRoom> selectNeedSendList();
+
+
 
 }

+ 40 - 35
pro-base/src/main/java/com/idea/buildManage/service/MnpBuildingService.java

@@ -247,30 +247,30 @@ public class MnpBuildingService implements BaseService<MnpBuilding, MnpBuildingE
         record.setId(id);
         int result = insertWithoutId(record);
 
-        try {
-            JSONObject json = new JSONObject();
-            json.put("srcsystemid", id);
-            json.put("code", id);
-            json.put("name", record.getBuildNum());
-            json.put("pk_org", InvoiceUtil.pk_org);
-            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_build);
-            // 给nc推送载体数据
-            String resultJson = InvoiceUtil.defdocAdd(json);
-            JSONObject jsonObject = JSONObject.parseObject(resultJson);
-            String success = jsonObject.getString("success");
-            if (success.equals("true")) {
-                JSONObject data = jsonObject.getJSONObject("data");
-                String code = data.getString("code");
-                String ncid = data.getString("ncid");
-                MnpBuilding model = new MnpBuilding();
-                model.setId(id);
-                model.setNcid(ncid);
-                model.setNcCode(code);
-                updateByPrimaryKeySelective(model);
-            }
-        } catch (Exception e) {
-            log.error("推送载体失败:{}", e);
-        }
+//        try {
+//            JSONObject json = new JSONObject();
+//            json.put("srcsystemid", id);
+//            json.put("code", id);
+//            json.put("name", record.getBuildNum());
+//            json.put("pk_org", InvoiceUtil.pk_org);
+//            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_build);
+//            // 给nc推送载体数据
+//            String resultJson = InvoiceUtil.defdocAdd(json);
+//            JSONObject jsonObject = JSONObject.parseObject(resultJson);
+//            String success = jsonObject.getString("success");
+//            if (success.equals("true")) {
+//                JSONObject data = jsonObject.getJSONObject("data");
+//                String code = data.getString("code");
+//                String ncid = data.getString("ncid");
+//                MnpBuilding model = new MnpBuilding();
+//                model.setId(id);
+//                model.setNcid(ncid);
+//                model.setNcCode(code);
+//                updateByPrimaryKeySelective(model);
+//            }
+//        } catch (Exception e) {
+//            log.error("推送载体失败", e);
+//        }
 
         return result;
     }
@@ -279,20 +279,25 @@ public class MnpBuildingService implements BaseService<MnpBuilding, MnpBuildingE
 
         int result = updateByPrimaryKeySelective(model);
 
-        try {
-            MnpBuilding building = selectByPrimaryKey(model.getId());
-            JSONObject json = new JSONObject();
-            json.put("ncid", building.getNcid());
-            json.put("code", building.getNcCode());
-            json.put("name", building.getBuildNum());
-            // 给nc推送修改载体数据
-            InvoiceUtil.defdocUpdate(json);
-        }catch (Exception e){
-            log.error("推送修改载体失败:{}",e);
-        }
+//        try {
+//            MnpBuilding building = selectByPrimaryKey(model.getId());
+//            JSONObject json = new JSONObject();
+//            json.put("ncid", building.getNcid());
+//            json.put("code", building.getNcCode());
+//            json.put("name", building.getBuildNum());
+//            // 给nc推送修改载体数据
+//            InvoiceUtil.defdocUpdate(json);
+//        }catch (Exception e){
+//            log.error("推送修改载体失败",e);
+//        }
 
         return result;
     }
 
+    public List<MnpBuilding> selectNeedSendList(){
+        return extendMapper.selectNeedSendList();
+    }
+
+
 
 }

+ 44 - 40
pro-base/src/main/java/com/idea/buildManage/service/ParkRoomService.java

@@ -159,17 +159,17 @@ public class ParkRoomService implements BaseService<ParkRoom, ParkRoomExample> {
 
         model.setUpdatedAt(new Date());
         model.setUpdatedId(ShiroUtils.getUserId());
-        try {
-            ParkRoom parkRoom = selectByPrimaryKey(model.getId());
-            JSONObject json = new JSONObject();
-            json.put("ncid", parkRoom.getNcid());
-            json.put("code", parkRoom.getNcCode());
-            json.put("name", parkRoom.getRoomNo());
-            // 给nc推送修改载体数据
-            InvoiceUtil.defdocUpdate(json);
-        }catch (Exception e){
-            log.error("推送修改房间失败:{}",e);
-        }
+//        try {
+//            ParkRoom parkRoom = selectByPrimaryKey(model.getId());
+//            JSONObject json = new JSONObject();
+//            json.put("ncid", parkRoom.getNcid());
+//            json.put("code", parkRoom.getNcCode());
+//            json.put("name", parkRoom.getRoomNo());
+//            // 给nc推送修改载体数据
+//            InvoiceUtil.defdocUpdate(json);
+//        }catch (Exception e){
+//            log.error("推送修改房间失败",e);
+//        }
         return updateByPrimaryKeySelective(model);
     }
 
@@ -300,39 +300,43 @@ public class ParkRoomService implements BaseService<ParkRoom, ParkRoomExample> {
         record.setOrderNum(orderNum);
         int result = insertWithoutId(record);
 
-        try {
-            ParkInfo parkInfo = parkInfoService.selectByPrimaryKey(record.getGroupId());
-            ParkFloorDisc parkFloorDisc = floorDiscService.selectByPrimaryKey(record.getDiscId());
-            MnpBuilding mnpBuilding = buildingService.selectByPrimaryKey(record.getBuildId());
-            String name = parkInfo.getGroupName() + "-" + parkFloorDisc.getName() + "-" + mnpBuilding.getBuildNum()
-                    + "-" + record.getRoomNo();
-            JSONObject json = new JSONObject();
-            json.put("srcsystemid", id);
-            json.put("code", id);
-            json.put("name", name);
-            json.put("pk_org", InvoiceUtil.pk_org);
-            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_room);
-            // 给nc推送房间数据
-            String resultJson = InvoiceUtil.defdocAdd(json);
-            JSONObject jsonObject = JSONObject.parseObject(resultJson);
-            String success = jsonObject.getString("success");
-            if (success.equals("true")) {
-                JSONObject data = jsonObject.getJSONObject("data");
-                String code = data.getString("code");
-                String ncid = data.getString("ncid");
-                ParkRoom model = new ParkRoom();
-                model.setId(id);
-                model.setNcid(ncid);
-                model.setNcCode(code);
-                updateByPrimaryKeySelective(model);
-            }
-        } catch (Exception e) {
-            log.error("推送房间失败:{}", e);
-        }
+//        try {
+//            ParkInfo parkInfo = parkInfoService.selectByPrimaryKey(record.getGroupId());
+//            ParkFloorDisc parkFloorDisc = floorDiscService.selectByPrimaryKey(record.getDiscId());
+//            MnpBuilding mnpBuilding = buildingService.selectByPrimaryKey(record.getBuildId());
+//            String name = parkInfo.getGroupName() + "-" + parkFloorDisc.getName() + "-" + mnpBuilding.getBuildNum()
+//                    + "-" + record.getRoomNo();
+//            JSONObject json = new JSONObject();
+//            json.put("srcsystemid", id);
+//            json.put("code", id);
+//            json.put("name", name);
+//            json.put("pk_org", InvoiceUtil.pk_org);
+//            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_room);
+//            // 给nc推送房间数据
+//            String resultJson = InvoiceUtil.defdocAdd(json);
+//            JSONObject jsonObject = JSONObject.parseObject(resultJson);
+//            String success = jsonObject.getString("success");
+//            if (success.equals("true")) {
+//                JSONObject data = jsonObject.getJSONObject("data");
+//                String code = data.getString("code");
+//                String ncid = data.getString("ncid");
+//                ParkRoom model = new ParkRoom();
+//                model.setId(id);
+//                model.setNcid(ncid);
+//                model.setNcCode(code);
+//                updateByPrimaryKeySelective(model);
+//            }
+//        } catch (Exception e) {
+//            log.error("推送房间失败", e);
+//        }
         return result;
 
     }
 
+    public List<ParkRoom> selectNeedSendList(){
+        return extendMapper.selectNeedSendList();
+    }
+
 
 
 }

+ 2 - 0
pro-base/src/main/java/com/idea/customerManagement/dto/CustomerManagementDto.java

@@ -25,4 +25,6 @@ public class CustomerManagementDto extends CustomerManagement {
 
     private List<String> discIdList;
 
+    private String identityCard;
+
 }

+ 1 - 0
pro-base/src/main/java/com/idea/customerManagement/mapper/CustomerManagementExtendMapper.java

@@ -11,6 +11,7 @@ public interface CustomerManagementExtendMapper {
 
     List<CustomerManagementDto> listByModel(CustomerManagementDto record);
 
+    List<CustomerManagementDto> selectNeedSendList();
 
 
 

+ 69 - 40
pro-base/src/main/java/com/idea/customerManagement/service/CustomerManagementService.java

@@ -192,33 +192,46 @@ public class CustomerManagementService implements BaseService<CustomerManagement
         model.setStatus(1);
         model.setCreatedAt(date);
         model.setCreatedId(userId);
+        int result = insertWithOutId(model);
+
+//        try {
+//            Buyer buyer = buyers.get(0);
+//            // 给nc推送客户数据
+//            JSONObject json = new JSONObject();
+//            json.put("srcsystemid", id);
+//            json.put("name", buyer.getName());
+//            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
+//            json.put("custprop", "0");//财务组织客户类型,必选,默认0
+//            json.put("taxpayerid", buyer.getIdentityCard()); //统一社会信用代码,必选
+//            String resultJson = InvoiceUtil.customerAdd(json);
+//            JSONObject jsonObject = JSONObject.parseObject(resultJson);
+//            String success = jsonObject.getString("success");
+//            if (success.equals("true")) {
+//                JSONObject data = jsonObject.getJSONObject("data");
+//                String code = data.getString("code");
+//                String ncid = data.getString("ncid");
+//                CustomerManagement record = new CustomerManagement();
+//                record.setId(id);
+//                record.setNcid(ncid);
+//                record.setNcCode(code);
+//                updateByPrimaryKeySelective(record);
+//            }
+//        }catch (Exception e){
+//            log.error("推送客户失败",e);
+//        }
+//
+//        try {
+//            Buyer buyer = buyers.get(0);
+//            // 客户分配
+//            JSONObject json = new JSONObject();
+//            json.put("pk_org", InvoiceUtil.pk_org);
+//            json.put("ncid", buyer.getIdentityCard());
+//            InvoiceUtil.customerAssign(json);
+//        }catch (Exception e){
+//            log.error("客户分配失败",e);
+//        }
 
-        try {
-            Buyer buyer = buyers.get(0);
-            // 给nc推送客户数据
-            JSONObject json = new JSONObject();
-            json.put("srcsystemid", id);
-            json.put("name", buyer.getName());
-            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
-            json.put("custprop", "0");//财务组织客户类型,必选,默认0
-            json.put("taxpayerid", buyer.getIdentityCard()); //统一社会信用代码,必选
-            InvoiceUtil.customerAdd(json);
-        }catch (Exception e){
-            log.error("推送客户失败:{}",e);
-        }
-
-        try {
-            Buyer buyer = buyers.get(0);
-            // 客户分配
-            JSONObject json = new JSONObject();
-            json.put("pk_org", InvoiceUtil.pk_org);
-            json.put("ncid", buyer.getIdentityCard());
-            InvoiceUtil.customerAssign(json);
-        }catch (Exception e){
-            log.error("客户分配失败:{}",e);
-        }
-
-        return insertWithOutId(model);
+        return result;
 
     }
 
@@ -272,20 +285,32 @@ public class CustomerManagementService implements BaseService<CustomerManagement
         model.setUpdatedAt(date);
         model.setUpdatedId(userId);
 
-        try {
-            Buyer oldBuyer = oldBuyers.get(0);
-            Buyer newBuyer = buyers.get(0);
-            // 修改客户数据
-            JSONObject json = new JSONObject();
-            json.put("ncid", oldBuyer.getIdentityCard());// 客户统一信用代码,必选
-            json.put("name", newBuyer.getName());
-            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
-            json.put("custprop", "0");//财务组织客户类型,必选,默认0
-            json.put("taxpayerid", newBuyer.getIdentityCard()); //统一社会信用代码,必选
-            InvoiceUtil.customerUpdate(json);
-        }catch (Exception e){
-            log.error("修改客户失败:{}",e);
-        }
+//        try {
+//            Buyer oldBuyer = oldBuyers.get(0);
+//            Buyer newBuyer = buyers.get(0);
+//            // 修改客户数据
+//            JSONObject json = new JSONObject();
+//            json.put("ncid", oldBuyer.getIdentityCard());// 客户统一信用代码,必选
+//            json.put("name", newBuyer.getName());
+//            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
+//            json.put("custprop", "0");//财务组织客户类型,必选,默认0
+//            json.put("taxpayerid", newBuyer.getIdentityCard()); //统一社会信用代码,必选
+//            String resultJson = InvoiceUtil.customerUpdate(json);
+//            JSONObject jsonObject = JSONObject.parseObject(resultJson);
+//            String success = jsonObject.getString("success");
+//            if (success.equals("true")) {
+//                JSONObject data = jsonObject.getJSONObject("data");
+//                String code = data.getString("code");
+//                String ncid = data.getString("ncid");
+//                CustomerManagement record = new CustomerManagement();
+//                record.setId(id);
+//                record.setNcid(ncid);
+//                record.setNcCode(code);
+//                updateByPrimaryKeySelective(record);
+//            }
+//        }catch (Exception e){
+//            log.error("修改客户失败",e);
+//        }
 
         return updateByPrimaryKeySelective(model);
 
@@ -684,4 +709,8 @@ public class CustomerManagementService implements BaseService<CustomerManagement
     }
 
 
+    public List<CustomerManagementDto> selectNeedSendList(){
+        return extendMapper.selectNeedSendList();
+    }
+
 }

+ 30 - 30
pro-base/src/main/java/com/idea/invoice/service/InvoiceManageService.java

@@ -401,7 +401,6 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
 //        String identityCard = buyer.getIdentityCard();
         int invoiceTax = Integer.parseInt(model.getInvoiceTax()) * 100;
 
-
         JSONObject json = new JSONObject();
 
         JSONObject ar_recbill = new JSONObject();
@@ -435,27 +434,27 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         ar_recitem.add(ar_recitemJson);
         json.put("ar_recitem", ar_recitem);
 
-        String result = "";
         try {
-            result = InvoiceUtil.recbillAdd(json);
+            String result = InvoiceUtil.recbillAdd(json);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            String success = jsonObject.getString("success");
+            if (success.equals("true")) {
+                String code = jsonObject.getJSONObject("data").getJSONObject("ar_recbill").getString("code");
+                model.setSendStatus("1");
+                model.setSubmitTime(new Date());
+                model.setSubmitUser(ShiroUtils.getUserId());
+                model.setNcJson(result);
+                model.setNcCode(code);
+                updateByPrimaryKeySelective(model);
+                return AjaxResult.success();
+            } else if (success.equals("false")) {
+                return AjaxResult.error(jsonObject.getString("message"));
+            }
         } catch (Exception e) {
-            log.error("推送发票失败:{}", e);
+            log.error("推送发票失败", e);
             return AjaxResult.error(e.getMessage());
         }
-        JSONObject jsonObject = JSONObject.parseObject(result);
-        String success = jsonObject.getString("success");
-        if (success.equals("true")) {
-            String code = jsonObject.getJSONObject("data").getJSONObject("ar_recbill").getString("code");
-            model.setSendStatus("1");
-            model.setSubmitTime(new Date());
-            model.setSubmitUser(ShiroUtils.getUserId());
-            model.setNcJson(result);
-            model.setNcCode(code);
-            updateByPrimaryKeySelective(model);
-            return AjaxResult.success();
-        } else if (success.equals("false")) {
-            return AjaxResult.error(jsonObject.getString("message"));
-        }
+
         return AjaxResult.error();
 
     }
@@ -478,18 +477,18 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         }
         String userId = ShiroUtils.getUserId();
         for (InvoiceManageDto invoiceManage : list) {
-            invoiceManage.setUpdateUser(userId);
-            InvoiceManage newRecord = selectByPrimaryKey(invoiceManage.getId());
-            // 如果流水号为空 则创建一个流水号
-            String serialNo;
-            if (StringUtils.isEmpty(newRecord.getSerialNo())) {
-                serialNo = "wuxi-" + System.currentTimeMillis() + "-001";
-                newRecord.setSerialNo(serialNo);
-                updateByPrimaryKeySelective(newRecord);
-            } else {
-                serialNo = newRecord.getSerialNo();
-            }
-            invoiceManage.setSerialNo(serialNo);
+//            invoiceManage.setUpdateUser(userId);
+//            InvoiceManage newRecord = selectByPrimaryKey(invoiceManage.getId());
+//            // 如果流水号为空 则创建一个流水号
+//            String serialNo;
+//            if (StringUtils.isEmpty(newRecord.getSerialNo())) {
+//                serialNo = "wuxi-" + System.currentTimeMillis() + "-001";
+//                newRecord.setSerialNo(serialNo);
+//                updateByPrimaryKeySelective(newRecord);
+//            } else {
+//                serialNo = newRecord.getSerialNo();
+//            }
+//            invoiceManage.setSerialNo(serialNo);
             invoiceManageService.sendInvoice(invoiceManage);
         }
         return AjaxResult.success();
@@ -527,6 +526,7 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
 
     /**
      * 查询需要更新状态的发票
+     *
      * @return
      */
     public List<InvoiceManage> selectNeedRefreshStatusList() {

+ 125 - 2
pro-base/src/main/java/com/idea/invoice/task/InvoiceTask.java

@@ -2,6 +2,17 @@ package com.idea.invoice.task;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.idea.buildManage.model.MnpBuilding;
+import com.idea.buildManage.model.ParkFloorDisc;
+import com.idea.buildManage.model.ParkInfo;
+import com.idea.buildManage.model.ParkRoom;
+import com.idea.buildManage.service.MnpBuildingService;
+import com.idea.buildManage.service.ParkFloorDiscService;
+import com.idea.buildManage.service.ParkInfoService;
+import com.idea.buildManage.service.ParkRoomService;
+import com.idea.customerManagement.dto.CustomerManagementDto;
+import com.idea.customerManagement.model.Buyer;
+import com.idea.customerManagement.service.CustomerManagementService;
 import com.idea.invoice.model.InvoiceManage;
 import com.idea.invoice.service.InvoiceManageService;
 import com.idea.invoice.util.InvoiceConstant;
@@ -9,6 +20,7 @@ import com.idea.invoice.util.InvoiceUtil;
 import com.idea.util.DateUtils;
 import com.rockstar.util.StringUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -23,7 +35,22 @@ public class InvoiceTask {
 
     @Autowired
     private InvoiceManageService invoiceManageService;
+    @Autowired
+    private ParkInfoService parkInfoService;
+    @Autowired
+    private ParkFloorDiscService floorDiscService;
+    @Autowired
+    private MnpBuildingService buildingService;
+    @Autowired
+    private ParkRoomService roomService;
+    @Autowired
+    private CustomerManagementService customerManagementService;
 
+
+
+    /**
+     * 每十分钟刷新一次发票状态
+     */
     @Scheduled(cron = "0 0/10 * * * ?")
     public void refreshStatus() {
 
@@ -54,16 +81,112 @@ public class InvoiceTask {
                 }
             }
         }catch (Exception e){
-            log.error("查询发票状态异常:{}",e);
+            log.error("查询发票状态异常",e);
         }
 
     }
 
-    public void refreshBuild() {
+    /**
+     * 每天凌晨执行 推送载体数据
+     */
+    @Scheduled(cron = "0 0 0 1/1 * ?")
+    public void sendBuild() {
+        List<MnpBuilding> mnpBuildings = buildingService.selectNeedSendList();
+        for(MnpBuilding building: mnpBuildings){
+            try {
+                JSONObject json = new JSONObject();
+                json.put("srcsystemid", building.getId());
+                json.put("code", building.getId());
+                json.put("name", building.getBuildNum());
+                json.put("pk_org", InvoiceUtil.pk_org);
+                json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_build);
+                // 给nc推送载体数据
+                String resultJson = InvoiceUtil.defdocAdd(json);
+                JSONObject jsonObject = JSONObject.parseObject(resultJson);
+                String success = jsonObject.getString("success");
+                if (success.equals("true")) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    String code = data.getString("code");
+                    String ncid = data.getString("ncid");
+                    building.setNcid(ncid);
+                    building.setNcCode(code);
+                    buildingService.updateByPrimaryKeySelective(building);
+                }
+            } catch (Exception e) {
+                log.error("推送载体失败", e);
+            }
+        }
+    }
 
+    /**
+     * 每天凌晨执行 推送房间数据
+     */
+    @Scheduled(cron = "0 0 0 1/1 * ?")
+    public void sendHouse(){
+        List<ParkRoom> parkRooms = roomService.selectNeedSendList();
+        for(ParkRoom record: parkRooms){
+            try {
+                ParkInfo parkInfo = parkInfoService.selectByPrimaryKey(record.getGroupId());
+                ParkFloorDisc parkFloorDisc = floorDiscService.selectByPrimaryKey(record.getDiscId());
+                MnpBuilding mnpBuilding = buildingService.selectByPrimaryKey(record.getBuildId());
+                String name = parkInfo.getGroupName() + "-" + parkFloorDisc.getName() + "-" + mnpBuilding.getBuildNum()
+                        + "-" + record.getRoomNo();
+                JSONObject json = new JSONObject();
+                json.put("srcsystemid", record.getId());
+                json.put("code", record.getId());
+                json.put("name", name);
+                json.put("pk_org", InvoiceUtil.pk_org);
+                json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_room);
+                // 给nc推送房间数据
+                String resultJson = InvoiceUtil.defdocAdd(json);
+                JSONObject jsonObject = JSONObject.parseObject(resultJson);
+                String success = jsonObject.getString("success");
+                if (success.equals("true")) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    String code = data.getString("code");
+                    String ncid = data.getString("ncid");
+                    record.setNcid(ncid);
+                    record.setNcCode(code);
+                    roomService.updateByPrimaryKeySelective(record);
+                }
+            } catch (Exception e) {
+                log.error("推送房间失败", e);
+            }
+        }
     }
 
+    /**
+     * 每天凌晨执行 推送客户数据
+     */
+    @Scheduled(cron = "0 0 0 1/1 * ?")
+    public void sendCustomer(){
 
+        List<CustomerManagementDto> customerManagementDtos = customerManagementService.selectNeedSendList();
+        for(CustomerManagementDto record: customerManagementDtos){
+            try {
+                // 给nc推送客户数据
+                JSONObject json = new JSONObject();
+                json.put("srcsystemid", record.getId());
+                json.put("name", record.getBuyerName());
+                json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
+                json.put("custprop", "0");//财务组织客户类型,必选,默认0
+                json.put("taxpayerid", record.getIdentityCard()); //统一社会信用代码,必选
+                String result = InvoiceUtil.customerAdd(json);
+                JSONObject jsonObject = JSONObject.parseObject(result);
+                String success = jsonObject.getString("success");
+                if (success.equals("true")) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    String code = data.getString("code");
+                    String ncid = data.getString("ncid");
+                    record.setNcid(ncid);
+                    record.setNcCode(code);
+                    customerManagementService.updateByPrimaryKeySelective(record);
+                }
+            }catch (Exception e){
+                log.error("推送客户失败",e);
+            }
+        }
+    }
 
 
 }

+ 4 - 2
pro-base/src/main/java/com/idea/invoice/util/InvoiceUtil.java

@@ -149,12 +149,13 @@ public class InvoiceUtil {
      *
      * @throws Exception
      */
-    public static void customerAdd(JSONObject json) throws Exception {
+    public static String customerAdd(JSONObject json) throws Exception {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/uapbd/customer/add");
         String result = util.getAPIRetrun(token, json.toJSONString());
         log.info("客户新增:{}", result);
+        return result;
     }
 
     /**
@@ -175,12 +176,13 @@ public class InvoiceUtil {
      *
      * @throws Exception
      */
-    public static void customerUpdate(JSONObject json) throws Exception {
+    public static String customerUpdate(JSONObject json) throws Exception {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/uapbd/customer/update");
         String result = util.getAPIRetrun(token, json.toJSONString());
         log.info("客户修改:{}", result);
+        return result;
     }
 
     /**

+ 4 - 0
pro-base/src/main/resources/mybatis/buildManage/MnpBuildingExtendMapper.xml

@@ -66,5 +66,9 @@
     )
   </select>
 
+    <select id="selectNeedSendList" resultType="com.idea.buildManage.model.MnpBuilding">
+      select * from mnp_building where ncid is null or ncid = ''
+    </select>
+
 
 </mapper>

+ 4 - 0
pro-base/src/main/resources/mybatis/buildManage/ParkRoomExtendMapper.xml

@@ -129,5 +129,9 @@
     </foreach>
   </select>
 
+    <select id="selectNeedSendList" resultType="com.idea.buildManage.model.ParkRoom">
+      select * from park_room where ncid is null or ncid = ''
+    </select>
+
 
 </mapper>

+ 6 - 0
pro-base/src/main/resources/mybatis/customerManagement/CustomerManagementExtendMapper.xml

@@ -31,4 +31,10 @@
     </where>
     order by batch_number + 0 desc,room_selection_number + 0 asc
   </select>
+
+    <select id="selectNeedSendList" resultType="com.idea.customerManagement.dto.CustomerManagementDto">
+      select c.*,b.name buyerName,b.identity_card from customer_management c
+      left join buyer b on c.id = b.customer_management_id and b.order_num = 1
+      where c.ncid is null or c.ncid = ''
+    </select>
 </mapper>