|
@@ -37,6 +37,9 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -83,7 +86,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
private static final Map<String,String> ASSETS_PRODUCTION_COLUM = new HashMap<>();
|
|
|
|
|
|
- private static final Map<String,String> FINANCE_CLAIM_COLUM = new HashMap<>();
|
|
|
+ private static final Map<String,String> FINANCE_INVOICE_COLUM = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
@@ -135,6 +138,10 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
@Autowired
|
|
|
private IAssetsProductionService assetsProductionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFinanceInvoiceService financeInvoiceService;
|
|
|
+
|
|
|
static {
|
|
|
// MAJOR_ORDER_COLUM.put("id","id");
|
|
|
MAJOR_ORDER_COLUM.put("name","name");
|
|
@@ -286,25 +293,27 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
ASSETS_PRODUCTION_COLUM.put("type","productionType");
|
|
|
|
|
|
//财务开票字段
|
|
|
- FINANCE_CLAIM_COLUM.put("companyName","title");
|
|
|
- FINANCE_CLAIM_COLUM.put("companyNO","taxNo");
|
|
|
- FINANCE_CLAIM_COLUM.put("bankName","bankName");
|
|
|
- FINANCE_CLAIM_COLUM.put("bankNO","bankAccount");
|
|
|
- FINANCE_CLAIM_COLUM.put("address","bankAddress");
|
|
|
- FINANCE_CLAIM_COLUM.put("invoiceType","type");
|
|
|
- FINANCE_CLAIM_COLUM.put("project","makeItem");
|
|
|
- FINANCE_CLAIM_COLUM.put("planMoney","planAmount");
|
|
|
- FINANCE_CLAIM_COLUM.put("realMoney","realAmount");
|
|
|
- FINANCE_CLAIM_COLUM.put("taxPoint","taxRate");
|
|
|
- FINANCE_CLAIM_COLUM.put("planDate","planMakeDate");
|
|
|
- FINANCE_CLAIM_COLUM.put("realDate","realMakeDate");
|
|
|
- FINANCE_CLAIM_COLUM.put("unit","itemUnit");
|
|
|
- FINANCE_CLAIM_COLUM.put("number","itemQuantity");
|
|
|
- FINANCE_CLAIM_COLUM.put("taxAmount","taxAmount");
|
|
|
- FINANCE_CLAIM_COLUM.put("status","state");
|
|
|
- FINANCE_CLAIM_COLUM.put("reason","reason");
|
|
|
- FINANCE_CLAIM_COLUM.put("description","remark");
|
|
|
- FINANCE_CLAIM_COLUM.put("invoiceEmp","makerId");
|
|
|
+ FINANCE_INVOICE_COLUM.put("orderId","orderFundId");
|
|
|
+ FINANCE_INVOICE_COLUM.put("incomeId","realFundId");
|
|
|
+ FINANCE_INVOICE_COLUM.put("companyName","title");
|
|
|
+ FINANCE_INVOICE_COLUM.put("companyNO","taxNo");
|
|
|
+ FINANCE_INVOICE_COLUM.put("bankName","bankName");
|
|
|
+ FINANCE_INVOICE_COLUM.put("bankNO","bankAccount");
|
|
|
+ FINANCE_INVOICE_COLUM.put("address","bankAddress");
|
|
|
+ FINANCE_INVOICE_COLUM.put("invoiceType","type");
|
|
|
+ FINANCE_INVOICE_COLUM.put("project","makeItem");
|
|
|
+ FINANCE_INVOICE_COLUM.put("planMoney","planAmount");
|
|
|
+ FINANCE_INVOICE_COLUM.put("realMoney","realAmount");
|
|
|
+ FINANCE_INVOICE_COLUM.put("taxPoint","taxRate");
|
|
|
+ FINANCE_INVOICE_COLUM.put("planDate","planMakeDate");
|
|
|
+ FINANCE_INVOICE_COLUM.put("realDate","realMakeDate");
|
|
|
+ FINANCE_INVOICE_COLUM.put("unit","itemUnit");
|
|
|
+ FINANCE_INVOICE_COLUM.put("taxAmount","taxAmount");
|
|
|
+ FINANCE_INVOICE_COLUM.put("status","state");
|
|
|
+ FINANCE_INVOICE_COLUM.put("reason","reason");
|
|
|
+ FINANCE_INVOICE_COLUM.put("description","remark");
|
|
|
+ FINANCE_INVOICE_COLUM.put("invoiceEmp","makerId");
|
|
|
+ FINANCE_INVOICE_COLUM.put("ticketNo","ticketNo");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -590,10 +599,70 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
Date max = dyoaRecordService.getMaxFinanceInvoiceCreatedTime();
|
|
|
List<String> newInvoice = dyoaHistoryMapper.getNewFinanceInvoice(max);
|
|
|
newInvoice.stream().forEach(x-> {
|
|
|
- //todo
|
|
|
+ fetchFinanceInvoiceDetail(x);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ 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;
|
|
|
+ default:
|
|
|
+ field.set(invoice,columValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void fetchAssetsOrderProduction() {
|