|
@@ -49,6 +49,7 @@ import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.dayou.common.Constants.*;
|
|
|
+import static com.dayou.enums.FinanceInvoiceState.已作废;
|
|
|
import static com.dayou.enums.MainBusinessEnum.*;
|
|
|
import static com.dayou.enums.ProductionEnum.FINAL;
|
|
|
|
|
@@ -626,8 +627,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void fetchFinanceInvoiceRecord(){
|
|
|
- Date max = dyoaRecordService.getMaxFinanceInvoiceCreatedTime();
|
|
|
- List<String> newInvoice = dyoaHistoryMapper.getNewFinanceInvoice(max);
|
|
|
+ List<String> newInvoice = dyoaHistoryMapper.getNewFinanceInvoice();
|
|
|
newInvoice.stream().forEach(x-> {
|
|
|
fetchFinanceInvoiceDetail(x);
|
|
|
});
|
|
@@ -636,66 +636,85 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
private void fetchFinanceInvoiceDetail(String id) {
|
|
|
try{
|
|
|
Map<String,Object> resultMap = dyoaHistoryMapper.getInvoiceInfo(id);
|
|
|
- FinanceInvoice invoice = new FinanceInvoice();
|
|
|
- Class<FinanceInvoice> fClass = FinanceInvoice.class;
|
|
|
String dyoaId = (String) resultMap.get("id");
|
|
|
- for (Map.Entry<String, String> entry : FINANCE_INVOICE_COLUM.entrySet()){
|
|
|
- Object columValue = resultMap.get(entry.getKey());
|
|
|
- if (columValue!=null){
|
|
|
- String mbsColum = entry.getValue();
|
|
|
- Field field = fClass.getDeclaredField(mbsColum);
|
|
|
- field.setAccessible(true);
|
|
|
- switch (mbsColum){
|
|
|
- case "orderFundId":
|
|
|
- Long orderFundMbsId = findOrderFundId((String) columValue);
|
|
|
- if (orderFundMbsId==null){
|
|
|
- return;
|
|
|
- }
|
|
|
- field.set(invoice, orderFundMbsId);
|
|
|
- break;
|
|
|
- case "realFundId":
|
|
|
- Long realFundId = findRealAmountMbsId((String) columValue);
|
|
|
- if (realFundId==null){
|
|
|
- return;
|
|
|
- }
|
|
|
- field.set(invoice, realFundId);
|
|
|
- break;
|
|
|
- case "planAmount":
|
|
|
- case "realAmount":
|
|
|
- case "taxAmount":
|
|
|
- case "taxRate":
|
|
|
- field.set(invoice,BigDecimal.valueOf((Double) columValue));
|
|
|
- break;
|
|
|
- case "planMakeDate":
|
|
|
- case "realMakeDate":
|
|
|
- Timestamp ts = (Timestamp) columValue;
|
|
|
- field.set(invoice, DateUtils.dateToLocalDate(new Date(ts.getTime())));
|
|
|
- break;
|
|
|
- case "makerId":
|
|
|
- field.set(invoice,getMbsUserId((String) columValue));
|
|
|
- break;
|
|
|
- case "applyId":
|
|
|
- field.set(invoice,getMbsUserId((String) columValue));
|
|
|
- break;
|
|
|
- default:
|
|
|
- field.set(invoice,columValue);
|
|
|
+ FinanceInvoice invoice = dyoaRecordService.getMbsIdByDyOAiDForInvoice(dyoaId);
|
|
|
+ if (invoice==null){
|
|
|
+ invoice = new FinanceInvoice();
|
|
|
+ Class<FinanceInvoice> fClass = FinanceInvoice.class;
|
|
|
+ for (Map.Entry<String, String> entry : FINANCE_INVOICE_COLUM.entrySet()){
|
|
|
+ Object columValue = resultMap.get(entry.getKey());
|
|
|
+ if (columValue!=null){
|
|
|
+ String mbsColum = entry.getValue();
|
|
|
+ Field field = fClass.getDeclaredField(mbsColum);
|
|
|
+ field.setAccessible(true);
|
|
|
+ switch (mbsColum){
|
|
|
+ case "orderFundId":
|
|
|
+ Long orderFundMbsId = findOrderFundId((String) columValue);
|
|
|
+ if (orderFundMbsId==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ field.set(invoice, orderFundMbsId);
|
|
|
+ break;
|
|
|
+ case "realFundId":
|
|
|
+ Long realFundId = findRealAmountMbsId((String) columValue);
|
|
|
+ if (realFundId==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ field.set(invoice, realFundId);
|
|
|
+ break;
|
|
|
+ case "planAmount":
|
|
|
+ case "realAmount":
|
|
|
+ case "taxAmount":
|
|
|
+ case "taxRate":
|
|
|
+ field.set(invoice,BigDecimal.valueOf((Double) columValue));
|
|
|
+ break;
|
|
|
+ case "planMakeDate":
|
|
|
+ case "realMakeDate":
|
|
|
+ Timestamp ts = (Timestamp) columValue;
|
|
|
+ field.set(invoice, DateUtils.dateToLocalDate(new Date(ts.getTime())));
|
|
|
+ break;
|
|
|
+ case "makerId":
|
|
|
+ field.set(invoice,getMbsUserId((String) columValue));
|
|
|
+ break;
|
|
|
+ case "applyId":
|
|
|
+ field.set(invoice,getMbsUserId((String) columValue));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ field.set(invoice,columValue);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ String orderId = (String) resultMap.get("orderId");
|
|
|
+ Long orderFundMbsId = findOrderFundId((String) orderId);
|
|
|
+ Long productionFunId = getProductionFundIdByOrderFundId(orderFundMbsId);
|
|
|
+ invoice.setProductionFundId(productionFunId);
|
|
|
+ Date createdDatetime = (Date) resultMap.get("createdDatetime");
|
|
|
+ invoice.setCreated(createdDatetime);
|
|
|
+ financeInvoiceService.save(invoice);
|
|
|
+ //插入同步记录表
|
|
|
+ Long mbsId = invoice.getId();
|
|
|
+ dyoaRecordService.insert(MainBusinessEnum.FINANCE_INVOICE, mbsId, dyoaId,createdDatetime);
|
|
|
+ }else{
|
|
|
+ String status = (String) resultMap.get("status");
|
|
|
+ if (StrUtil.isNotBlank(status) && "已作废".equals(status)){
|
|
|
+ invoice.setState("已作废");
|
|
|
+ invoice.setReason((String) resultMap.get("reason"));
|
|
|
+ financeInvoiceService.update(invoice);
|
|
|
+ }
|
|
|
+ String state = invoice.getState();
|
|
|
+ if (StrUtil.isNotBlank(state) && "待开票".equals(state) && StrUtil.isNotBlank(status) && "已开票".equals(status)){
|
|
|
+ invoice.setState("已开票");
|
|
|
+ Timestamp ts = (Timestamp) resultMap.get("realDate");
|
|
|
+ invoice.setRealMakeDate(DateUtils.dateToLocalDate(new Date(ts.getTime())));
|
|
|
+ invoice.setRealAmount(BigDecimal.valueOf((Double) resultMap.get("realMoney")));
|
|
|
+ invoice.setTicketNo((String) resultMap.get("ticketNo"));
|
|
|
+ invoice.setMakerId(getMbsUserId((String) resultMap.get("invoiceEmp")));
|
|
|
+ financeInvoiceService.update(invoice);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- String orderId = (String) resultMap.get("orderId");
|
|
|
- Long orderFundMbsId = findOrderFundId((String) orderId);
|
|
|
- Long productionFunId = getProductionFundIdByOrderFundId(orderFundMbsId);
|
|
|
- invoice.setProductionFundId(productionFunId);
|
|
|
-
|
|
|
- Date createdDatetime = (Date) resultMap.get("createdDatetime");
|
|
|
- invoice.setCreated(createdDatetime);
|
|
|
- financeInvoiceService.save(invoice);
|
|
|
- //插入同步记录表
|
|
|
- Long mbsId = invoice.getId();
|
|
|
- dyoaRecordService.insert(MainBusinessEnum.FINANCE_INVOICE, mbsId, dyoaId,createdDatetime);
|
|
|
}catch (NoSuchFieldException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
} catch (IllegalAccessException e) {
|
|
@@ -1845,6 +1864,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean updateProductionFund() {
|
|
|
List<OrderFund> orderFunds = orderFundService.getAllOrderFund();
|