|
1
|
package com.lframework.xingyun.sc.procurement.controller.credit;
|
1
|
package com.lframework.xingyun.sc.procurement.controller.credit;
|
|
2
|
|
2
|
|
|
|
|
3
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
3
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
4
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
4
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
5
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
|
5
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
6
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
|
@@ -8,24 +9,39 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
|
@@ -8,24 +9,39 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
|
8
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
9
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
|
9
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
10
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
|
10
|
import com.lframework.starter.web.core.utils.JsonUtil;
|
11
|
import com.lframework.starter.web.core.utils.JsonUtil;
|
|
|
|
12
|
+import com.lframework.xingyun.sc.procurement.dto.ForeignTradeReviewerDto;
|
|
11
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
|
13
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit;
|
|
12
|
import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService;
|
14
|
import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService;
|
|
13
|
import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo;
|
15
|
import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementForeignTradeCreditVo;
|
|
14
|
import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo;
|
16
|
import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementForeignTradeCreditVo;
|
|
15
|
import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
|
17
|
import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementForeignTradeCreditVo;
|
|
|
|
18
|
+import com.lframework.xingyun.sc.utils.ExcelUtil;
|
|
|
|
19
|
+import com.lframework.xingyun.sc.utils.ResponseUtil;
|
|
16
|
import io.swagger.annotations.Api;
|
20
|
import io.swagger.annotations.Api;
|
|
17
|
import io.swagger.annotations.ApiImplicitParam;
|
21
|
import io.swagger.annotations.ApiImplicitParam;
|
|
18
|
import io.swagger.annotations.ApiOperation;
|
22
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
23
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
24
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
25
|
+import org.apache.poi.util.IOUtils;
|
|
|
|
26
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
27
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
20
|
import org.springframework.validation.annotation.Validated;
|
28
|
import org.springframework.validation.annotation.Validated;
|
|
21
|
import org.springframework.web.bind.annotation.*;
|
29
|
import org.springframework.web.bind.annotation.*;
|
|
22
|
|
30
|
|
|
23
|
import javax.annotation.Resource;
|
31
|
import javax.annotation.Resource;
|
|
|
|
32
|
+import javax.servlet.http.HttpServletResponse;
|
|
24
|
import javax.validation.Valid;
|
33
|
import javax.validation.Valid;
|
|
25
|
import javax.validation.constraints.NotBlank;
|
34
|
import javax.validation.constraints.NotBlank;
|
|
|
|
35
|
+import java.io.FileNotFoundException;
|
|
|
|
36
|
+import java.io.IOException;
|
|
|
|
37
|
+import java.io.InputStream;
|
|
|
|
38
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
39
|
+import java.util.HashMap;
|
|
|
|
40
|
+import java.util.Map;
|
|
26
|
|
41
|
|
|
27
|
@Api(tags = "采购外贸资信调查表")
|
42
|
@Api(tags = "采购外贸资信调查表")
|
|
28
|
@Validated
|
43
|
@Validated
|
|
|
|
44
|
+@Slf4j
|
|
29
|
@RestController
|
45
|
@RestController
|
|
30
|
@RequestMapping("/procurement/foreignTradeCredit")
|
46
|
@RequestMapping("/procurement/foreignTradeCredit")
|
|
31
|
public class ProcurementForeignTradeCreditController extends DefaultBaseController {
|
47
|
public class ProcurementForeignTradeCreditController extends DefaultBaseController {
|
|
@@ -103,4 +119,115 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll |
|
@@ -103,4 +119,115 @@ public class ProcurementForeignTradeCreditController extends DefaultBaseControll |
|
103
|
}
|
119
|
}
|
|
104
|
return InvokeResultBuilder.success(data);
|
120
|
return InvokeResultBuilder.success(data);
|
|
105
|
}
|
121
|
}
|
|
|
|
122
|
+
|
|
|
|
123
|
+ @ApiOperation("打印")
|
|
|
|
124
|
+ @GetMapping("/print")
|
|
|
|
125
|
+ public void printPurchaseOrder(@NotBlank(message = "id不能为空") String id, HttpServletResponse response) throws IOException {
|
|
|
|
126
|
+ ProcurementForeignTradeCredit data = procurementForeignTradeCreditService.findById(id);
|
|
|
|
127
|
+
|
|
|
|
128
|
+ try {
|
|
|
|
129
|
+ // 加载模板文件
|
|
|
|
130
|
+ ClassPathResource templateResource = new ClassPathResource("templates/procurementForeignTradeCreditTemplate.xlsx");
|
|
|
|
131
|
+
|
|
|
|
132
|
+ try (InputStream inputStream = templateResource.getStream();
|
|
|
|
133
|
+ Workbook workbook = new XSSFWorkbook(inputStream)) {
|
|
|
|
134
|
+ try {
|
|
|
|
135
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
136
|
+
|
|
|
|
137
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
138
|
+
|
|
|
|
139
|
+ dataMap.put("reviewDate", dateFormatter.format(data.getCreateTime()));
|
|
|
|
140
|
+ dataMap.put("unitName", data.getUnitName() == null ? "" : data.getUnitName());
|
|
|
|
141
|
+ dataMap.put("companyNature", data.getCompanyNature() == null ? "" : data.getCompanyNature());
|
|
|
|
142
|
+ dataMap.put("legalRepresentative", data.getLegalRepresentative() == null ? "" : data.getLegalRepresentative());
|
|
|
|
143
|
+ dataMap.put("phoneAndFax", data.getPhoneAndFax() == null ? "" : data.getPhoneAndFax());
|
|
|
|
144
|
+ dataMap.put("registrationCertificateNo", data.getRegistrationCertificateNo() == null ? "" : data.getRegistrationCertificateNo());
|
|
|
|
145
|
+ dataMap.put("address", data.getAddress() == null ? "" : data.getAddress());
|
|
|
|
146
|
+ dataMap.put("domesticBusinessPrincipal", data.getDomesticBusinessPrincipal() == null ? "" : data.getDomesticBusinessPrincipal());
|
|
|
|
147
|
+ dataMap.put("principalCertificateNo", data.getPrincipalCertificateNo() == null ? "" : data.getPrincipalCertificateNo());
|
|
|
|
148
|
+ dataMap.put("establishedTimeAndYardScale", data.getEstablishedTimeAndYardScale() == null ? "" : data.getEstablishedTimeAndYardScale());
|
|
|
|
149
|
+ dataMap.put("overallBusinessVarietiesScale", data.getOverallBusinessVarietiesScale() == null ? "" : data.getOverallBusinessVarietiesScale());
|
|
|
|
150
|
+ dataMap.put("exportToDomesticTime", data.getExportToDomesticTime() == null ? "" : data.getExportToDomesticTime());
|
|
|
|
151
|
+ dataMap.put("exportToDomesticScaleVarieties", data.getExportToDomesticScaleVarieties() == null ? "" : data.getExportToDomesticScaleVarieties());
|
|
|
|
152
|
+ dataMap.put("cooperatingDomesticCompanies", data.getCooperatingDomesticCompanies() == null ? "" : data.getCooperatingDomesticCompanies());
|
|
|
|
153
|
+ dataMap.put("cooperationEffect", data.getCooperationEffect() == null ? "" : data.getCooperationEffect());
|
|
|
|
154
|
+ dataMap.put("supplierInspection", data.getSupplierInspection() == null ? "" : data.getSupplierInspection());
|
|
|
|
155
|
+ dataMap.put("domesticSalesOfficeInspection", data.getDomesticSalesOfficeInspection() == null ? "" : data.getDomesticSalesOfficeInspection());
|
|
|
|
156
|
+ dataMap.put("guaranteeLetter", data.getGuaranteeLetter() == null ? "" : data.getGuaranteeLetter());
|
|
|
|
157
|
+ dataMap.put("contractDispute", data.getContractDispute() == null ? "" : data.getContractDispute());
|
|
|
|
158
|
+ dataMap.put("insuranceTransportMode", data.getInsuranceTransportMode() == null ? "" : data.getInsuranceTransportMode());
|
|
|
|
159
|
+ dataMap.put("detentionDemurrageFee", data.getDetentionDemurrageFee() == null ? "" : data.getDetentionDemurrageFee());
|
|
|
|
160
|
+ dataMap.put("operationVariety", data.getOperationVariety() == null ? "" : data.getOperationVariety());
|
|
|
|
161
|
+ dataMap.put("operationScale", data.getOperationScale() == null ? "" : data.getOperationScale());
|
|
|
|
162
|
+ dataMap.put("pricingMode", data.getPricingMode() == null ? "" : data.getPricingMode());
|
|
|
|
163
|
+ dataMap.put("settlementMethod", data.getSettlementMethod() == null ? "" : data.getSettlementMethod());
|
|
|
|
164
|
+ dataMap.put("weightDifferenceAgreement", data.getWeightDifferenceAgreement() == null ? "" : data.getWeightDifferenceAgreement());
|
|
|
|
165
|
+ dataMap.put("qualityStandard", data.getQualityStandard() == null ? "" : data.getQualityStandard());
|
|
|
|
166
|
+ String A = "□";
|
|
|
|
167
|
+ String B = "□";
|
|
|
|
168
|
+ String C = "□";
|
|
|
|
169
|
+ String D = "□";
|
|
|
|
170
|
+ if ("A".equals(data.getSupplierCategory())) {
|
|
|
|
171
|
+ A = "☑";
|
|
|
|
172
|
+ } else if ("B".equals(data.getSupplierCategory())) {
|
|
|
|
173
|
+ B = "☑";
|
|
|
|
174
|
+ } else if ("C".equals(data.getSupplierCategory())) {
|
|
|
|
175
|
+ C = "☑";
|
|
|
|
176
|
+ } else if ("D".equals(data.getSupplierCategory())) {
|
|
|
|
177
|
+ D = "☑";
|
|
|
|
178
|
+ }
|
|
|
|
179
|
+ dataMap.put("A", A);
|
|
|
|
180
|
+ dataMap.put("B", B);
|
|
|
|
181
|
+ dataMap.put("C", C);
|
|
|
|
182
|
+ dataMap.put("D", D);
|
|
|
|
183
|
+ dataMap.put("schemeOperationTime", data.getSchemeOperationTime() == null ? "" : data.getSchemeOperationTime());
|
|
|
|
184
|
+ dataMap.put("schemeOperationMode", data.getSchemeOperationMode() == null ? "" : data.getSchemeOperationMode());
|
|
|
|
185
|
+ dataMap.put("schemeOperationVariety", data.getSchemeOperationVariety() == null ? "" : data.getSchemeOperationVariety());
|
|
|
|
186
|
+ dataMap.put("schemeOperationQuantity", data.getSchemeOperationQuantity() == null ? "" : data.getSchemeOperationQuantity());
|
|
|
|
187
|
+ dataMap.put("shippingRequirement", data.getShippingRequirement() == null ? "" : data.getShippingRequirement());
|
|
|
|
188
|
+ dataMap.put("paymentMethod", data.getPaymentMethod() == null ? "" : data.getPaymentMethod());
|
|
|
|
189
|
+ dataMap.put("nextReviewTime", data.getNextReviewTime() == null ? "" : data.getNextReviewTime().format(dateFormatter));
|
|
|
|
190
|
+ dataMap.put("reviewDepartment", data.getReviewDepartment() == null ? "" : data.getReviewDepartment());
|
|
|
|
191
|
+
|
|
|
|
192
|
+
|
|
|
|
193
|
+ ForeignTradeReviewerDto reviewer = procurementForeignTradeCreditService.getReviewerById(id);
|
|
|
|
194
|
+ if (reviewer == null) {
|
|
|
|
195
|
+ reviewer = new ForeignTradeReviewerDto();
|
|
|
|
196
|
+ }
|
|
|
|
197
|
+ //总经理
|
|
|
|
198
|
+ dataMap.put("generalManager", reviewer.getGeneralManager() == null ? "" : reviewer.getGeneralManager());
|
|
|
|
199
|
+ //营销分管
|
|
|
|
200
|
+ dataMap.put("marketingManagement", reviewer.getMarketingManagement() == null ? "" : reviewer.getMarketingManagement());
|
|
|
|
201
|
+ //法务
|
|
|
|
202
|
+ dataMap.put("legalAffairs", reviewer.getLegalAffairs() == null ? "" : reviewer.getLegalAffairs());
|
|
|
|
203
|
+ //供应部
|
|
|
|
204
|
+ dataMap.put("supplyDepartment", reviewer.getSupplyDepartment() == null ? "" : reviewer.getSupplyDepartment());
|
|
|
|
205
|
+ //供应管理科
|
|
|
|
206
|
+ dataMap.put("supplyManagementSection", reviewer.getSupplyManagementSection() == null ? "" : reviewer.getSupplyManagementSection());
|
|
|
|
207
|
+ //外贸业务科
|
|
|
|
208
|
+ dataMap.put("foreignTradeBusinessDepartment", reviewer.getForeignTradeBusinessDepartment() == null ? "" : reviewer.getForeignTradeBusinessDepartment());
|
|
|
|
209
|
+ //制单人
|
|
|
|
210
|
+ dataMap.put("createBy", data.getCreateBy());
|
|
|
|
211
|
+
|
|
|
|
212
|
+ ExcelUtil.processTemplate(workbook, dataMap);
|
|
|
|
213
|
+
|
|
|
|
214
|
+ ResponseUtil.setExcelResponseHead(response, data.getUnitName() + "-外贸客户资信调查表打印.xlsx");
|
|
|
|
215
|
+ // 写入响应流
|
|
|
|
216
|
+ workbook.write(response.getOutputStream());
|
|
|
|
217
|
+ response.getOutputStream().flush();
|
|
|
|
218
|
+
|
|
|
|
219
|
+ } finally {
|
|
|
|
220
|
+ IOUtils.closeQuietly(workbook);
|
|
|
|
221
|
+ }
|
|
|
|
222
|
+
|
|
|
|
223
|
+ } catch (FileNotFoundException e) {
|
|
|
|
224
|
+ throw new RuntimeException("模板文件不存在: templates/procurementForeignTradeCreditTemplate.xlsx", e);
|
|
|
|
225
|
+ } catch (IOException e) {
|
|
|
|
226
|
+ throw new RuntimeException("无法读取模板文件: templates/procurementForeignTradeCreditTemplate.xlsx", e);
|
|
|
|
227
|
+ }
|
|
|
|
228
|
+ } catch (Exception e) {
|
|
|
|
229
|
+ log.error("外贸客户资信调查表导出失败: {}", e.getMessage(), e);
|
|
|
|
230
|
+ throw new RuntimeException("外贸客户资信调查表导出失败:", e);
|
|
|
|
231
|
+ }
|
|
|
|
232
|
+ }
|
|
106
|
} |
233
|
} |