Commit d3b6f6b4 by yinyong

付款单-拉取财务出纳附件信息

parent 09814895
package com.blt.other.other_cost.config;
import com.blt.other.other_cost.job.CashierAnnexSyncJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CashierAnnexSyncConfiguration {
// 扫描主体列表时间间隔:(秒)
private static final int TIME = 86400;
@Bean
public JobDetail cashierAnnexSyncJobDetail() {
return JobBuilder.newJob(CashierAnnexSyncJob.class).withIdentity("cashierAnnexSyncJob").storeDurably().build();
}
@Bean
public Trigger cashierAnnexSyncJobTrigger() {
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(TIME).repeatForever();
return TriggerBuilder.newTrigger().forJob(cashierAnnexSyncJobDetail())
.withIdentity("cashierAnnexSyncTrigger")
.withSchedule(simpleScheduleBuilder).build();
}
}
......@@ -590,4 +590,14 @@ public class CostCheckController {
costLogService.save(costNo,Integer.parseInt(updateuserid),"操作结清");
return result;
}
@GetMapping("downCashierAnnex")
public Map<String, Object> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) {
AxiosUtil.setCors(response, request);
Map<String, Object> result = new HashMap<>();
List<String> list = costCashiercallbackService.downCashierAnnex();
result.put("success", true);
result.put("msg", "出纳单附件下载完成");
return result;
}
}
package com.blt.other.other_cost.job;
import com.blt.other.other_cost.service.CostCashiercallbackService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
@Slf4j
public class CashierAnnexSyncJob extends QuartzJobBean {
@Autowired
private CostCashiercallbackService costCashiercallbackService;
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
costCashiercallbackService.downCashierAnnex();
}
}
......@@ -2,7 +2,11 @@ package com.blt.other.other_cost.service;
import com.blt.other.other_database.model.CostCashiercallbackDomain;
import java.util.List;
public interface CostCashiercallbackService {
Integer saveCostCashiercallbackResponse(CostCashiercallbackDomain costCashiercallbackDomain);
List<String> downCashierAnnex();
}
......@@ -101,4 +101,8 @@ public interface CostService {
Integer getCostStatusByNo(String costNo);
List<CostDto> getCostByRejectStatus();
List<String> listCostNo();
Integer updateCashierAnnex(String costNo, String filePath, String downloadUrl);
}
package com.blt.other.other_cost.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.blt.other.other_commons.utils.PathUtil;
import com.blt.other.other_cost.dao.CostCashiercallbackDao;
import com.blt.other.other_cost.service.CostCashiercallbackService;
import com.blt.other.other_cost.service.CostService;
import com.blt.other.other_database.model.CashiercallbackDomain;
import com.blt.other.other_database.model.CostCashiercallbackDomain;
import com.blt.other.other_purchasing.dao.CashiercallbackDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Service
public class CostCashiercallbackServiceImpl implements CostCashiercallbackService {
@Autowired
CostCashiercallbackDao costCashiercallbackDao;
@Autowired
private CostService costService;
@Value("${url.api.getCashierAnnexApi}")
private String getCashierAnnexApi;
@Autowired
private RestTemplate restTemplate;
@Override
public Integer saveCostCashiercallbackResponse(CostCashiercallbackDomain costCashiercallbackDomain) {
return costCashiercallbackDao.insert(costCashiercallbackDomain);
}
@Override
public List<String> downCashierAnnex() {
List<String> costNoList = costService.listCostNo();
HttpHeaders headers = new HttpHeaders();
HttpEntity<Resource> httpEntity = new HttpEntity<Resource>(headers);
for(String costNo: costNoList) {
String baseUrl = getCashierAnnexApi + "?sourceCode=newCost&detailName=" + costNo;
String downloadStr = "";
try {
ResponseEntity<String> download = restTemplate.getForEntity(baseUrl, String.class);
downloadStr = download.getBody();
}catch (Exception e){
continue;
}
Map<String, String> map = JSONObject.parseObject(downloadStr, Map.class);
String downloadUrl = map.get("annex");
if(!downloadUrl.contains("uploadfile")) {
continue;
}
ResponseEntity<byte[]> response = restTemplate.exchange(downloadUrl, HttpMethod.GET, httpEntity, byte[].class);
try {
String filePath = PathUtil.getBasePath()+PathUtil.getPath("cashier/"+costNo+"/"+UUID.randomUUID()+"."+response.getHeaders().getContentType().getSubtype());
File file = new File(filePath);
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(response.getBody());
fos.flush();
fos.close();
costService.updateCashierAnnex(costNo, filePath, downloadUrl);
} catch (IOException e) {
e.printStackTrace();
}
}
return costNoList;
}
}
......@@ -362,6 +362,17 @@ public class CostServiceImpl implements CostService {
}
@Override
public List<String> listCostNo() {
return costDao.listCostNo();
}
@Override
public Integer updateCashierAnnex(String costNo, String filePath, String downloadUrl) {
return costDao.updateCashierAnnex(costNo, filePath, downloadUrl);
}
@Override
public CostDomain getCostDomainByNo(String costNo) {
CostDomain costDomain = costDao.selectByCostNo(costNo);
return costDomain;
......
......@@ -70,6 +70,7 @@ url:
getAllSubLogisticsFinansysApi: http://supplier.bailuntec.com/Api/GetSubLogisticsSupplier
# 获取耗材
getConsumablesApi: ${url.api.baseFinansysUrl}/Cashier/Cashier/BuyCashierRecordList
getCashierAnnexApi: ${url.api.baseFinansysUrl}/API/API/GetCashierAnnex
cookie:
......
......@@ -559,4 +559,12 @@
<select id="getCostByRejectStatus" resultType="com.blt.other.other_cost.dto.CostDto">
select * from cost where cost_status = 3 and reject_type = 1 and reject_time <![CDATA[<]]> date_sub(now(),INTERVAL 1 DAY)
</select>
<select id="listCostNo" resultType="java.lang.String">
select cost_no from cost where cost_form = 1 and cost_status = 4 and cashier_file_path = ''
</select>
<update id="updateCashierAnnex">
update cost set cashier_file_path = #{filePath}, cashier_download_path = #{downloadUrl} where cost_no = #{costNo}
</update>
</mapper>
\ No newline at end of file
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