|
@@ -3,8 +3,11 @@
|
|
|
*/
|
|
|
package com.jeeplus.modules.workinvoice.service;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
import com.jeeplus.common.service.CrudService;
|
|
|
import com.jeeplus.common.utils.DateUtils;
|
|
@@ -54,9 +57,15 @@ import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -118,6 +127,8 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
private AreaService areaService;
|
|
|
@Autowired
|
|
|
private WorkInvoiceCloudDao workInvoiceCloudDao;
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
|
|
|
private static byte[] SYN_BYTE = new byte[0];
|
|
|
|
|
@@ -518,13 +529,13 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
ActUtils.PD_REIMBURSEMENT[0], businessKey, processInstance.getId(), variables});
|
|
|
return "";
|
|
|
}
|
|
|
-
|
|
|
+ private ObjectMapper objectMapper = new ObjectMapper();
|
|
|
/**
|
|
|
* 保存发票收款信息
|
|
|
* @param workInvoice
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void saveReceipt(WorkInvoice workInvoice) {
|
|
|
+ public void saveReceipt(WorkInvoice workInvoice) throws JsonProcessingException {
|
|
|
if(null != workInvoice.getWorkReceiptList()) {
|
|
|
//发票收款信息
|
|
|
for (WorkInvoiceReceipt receiptInfo : workInvoice.getWorkReceiptList()) {
|
|
@@ -559,6 +570,34 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
workInvoice.setReceiptMoney("0");
|
|
|
workInvoiceDao.updateInvoiceReceipt(workInvoice);
|
|
|
}
|
|
|
+ //先查询该发票是否为苏州分公司的发票
|
|
|
+ WorkInvoice invoice = workInvoiceDao.get(workInvoice.getId());
|
|
|
+ if (StringUtils.isNotBlank(invoice.getIsSzCloud()) && invoice.getIsSzCloud().equals("sz")){
|
|
|
+ if(null != receiptList && receiptList.size()>0){
|
|
|
+ for (WorkInvoiceReceipt workInvoiceReceipt : receiptList) {
|
|
|
+ User user = UserUtils.get(workInvoiceReceipt.getCreateBy().getId());
|
|
|
+ workInvoiceReceipt.setCreateName(user.getName());
|
|
|
+ User user1 = UserUtils.get(workInvoiceReceipt.getUpdateBy().getId());
|
|
|
+ workInvoiceReceipt.setUpdateName(user1.getName());
|
|
|
+ }
|
|
|
+ WorkInvoice invoice1 = new WorkInvoice();
|
|
|
+ invoice1.setWorkReceiptList(receiptList);
|
|
|
+ String json = objectMapper.writeValueAsString(invoice1);
|
|
|
+ String path = Global.getConfig("SZ_PATH");
|
|
|
+ String url = path+"/transpond/saveReceipt";
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
|
|
|
+ try {
|
|
|
+ restTemplate.exchange(url, HttpMethod.POST,httpEntity,String.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录错误日志或进行其他处理
|
|
|
+ System.err.println("Error sending project info to cloud: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -750,12 +789,32 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
* @param workInvoice
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void receiptMoney(WorkInvoice workInvoice) {
|
|
|
+ public void receiptMoney(WorkInvoice workInvoice) throws JsonProcessingException {
|
|
|
workInvoice.preUpdate();
|
|
|
dao.receiptMoney(workInvoice);
|
|
|
/*for (WorkInvoiceDetail workAccount : workInvoice.getWorkAccountList()){
|
|
|
workInvoiceDetailDao.delete(workAccount);
|
|
|
}*/
|
|
|
+ //先查询该发票是否为苏州分公司的发票
|
|
|
+ WorkInvoice invoice = workInvoiceDao.get(workInvoice.getId());
|
|
|
+ if (StringUtils.isNotBlank(invoice.getIsSzCloud()) && invoice.getIsSzCloud().equals("sz")){
|
|
|
+ WorkInvoice invoice1 = new WorkInvoice();
|
|
|
+ invoice1.setId(workInvoice.getId());
|
|
|
+ invoice1.setReceiptMoney("1");
|
|
|
+ invoice1.setReceiptMoneyDate(invoice.getReceiptMoneyDate());
|
|
|
+ String json = objectMapper.writeValueAsString(invoice1);
|
|
|
+ String path = Global.getConfig("SZ_PATH");
|
|
|
+ String url = path+"/transpond/saveReceivable";
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
|
|
|
+ try {
|
|
|
+ restTemplate.exchange(url, HttpMethod.POST,httpEntity,String.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录错误日志或进行其他处理
|
|
|
+ System.err.println("Error sending project info to cloud: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -763,12 +822,32 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
* @param workInvoice
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void saveCancelReceiptMoney(WorkInvoice workInvoice) {
|
|
|
+ public void saveCancelReceiptMoney(WorkInvoice workInvoice) throws JsonProcessingException {
|
|
|
workInvoice.preUpdate();
|
|
|
dao.cancelReceiptMoney(workInvoice);
|
|
|
/*for (WorkInvoiceDetail workAccount : workInvoice.getWorkAccountList()){
|
|
|
workInvoiceDetailDao.delete(workAccount);
|
|
|
}*/
|
|
|
+ //先查询该发票是否为苏州分公司的发票
|
|
|
+ WorkInvoice invoice = workInvoiceDao.get(workInvoice.getId());
|
|
|
+ if (StringUtils.isNotBlank(invoice.getIsSzCloud()) && invoice.getIsSzCloud().equals("sz")){
|
|
|
+ WorkInvoice invoice1 = new WorkInvoice();
|
|
|
+ invoice1.setId(workInvoice.getId());
|
|
|
+ invoice1.setReceiptMoney("0");
|
|
|
+ invoice1.setReceiptMoneyDate(invoice.getReceiptMoneyDate());
|
|
|
+ String json = objectMapper.writeValueAsString(invoice1);
|
|
|
+ String path = Global.getConfig("SZ_PATH");
|
|
|
+ String url = path+"/transpond/saveReceivable";
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
|
|
|
+ try {
|
|
|
+ restTemplate.exchange(url, HttpMethod.POST,httpEntity,String.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录错误日志或进行其他处理
|
|
|
+ System.err.println("Error sending project info to cloud: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
* 获取关联项目名称list
|
|
@@ -2375,4 +2454,13 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
|
|
|
public List<WorkInvoiceCloud> getByInvoiceId(String id) {
|
|
|
return workInvoiceCloudDao.getByInvoiceId(id);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id获取所有发票号
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getInvoiceNumberStr(String id) {
|
|
|
+ return workInvoiceDao.getInvoiceNumberStr(id);
|
|
|
+ }
|
|
|
}
|