Commit 79a2050f by huluobin

新资产负债表

parent 776eb93e
package com.bailuntec.job.service;
import com.bailuntec.common.BeanUtils;
import com.bailuntec.common.ListUtil;
import com.bailuntec.cost.api.CostApi;
import com.bailuntec.cost.api.dto.CostDto;
import com.bailuntec.cost.api.dto.ManageCostDto;
......@@ -36,6 +37,10 @@ import java.util.List;
@Service
public class SyncFeeService {
public static final String baseSyncFinanceFee = "base-sync-finance-fee";
public static final String baseSyncLogistics = "base-sync-logistics";
public static final String baseSyncManageCost = "base-sync-manage-cost";
public static final String baseSyncDailyFee = "base-sync-daily-fee";
@Resource
DcJobConfigMapper dcJobConfigMapper;
......@@ -48,31 +53,37 @@ public class SyncFeeService {
@Resource
DcBaseFinanceManagecostMapper dcBaseFinanceManagecostMapper;
public static final String baseSyncFinanceFee = "base-sync-finance-fee";
public static final String baseSyncLogistics = "base-sync-logistics";
public static final String baseSyncManageCost = "base-sync-manage-cost";
public static final String baseSyncDailyFee = "base-sync-daily-fee";
@Transactional
public void syncFinanceFee() {
DcJobConfig dcJobConfig = dcJobConfigMapper.selectByName(baseSyncFinanceFee);
CostResult<List<CostDto>> result = costApi.getCostList(dcJobConfig.getStartTimeStr(),
dcJobConfig.getEndTimeStr());
result.getData().forEach(costDto -> {
DcBaseFinanceFee dcBaseFinanceFee = new DcBaseFinanceFee();
BeanUtils.copyProperties(costDto, dcBaseFinanceFee, "id");
dcBaseFinanceFee.setCreateTime(LocalDateTime.ofInstant(costDto.getCreateTime().toInstant(), ZoneId.systemDefault()));
//更新
int update = dcBaseFinanceFeeMapper.update(dcBaseFinanceFee, new LambdaQueryWrapper<DcBaseFinanceFee>()
.eq(DcBaseFinanceFee::getCostNo, dcBaseFinanceFee.getCostNo()));
//插入
if (update == 0) {
dcBaseFinanceFeeMapper.insert(dcBaseFinanceFee);
Integer pageNum = 1;
Integer pageSize = 100;
for (; ; ) {
CostResult<List<CostDto>> result = costApi.getCostList(dcJobConfig.getStartTimeStr(),
dcJobConfig.getEndTimeStr(),
pageNum,
pageSize);
if (ListUtil.isEmpty(result.getData())) {
break;
}
log.info("同步一条费用单,costNo:{}", costDto.getCostNo());
});
result.getData().forEach(costDto -> {
DcBaseFinanceFee dcBaseFinanceFee = new DcBaseFinanceFee();
BeanUtils.copyProperties(costDto, dcBaseFinanceFee, "id");
dcBaseFinanceFee.setCreateTime(LocalDateTime.ofInstant(costDto.getCreateTime().toInstant(), ZoneId.systemDefault()));
//更新
int update = dcBaseFinanceFeeMapper.update(dcBaseFinanceFee, new LambdaQueryWrapper<DcBaseFinanceFee>()
.eq(DcBaseFinanceFee::getCostNo, dcBaseFinanceFee.getCostNo()));
//插入
if (update == 0) {
dcBaseFinanceFeeMapper.insert(dcBaseFinanceFee);
}
log.info("同步一条费用单,costNo:{}", costDto.getCostNo());
});
pageNum++;
}
dcJobConfigMapper.updateById(dcJobConfig.refresh());
}
......@@ -146,8 +157,8 @@ public class SyncFeeService {
public void syncDailyFee() {
DcJobConfig dcJobConfig = dcJobConfigMapper.selectByName(baseSyncDailyFee);
LocalDate date = dcJobConfig.getStartTime().toLocalDate();
dcBaseFinanceFeeMapper.deleteDailyFee(date.minusDays(1L));
dcBaseFinanceFeeMapper.insertDailyFee(date.minusDays(1L));
dcBaseFinanceFeeMapper.deleteDailyFee(date);
dcBaseFinanceFeeMapper.insertDailyFee(date);
dcJobConfigMapper.updateById(dcJobConfig.refresh());
}
......
......@@ -10,14 +10,8 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
#mybatis plus 配置
mybatis-plus:
mapper-locations:
- classpath*:com/bailuntec/mapper/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#
profiles:
active: test
feign:
......
package com.bailuntec.job.service;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import javax.annotation.Resource;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/12/1 3:27 下午
*/
@SpringBootTest(classes = TestApp.class)
class SyncFeeServiceTest extends AbstractTestNGSpringContextTests {
@Resource
SyncFeeService syncFeeService;
@Test
void syncFinanceFee() {
syncFeeService.syncFinanceFee();
}
@Test
void syncLogistics() {
}
@Test
void syncManageCost() {
}
@Test
void syncDailyFee() {
}
}
package com.bailuntec.job.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.core.SpringVersion;
import org.springframework.test.context.ActiveProfiles;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/12/1 3:28 下午
*/
@EnableFeignClients(basePackages = {"com.bailuntec.api", "com.bailuntec.*.api"})
@Slf4j
@SpringBootApplication(scanBasePackages = "com.bailuntec")
@ActiveProfiles("test")
public class TestApp {
public static void main(String[] args) {
String version = SpringVersion.getVersion();
String version1 = SpringBootVersion.getVersion();
log.info("SpringVersion {}", version);
log.info("SpringBootVersion {}", version1);
SpringApplication.run(TestApp.class, args);
}
}
spring:
# 服务名称
application:
name: base-sync-fee
# 数据配置
datasource:
url: jdbc:mysql://gz-cdb-kp7s5i79.sql.tencentcdb.com:61691/bailun_datacenter?serverTimezone=GMT%2B8&characterEncoding=utf-8
username: root
password: '#7kfnymAM$Y9-Ntf'
driver-class-name: com.mysql.jdbc.Driver
main:
allow-bean-definition-overriding: true
profiles:
active: test
#mybatis plus 配置
mybatis-plus:
mapper-locations:
- classpath*:com/bailuntec/mapper/*.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#
feign:
hystrix:
enabled: false
client:
config:
default:
connectTimeout: 30000
readTimeout: 30000
......@@ -20,6 +20,12 @@
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......@@ -28,7 +34,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.3.RELEASE</version>
<configuration>
<mainClass>com.bailuntec.job.BalanceSheetApp</mainClass>
<mainClass>com.bailuntec.BalanceSheetApp</mainClass>
</configuration>
<executions>
<execution>
......
package com.bailuntec.job;
package com.bailuntec;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -16,7 +16,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
*/
@SpringBootApplication
@EnableScheduling
@ComponentScan("com.bailuntec")
@EnableFeignClients(basePackages = {"com.bailuntec.api", "com.bailuntec.*.api"})
public class BalanceSheetApp {
......
package com.bailuntec;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* <p>
* Swagger2配置类
* </p>
*
* @author robbendev
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
/**
* 创建API应用
* apiInfo() 增加API相关信息
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
*
* @return
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.bailuntec"))
.paths(PathSelectors.any())
.build()
;
}
/**
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
* 访问地址:http://项目实际地址/swagger-ui.html
*
* @return
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("资产负债表接口文档")
.description("")
.version("1.0")
.build();
}
}
package com.bailuntec.interfaces;
import com.bailuntec.application.IDcBalanceSheetNewModifyService;
import com.bailuntec.common.base.BaseResult;
import com.bailuntec.domain.DcBalanceSheetNewModify;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/12/3 1:41 下午
*/
@Api(tags = "资产负债表接口")
@RestController
@RequestMapping("/balanceSheetModify")
public class BalanceSheetModifyController {
@Resource
IDcBalanceSheetNewModifyService dcBalanceSheetNewModifyService;
@ApiOperation("资产负债表录入")
@PostMapping("/record")
public BaseResult<Void> record(@RequestBody DcBalanceSheetNewModify dcBalanceSheetNewModify) {
dcBalanceSheetNewModifyService.record(dcBalanceSheetNewModify);
return BaseResult.success();
}
}
......@@ -120,5 +120,25 @@ public class BalanceSheetJob {
}
}
/**
* 每天 生成新资产负债结果表
* companyValue 0
* companyName 百伦供应链
* <p>
* {@link}
* </p>
* 数据来源
*/
@Scheduled(cron = "0/1 * * * * ?")
public void generateBalanceSheetNewResult() {
try {
log.info("每分钟 生成新资产负债结果表 开始");
balanceSheetService.generateBalanceSheetNewResult();
log.info("每分钟 生成新资产负债结果表 结束");
} catch (Exception ex) {
log.error("每分钟 生成新资产负债结果表 异常:", ex);
}
}
}
package com.bailuntec.job.service;
import com.bailuntec.job.BalanceSheetApp;
import com.bailuntec.BalanceSheetApp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -8,7 +8,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDate;
......
......@@ -29,6 +29,13 @@
<artifactId>bailuntec-datacenter</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment