Browse Source

开启nc 推送

LAPTOP-FO2T5SIU\35838 5 months ago
parent
commit
f671962438

+ 3 - 3
pro-base/src/main/java/com/idea/buildManage/controller/MnpBuildingController.java

@@ -132,9 +132,9 @@ public class MnpBuildingController extends BaseController {
             EasyExcel.read(excel, MnpBuildingExcel.class, listener).headRowNumber(2).sheet().doRead();
             excel.delete();
             // 启动一个新的线程来触发另一个方法
-//            new Thread(() -> {
-//                invoiceTask.sendBuild();
-//            }).start();
+            new Thread(() -> {
+                invoiceTask.sendBuild();
+            }).start();
         } catch (Exception e) {
             e.printStackTrace();
             return AjaxResult.error(e.getMessage());

+ 3 - 3
pro-base/src/main/java/com/idea/buildManage/controller/ParkRoomController.java

@@ -160,9 +160,9 @@ public class ParkRoomController extends BaseController {
             EasyExcel.read(excel, ParkRoomExcel.class, listener).headRowNumber(2).sheet().doRead();
             excel.delete();
             // 启动一个新的线程来触发另一个方法
-//            new Thread(() -> {
-//                invoiceTask.sendHouse();
-//            }).start();
+            new Thread(() -> {
+                invoiceTask.sendHouse();
+            }).start();
         } catch (Exception e) {
             e.printStackTrace();
             return AjaxResult.error(e.getMessage());

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

@@ -204,13 +204,13 @@ public class MnpBuildingService implements BaseService<MnpBuilding, MnpBuildingE
         building.setDelFlag("1");
         int result = updateByPrimaryKeySelective(building);
         // 用友推送楼栋禁用
-//        try {
-//            JSONObject json = new JSONObject();
-//            json.put("ncid", building.getNcid());
-//            InvoiceUtil.defdocDisable(json);
-//        }catch (Exception e){
-//            log.error("楼栋禁用失败:",e);
-//        }
+        try {
+            JSONObject json = new JSONObject();
+            json.put("ncid", building.getNcid());
+            InvoiceUtil.defdocDisable(json);
+        }catch (Exception e){
+            log.error("楼栋禁用失败:",e);
+        }
         return result;
     }
 
@@ -279,31 +279,31 @@ public class MnpBuildingService implements BaseService<MnpBuilding, MnpBuildingE
 
         ParkInfo parkInfo = parkInfoMapper.selectByPrimaryKey(record.getGroupId());
 
-//        try {
-//            JSONObject json = new JSONObject();
-//            json.put("srcsystemid", id);
-//            json.put("code", id);
-//            json.put("name", record.getBuildNum());
-//            json.put("pk_org", parkInfo.getOrganizationalCode());
-//            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_build);
-//            log.info("推送载体详情:{}", json.toJSONString());
-//            // 给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", parkInfo.getOrganizationalCode());
+            json.put("pk_defdoclist", InvoiceUtil.pk_defdoclist_build);
+            log.info("推送载体详情:{}", json.toJSONString());
+            // 给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;
     }
@@ -312,17 +312,17 @@ 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;
     }

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

@@ -211,18 +211,18 @@ 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());
-//            log.info("推送房间修改详情:{}", json.toJSONString());
-//            // 给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());
+            log.info("推送房间修改详情:{}", json.toJSONString());
+            // 给nc推送修改载体数据
+            InvoiceUtil.defdocUpdate(json);
+        }catch (Exception e){
+            log.error("推送修改房间失败",e);
+        }
         return updateByPrimaryKeySelective(model);
     }
 
@@ -311,13 +311,13 @@ public class ParkRoomService implements BaseService<ParkRoom, ParkRoomExample> {
         parkRoom.setDelFlag("1");
         int result = updateByPrimaryKeySelective(parkRoom);
         // 用友推送房间禁用
-//        try {
-//            JSONObject json = new JSONObject();
-//            json.put("ncid", parkRoom.getNcid());
-//            InvoiceUtil.defdocDisable(json);
-//        }catch (Exception e){
-//            log.error("房间禁用失败:",e);
-//        }
+        try {
+            JSONObject json = new JSONObject();
+            json.put("ncid", parkRoom.getNcid());
+            InvoiceUtil.defdocDisable(json);
+        }catch (Exception e){
+            log.error("房间禁用失败:",e);
+        }
 
         return result;
     }
