|
@@ -24,6 +24,8 @@ import com.dayou.enums.MainBusinessEnum;
|
|
|
import com.dayou.enums.ProductionEnum;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
import com.dayou.mapper.DyoaHistoryMapper;
|
|
|
+import com.dayou.mapper.DyoaRecordMapper;
|
|
|
+import com.dayou.mapper.FinanceClaimMapper;
|
|
|
import com.dayou.service.*;
|
|
|
import com.dayou.utils.DateUtils;
|
|
|
import com.dayou.utils.HttpKit;
|
|
@@ -65,6 +67,10 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
private Map<String,Long> departments = new HashMap<>();
|
|
|
|
|
|
+ private Map<String,Long> realAmounts = new HashMap<>();
|
|
|
+
|
|
|
+ private Map<String,Long> orderFundIds = new HashMap<>();
|
|
|
+
|
|
|
|
|
|
private static final Map<String,String> MAJOR_ORDER_COLUM = new HashMap<>();
|
|
|
|
|
@@ -74,6 +80,9 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
private static final Map<String,String> REAL_AMOUNT_COLUM = new HashMap<>();
|
|
|
|
|
|
+ private static final Map<String,String> REAL_AMOUNT_CLAIM_COLUM = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
@@ -111,6 +120,12 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
@Autowired
|
|
|
private ICustomerLinkmanService customerLinkmanService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FinanceClaimMapper financeClaimMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFinanceClaimService financeClaimService;
|
|
|
static {
|
|
|
// MAJOR_ORDER_COLUM.put("id","id");
|
|
|
MAJOR_ORDER_COLUM.put("name","name");
|
|
@@ -148,6 +163,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
MAJOR_ORDER_COLUM.put("description","remark");
|
|
|
MAJOR_ORDER_COLUM.put("customerName","clienteleId");
|
|
|
MAJOR_ORDER_COLUM.put("customerName2","clienteleSubId");
|
|
|
+ MAJOR_ORDER_COLUM.put("bankContactName","clienteleContactId");
|
|
|
MAJOR_ORDER_COLUM.put("terminalName","terminalClienteleId");
|
|
|
MAJOR_ORDER_COLUM.put("terminalContactName","terminalClienteleContactId");
|
|
|
|
|
@@ -199,6 +215,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
PERSONAL_ORDER_COLUM.put("customerType","clienteleType");
|
|
|
PERSONAL_ORDER_COLUM.put("customerName","clienteleId");
|
|
|
PERSONAL_ORDER_COLUM.put("customerName2","clienteleSubId");
|
|
|
+ PERSONAL_ORDER_COLUM.put("bankContactName","clienteleContactId");
|
|
|
PERSONAL_ORDER_COLUM.put("terminalType","terminalClienteleType");
|
|
|
PERSONAL_ORDER_COLUM.put("terminalName","terminalClienteleId");
|
|
|
PERSONAL_ORDER_COLUM.put("terminalContactName","terminalClienteleContactId");
|
|
@@ -215,8 +232,18 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
REAL_AMOUNT_COLUM.put("description","remark");
|
|
|
REAL_AMOUNT_COLUM.put("creatorName","creatorId");
|
|
|
|
|
|
+ //实收款认领记录
|
|
|
+ REAL_AMOUNT_CLAIM_COLUM.put("orderId","orderFundId");
|
|
|
+ REAL_AMOUNT_CLAIM_COLUM.put("incomeId","realFundId");
|
|
|
+ REAL_AMOUNT_CLAIM_COLUM.put("money","claimAmount");
|
|
|
+ REAL_AMOUNT_CLAIM_COLUM.put("takeEmpName","claimUserId");
|
|
|
+ REAL_AMOUNT_CLAIM_COLUM.put("createdDatetime","claimDatetime");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DyoaRecordMapper dyoaRecordMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<HisMajorOrder> hisMajorPage(HisOrderParam param) {
|
|
|
checkCookie();
|
|
@@ -368,11 +395,105 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void fetchRealAmountClaimData() {
|
|
|
+ Date max = dyoaRecordService.getMaxClaimDate();
|
|
|
+ List<String> claimIds = dyoaHistoryMapper.getNewClaimRecordIds(max);
|
|
|
+ claimIds.stream().forEach(x->{
|
|
|
+ fetchClaimRecord(x);
|
|
|
+ });
|
|
|
+ //更新订单实收款金额
|
|
|
+ List<OrderFund> orderTotalAmount = financeClaimMapper.queryOrderTotalAmount();
|
|
|
+ orderFundService.updateBatchById(orderTotalAmount);
|
|
|
+
|
|
|
+ //分配认领金额到产品收款表
|
|
|
+ List<OrderFund> majorOrderFund = orderTotalAmount.stream().filter(x -> x.getBusinessType().equals(MAJOR_BUSINESS.name())).collect(Collectors.toList());
|
|
|
+ majorOrderFund.stream().forEach(x->{
|
|
|
+ List<ProductionFund> prods = productionFundService.list(new LambdaQueryWrapper<ProductionFund>()
|
|
|
+ .eq(ProductionFund::getOrderFundId, x.getId()).select(ProductionFund::getProductionType));
|
|
|
+ if (CollectionUtil.isNotEmpty(prods)){
|
|
|
+ if (prods.size()>1){
|
|
|
+ List<ProductionFund> noStatement = prods.stream().filter(p -> !p.getProductionType().equals(ProductionEnum.STATEMENT.name())).collect(Collectors.toList());
|
|
|
+ if (noStatement.size()>1){
|
|
|
+ productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
|
|
|
+ .eq(ProductionFund::getOrderFundId,x.getId())
|
|
|
+ .eq(ProductionFund::getProductionType,ProductionEnum.REPORT.name())
|
|
|
+ .set(ProductionFund::getRealAmount,x.getRealAmount()));
|
|
|
+ }else {
|
|
|
+ productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
|
|
|
+ .eq(ProductionFund::getOrderFundId,x.getId())
|
|
|
+ .eq(ProductionFund::getProductionType,noStatement.get(0).getProductionType())
|
|
|
+ .set(ProductionFund::getRealAmount,x.getRealAmount()));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ productionFundService.update(new LambdaUpdateWrapper<ProductionFund>()
|
|
|
+ .eq(ProductionFund::getOrderFundId,x.getId()).set(ProductionFund::getRealAmount,x.getRealAmount()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void fetchClaimRecord(String id) {
|
|
|
+ try{
|
|
|
+ Map<String, Object> resultMap = dyoaHistoryMapper.getNewClaimRecord(id);
|
|
|
+ FinanceClaim financeClaim = new FinanceClaim();
|
|
|
+ Class<FinanceClaim> fClass = FinanceClaim.class;
|
|
|
+ String dyoaId = (String) resultMap.get("id");
|
|
|
+ for (Map.Entry<String, String> entry : REAL_AMOUNT_CLAIM_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 "realFundId":
|
|
|
+ Long realAmountMbsId = findRealAmountMbsId((String) columValue);
|
|
|
+ if (realAmountMbsId==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ field.set(financeClaim, realAmountMbsId);break;
|
|
|
+ case "orderFundId":
|
|
|
+ Long orderFundMbsId = findOrderFundId((String) columValue);
|
|
|
+ if (orderFundMbsId==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ field.set(financeClaim, orderFundMbsId);break;
|
|
|
+ case "claimUserId":
|
|
|
+ field.set(financeClaim,getMbsUserId((String) columValue));break;
|
|
|
+ case "claimAmount":
|
|
|
+ field.set(financeClaim, BigDecimal.valueOf((Double) columValue));break;
|
|
|
+ case "claimDatetime":
|
|
|
+ field.set(financeClaim, DateUtils.dateToLocalDate((Date) columValue));break;
|
|
|
+ default:
|
|
|
+ field.set(financeClaim,columValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Date createdDatetime = (Date) resultMap.get("createdDatetime");
|
|
|
+ financeClaim.setCreated(createdDatetime);
|
|
|
+ financeClaimService.save(financeClaim);
|
|
|
+ //插入同步记录表
|
|
|
+ Long mbsId = financeClaim.getId();
|
|
|
+ dyoaRecordService.insert(MainBusinessEnum.REAL_AMOUNT_CLAIM, mbsId, dyoaId,createdDatetime);
|
|
|
+ }
|
|
|
+ }catch (NoSuchFieldException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private Long findRealAmountMbsId(String columValue) {
|
|
|
+ if (CollectionUtil.isEmpty(realAmounts)){
|
|
|
+ realAmounts = dyoaRecordService.list(new LambdaQueryWrapper<DyoaRecord>().select(DyoaRecord::getMbsId, DyoaRecord::getDyoaId)
|
|
|
+ .eq(DyoaRecord::getMbsType, REAL_AMOUNT.name())).stream().collect(Collectors.toMap(DyoaRecord::getDyoaId, DyoaRecord::getMbsId));
|
|
|
+ }
|
|
|
+ return realAmounts.get(columValue);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void fetchRealAmount() {
|
|
|
Date max = dyoaRecordService.getMaxRealAmountCreatedTime();
|
|
@@ -414,7 +535,6 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
//插入同步记录表
|
|
|
Long mbsId = realFund.getId();
|
|
|
dyoaRecordService.insert(MainBusinessEnum.REAL_AMOUNT, mbsId, dyoaId,createdDatetime);
|
|
|
-
|
|
|
}catch (NoSuchFieldException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
} catch (IllegalAccessException e) {
|
|
@@ -459,7 +579,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
switch (mbsColum){
|
|
|
case "purpose":
|
|
|
case "credentials":
|
|
|
- field.set(personal,toJsonString((String) columValue));break;
|
|
|
+ field.set(personal,covertData((String) columValue,mbsColum));break;
|
|
|
case "clientManagerId":
|
|
|
case "outwardStaff":
|
|
|
case "inwardStaff":
|
|
@@ -471,9 +591,17 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
field.set(personal, BigDecimal.valueOf((Integer) columValue));break;
|
|
|
case "clienteleSubId":
|
|
|
case "clienteleId":
|
|
|
- case "terminalClienteleId":
|
|
|
field.set(personal, getCompanyId((String) columValue));break;
|
|
|
+ case "terminalClienteleId":
|
|
|
+ String terminalType = (String) dyoaPersonalOrder.get("terminalType");
|
|
|
+ if ("企业".equals(terminalType)){
|
|
|
+ field.set(personal, getCompanyId((String) columValue));
|
|
|
+ }else {
|
|
|
+ field.set(personal, getCompanyLinkmanId((String) columValue));
|
|
|
+ }
|
|
|
+ break;
|
|
|
case "terminalClienteleContactId":
|
|
|
+ case "clienteleContactId":
|
|
|
field.set(personal, getCompanyLinkmanId((String) columValue));break;
|
|
|
default:
|
|
|
field.set(personal,columValue);
|
|
@@ -490,6 +618,44 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
return personal;
|
|
|
}
|
|
|
|
|
|
+ private static String covertData(String columValue, String mbsColum) {
|
|
|
+ List<String> list = Arrays.asList(columValue.split(","));
|
|
|
+ List<String> ret = new ArrayList<>();
|
|
|
+ if (mbsColum.equals("purpose")){
|
|
|
+ list.stream().forEach(x->{
|
|
|
+ if (x.equals("住宅")){
|
|
|
+ ret.add("HOUSE");
|
|
|
+ }else if (x.equals("商业")){
|
|
|
+ ret.add("BUSINESS");
|
|
|
+ }else if (x.equals("办公")){
|
|
|
+ ret.add("OFFICE");
|
|
|
+ }else if (x.equals("工业")){
|
|
|
+ ret.add("INDUSTRIAL");
|
|
|
+ }else if (x.equals("其他")){
|
|
|
+ ret.add("OTHER");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (mbsColum.equals("credentials")){
|
|
|
+ list.stream().forEach(x->{
|
|
|
+ if (x.equals("房产证")){
|
|
|
+ ret.add("HOUSE_CERTIFICATE");
|
|
|
+ }else if (x.equals("国土证")){
|
|
|
+ ret.add("LAND_CERTIFICATE");
|
|
|
+ }else if (x.equals("不动产权证")){
|
|
|
+ ret.add("IMMOVABLE_CERTIFICATE");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return JSON.toJSONString(ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String credentials = covertData("房产证,国土证,不动产权证,租赁合同", "credentials");
|
|
|
+ System.out.println(credentials);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private Long getCompanyId(String columValue) {
|
|
|
List<CustomerCompany> list = customerCompanyService.list(new LambdaQueryWrapper<CustomerCompany>().eq(CustomerCompany::getName, columValue)
|
|
|
.select(BaseEntity::getId));
|
|
@@ -533,13 +699,12 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
|
|
|
public void doCreateMajorProduction(Double shouldAmount ,String id,Long majorId) throws NoSuchFieldException, IllegalAccessException {
|
|
|
List<HisMajorTarget> majorProductions = dyoaHistoryMapper.queryMajorProduction(id);
|
|
|
+ //创建产品收款记录
|
|
|
if (CollectionUtil.isNotEmpty(majorProductions)){
|
|
|
-
|
|
|
+ //创建订单收款记录
|
|
|
OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>().eq(OrderFund::getBusinessType, MAJOR_BUSINESS.name())
|
|
|
.eq(OrderFund::getBusinessId, majorId).eq(OrderFund::getOrderId, majorProductions.get(0).getCode()));
|
|
|
-
|
|
|
if (orderFund==null){
|
|
|
- //创建订单收款记录
|
|
|
orderFund = new OrderFund();
|
|
|
orderFund.setBusinessId(majorId);
|
|
|
orderFund.setBusinessType(MAJOR_BUSINESS.name());
|
|
@@ -548,7 +713,6 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
orderFund.setShouldAmount(BigDecimal.valueOf(shouldAmount));
|
|
|
orderFundService.save(orderFund);
|
|
|
}
|
|
|
-
|
|
|
for (HisMajorTarget production :majorProductions){
|
|
|
if (StrUtil.isNotBlank(production.getPId())){
|
|
|
MajorProduction majorProduction = new MajorProduction();
|
|
@@ -672,6 +836,7 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
case "terminalClienteleId":
|
|
|
field.set(major, getCompanyId((String) columValue));break;
|
|
|
case "terminalClienteleContactId":
|
|
|
+ case "clienteleContactId":
|
|
|
field.set(major, getCompanyLinkmanId((String) columValue));break;
|
|
|
default:
|
|
|
field.set(major,columValue);
|
|
@@ -724,6 +889,13 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
|
|
|
return JSON.toJSONString(userIds);
|
|
|
}
|
|
|
|
|
|
+ private Long findOrderFundId(String columValue){
|
|
|
+ if (CollectionUtil.isEmpty(orderFundIds)){
|
|
|
+ orderFundIds = dyoaRecordMapper.selectOrderFundIdByDyoaOrderId().stream().collect(Collectors.toMap(DyoaRecord::getDyoaId,DyoaRecord::getMbsId));
|
|
|
+ }
|
|
|
+ return orderFundIds.get(columValue);
|
|
|
+ }
|
|
|
+
|
|
|
// private Long getMbsWorkFlows(String flowCode){
|
|
|
// if (CollectionUtil.isEmpty(workFlows)){
|
|
|
// List<WorkFlow> list = workFlowService.list(new LambdaQueryWrapper<WorkFlow>().select(BaseEntity::getId, WorkFlow::getCode));
|