|
@@ -1,192 +1,192 @@
|
|
|
-//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;
|
|
|
-//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;
|
|
|
-//
|
|
|
-//import java.util.Date;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//@Slf4j
|
|
|
-//@Component
|
|
|
-//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;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 每十分钟刷新一次发票状态
|
|
|
-// */
|
|
|
+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;
|
|
|
+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;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+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() {
|
|
|
-//
|
|
|
-// List<InvoiceManage> invoiceManages = invoiceManageService.selectNeedRefreshStatusList();
|
|
|
-// String ncCodes = invoiceManages.stream().map(InvoiceManage::getNcCode).collect(Collectors.joining());
|
|
|
-// JSONObject json = new JSONObject();
|
|
|
-// json.put("billno",ncCodes);
|
|
|
-// json.put("pk_org", InvoiceUtil.pk_org);
|
|
|
-// try {
|
|
|
-// String result = InvoiceUtil.invoiceQuery(json);
|
|
|
-// JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
-// if(jsonObject.getString("success").equals("true")){
|
|
|
-// JSONArray data = jsonObject.getJSONArray("data");
|
|
|
-// for (int i = 0; i < data.size(); i++) {
|
|
|
-// JSONObject object = data.getJSONObject(i);
|
|
|
-// String srcsystemid = object.getString("srcsystemid");
|
|
|
-// String invoiceno = object.getString("invoiceno");
|
|
|
-// String settledate = object.getString("settledate");
|
|
|
-// if(StringUtils.isNotEmpty(invoiceno)){
|
|
|
-//
|
|
|
-// Date date = DateUtils.parseDate(settledate, DateUtils.YYYY_MM_DD_HH_MM_SS);
|
|
|
-// InvoiceManage invoiceManage = invoiceManageService.selectByPrimaryKey(srcsystemid);
|
|
|
-// invoiceManage.setInvoiceNo(invoiceno);
|
|
|
-// invoiceManage.setInvoiceStatus("1");
|
|
|
-// invoiceManage.setInvoiceDate(date);
|
|
|
-// invoiceManageService.updateByPrimaryKeySelective(invoiceManage);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }catch (Exception e){
|
|
|
-// log.error("查询发票状态异常",e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 每天凌晨执行 推送载体数据
|
|
|
-// */
|
|
|
-//// @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);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//}
|
|
|
+ public void refreshStatus() {
|
|
|
+
|
|
|
+ List<InvoiceManage> invoiceManages = invoiceManageService.selectNeedRefreshStatusList();
|
|
|
+ String ncCodes = invoiceManages.stream().map(InvoiceManage::getNcCode).collect(Collectors.joining());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("billno",ncCodes);
|
|
|
+ json.put("pk_org", InvoiceUtil.pk_org);
|
|
|
+ try {
|
|
|
+ String result = InvoiceUtil.invoiceQuery(json);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if(jsonObject.getString("success").equals("true")){
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject object = data.getJSONObject(i);
|
|
|
+ String srcsystemid = object.getString("srcsystemid");
|
|
|
+ String invoiceno = object.getString("invoiceno");
|
|
|
+ String settledate = object.getString("settledate");
|
|
|
+ if(StringUtils.isNotEmpty(invoiceno)){
|
|
|
+
|
|
|
+ Date date = DateUtils.parseDate(settledate, DateUtils.YYYY_MM_DD_HH_MM_SS);
|
|
|
+ InvoiceManage invoiceManage = invoiceManageService.selectByPrimaryKey(srcsystemid);
|
|
|
+ invoiceManage.setInvoiceNo(invoiceno);
|
|
|
+ invoiceManage.setInvoiceStatus("1");
|
|
|
+ invoiceManage.setInvoiceDate(date);
|
|
|
+ invoiceManageService.updateByPrimaryKeySelective(invoiceManage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("查询发票状态异常",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天凌晨执行 推送载体数据
|
|
|
+ */
|
|
|
+// @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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|