@@ -395,35 +395,35 @@ 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", parkInfo.getOrganizationalCode());
-//            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", parkInfo.getOrganizationalCode());
+            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;
 
     }

+ 5 - 3
pro-base/src/main/java/com/idea/customerManagement/controller/CustomerManagementController.java

@@ -18,6 +18,7 @@ import com.rockstar.frame.model.extend.DateTrans;
 import com.rockstar.frame.model.extend.TableSplitResult;
 import com.rockstar.frame.model.extend.Tablepar;
 import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
@@ -30,6 +31,7 @@ import java.io.IOException;
 import java.util.Date;
 import java.util.List;
 
+@Slf4j
 @Controller
 @RequestMapping(value = "CustomerManagementController")
 @Api(tags = "客户管理")
@@ -125,9 +127,9 @@ public class CustomerManagementController extends BaseController {
     public AjaxResult handleImport(@RequestParam("file") MultipartFile file) throws IOException {
         JSONObject jsonObject = modelService.handleImport(file);
         // 启动一个新的线程来触发另一个方法
-//        new Thread(() -> {
-//            invoiceTask.sendCustomer();
-//        }).start();
+        new Thread(() -> {
+            invoiceTask.sendCustomer();
+        }).start();
         return AjaxResult.success(jsonObject);
     }
 

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

@@ -243,31 +243,31 @@ public class CustomerManagementService implements BaseService<CustomerManagement
         model.setCreatedId(userId);
         int result = insertWithOutId(model);
 
-//        try {
-//            // 给nc推送客户数据
-//            JSONObject json = new JSONObject();
-//            json.put("srcsystemid", id);
-//            json.put("name", builder.toString());
-//            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
-//            json.put("custprop", "0");//财务组织客户类型,必选,默认0
-//            json.put("taxpayerid",identityCardBuilder.toString() ); //统一社会信用代码,必选
-//            log.info("推送客户详情:{}", json.toJSONString());
-//            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 {
+            // 给nc推送客户数据
+            JSONObject json = new JSONObject();
+            json.put("srcsystemid", id);
+            json.put("name", builder.toString());
+            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
+            json.put("custprop", "0");//财务组织客户类型,必选,默认0
+            json.put("taxpayerid",identityCardBuilder.toString() ); //统一社会信用代码,必选
+            log.info("推送客户详情:{}", json.toJSONString());
+            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);
+        }
 
 
         return result;
@@ -335,24 +335,24 @@ public class CustomerManagementService implements BaseService<CustomerManagement
 
         int result = updateByPrimaryKeySelective(model);
 
-//        try {
-//
-//            // 修改客户数据
-//            JSONObject json = new JSONObject();
-//            json.put("ncid", oldCustomer.getBuyerIdentityCard());// 客户统一信用代码,必选
-//            json.put("name", builder.toString());
-//            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
-//            json.put("custprop", "0");//财务组织客户类型,必选,默认0
-//            json.put("taxpayerid", identityCardBuilder.toString()); //统一社会信用代码,必选
-//            log.info("推送客户修改详情:{}", json.toJSONString());
-//            String resultJson = InvoiceUtil.customerUpdate(json);
-//            JSONObject jsonObject = JSONObject.parseObject(resultJson);
-//            String success = jsonObject.getString("success");
-//            if (success.equals("true")) {
-//            }
-//        }catch (Exception e){
-//            log.error("修改客户失败",e);
-//        }
+        try {
+
+            // 修改客户数据
+            JSONObject json = new JSONObject();
+            json.put("ncid", oldCustomer.getBuyerIdentityCard());// 客户统一信用代码,必选
+            json.put("name", builder.toString());
+            json.put("pk_custclass", "02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
+            json.put("custprop", "0");//财务组织客户类型,必选,默认0
+            json.put("taxpayerid", identityCardBuilder.toString()); //统一社会信用代码,必选
+            log.info("推送客户修改详情:{}", json.toJSONString());
+            String resultJson = InvoiceUtil.customerUpdate(json);
+            JSONObject jsonObject = JSONObject.parseObject(resultJson);
+            String success = jsonObject.getString("success");
+            if (success.equals("true")) {
+            }
+        }catch (Exception e){
+            log.error("修改客户失败",e);
+        }
 
         return result;
 

+ 10 - 10
pro-base/src/main/java/com/idea/customerManagement/service/IntentionalDepositService.java

@@ -410,16 +410,16 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         }
         customerManagement.setHouseName(builder.toString());
         customerManagementMapper.updateByPrimaryKeySelective(customerManagement);
-//        try {
-//            ParkInfo parkInfo = parkInfoMapper.selectByPrimaryKey(response.getGroupId());
-//            // 客户分配
-//            JSONObject json = new JSONObject();
-//            json.put("pk_org", parkInfo.getOrganizationalCode());
-//            json.put("ncid", customerManagement.getBuyerIdentityCard());
-//            InvoiceUtil.customerAssign(json);
-//        } catch (Exception e) {
-//            log.error("客户分配失败", e);
-//        }
+        try {
+            ParkInfo parkInfo = parkInfoMapper.selectByPrimaryKey(response.getGroupId());
+            // 客户分配
+            JSONObject json = new JSONObject();
+            json.put("pk_org", parkInfo.getOrganizationalCode());
+            json.put("ncid", customerManagement.getBuyerIdentityCard());
+            InvoiceUtil.customerAssign(json);
+        } catch (Exception e) {
+            log.error("客户分配失败", e);
+        }
 
 
 

+ 10 - 10
pro-base/src/main/java/com/idea/customerManagement/service/RoomSelectionInfoService.java

@@ -288,16 +288,16 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
         CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(model.getCustomerManagementId());
         customerManagement.setStatus(7);
         customerManagementMapper.updateByPrimaryKeySelective(customerManagement);
-//        try {
-//            ParkInfo parkInfo = parkInfoMapper.selectByPrimaryKey(parkRoom.getGroupId());
-//            // 客户分配
-//            JSONObject json = new JSONObject();
-//            json.put("pk_org", parkInfo.getOrganizationalCode());
-//            json.put("ncid", customerManagement.getBuyerIdentityCard());
-//            InvoiceUtil.customerAssign(json);
-//        } catch (Exception e) {
-//            log.error("客户分配失败", e);
-//        }
+        try {
+            ParkInfo parkInfo = parkInfoMapper.selectByPrimaryKey(parkRoom.getGroupId());
+            // 客户分配
+            JSONObject json = new JSONObject();
+            json.put("pk_org", parkInfo.getOrganizationalCode());
+            json.put("ncid", customerManagement.getBuyerIdentityCard());
+            InvoiceUtil.customerAssign(json);
+        } catch (Exception e) {
+            log.error("客户分配失败", e);
+        }
 
         // 票据管理 新增一条记录
         ReceiptManage receiptManage = new ReceiptManage();

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

@@ -172,7 +172,7 @@ public class InvoiceTask {
      * 每天凌晨执行 推送客户数据
      */
 //    @Scheduled(cron = "0 0 0 1/1 * ?")
-    public void sendCustomer() throws Exception {
+    public void sendCustomer(){
 
         List<CustomerManagementDto> customerManagementDtos = customerManagementService.selectNeedSendList();
         for(CustomerManagementDto record: customerManagementDtos){
@@ -206,7 +206,7 @@ public class InvoiceTask {
     /**
      * 分配客户
      */
-    public void customerAssign() throws Exception {
+    public void customerAssign() {
 
 
         List<CustomerManagement> customerManagements = customerManagementService.selectByExample(new CustomerManagementExample());