|
1
|
1
|
package com.lframework.xingyun.sc.procurement.controller.credit;
|
|
2
|
2
|
|
|
|
3
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
3
|
4
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
4
|
5
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
|
5
|
6
|
import com.lframework.starter.web.core.components.redis.RedisHandler;
|
|
...
|
...
|
@@ -8,23 +9,36 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
|
8
|
9
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
|
9
|
10
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
|
10
|
11
|
import com.lframework.starter.web.core.utils.JsonUtil;
|
|
|
12
|
+import com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto;
|
|
11
|
13
|
import com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerCredit;
|
|
12
|
14
|
import com.lframework.xingyun.sc.procurement.service.credit.ProcurementDomesticCustomerCreditService;
|
|
13
|
15
|
import com.lframework.xingyun.sc.procurement.vo.credit.CreateProcurementDomesticCustomerCreditVo;
|
|
14
|
16
|
import com.lframework.xingyun.sc.procurement.vo.credit.QueryProcurementDomesticCustomerCreditVo;
|
|
15
|
17
|
import com.lframework.xingyun.sc.procurement.vo.credit.UpdateProcurementDomesticCustomerCreditVo;
|
|
|
18
|
+import com.lframework.xingyun.sc.utils.ExcelUtil;
|
|
|
19
|
+import com.lframework.xingyun.sc.utils.ResponseUtil;
|
|
16
|
20
|
import io.swagger.annotations.Api;
|
|
17
|
21
|
import io.swagger.annotations.ApiImplicitParam;
|
|
18
|
22
|
import io.swagger.annotations.ApiOperation;
|
|
19
|
23
|
import javax.annotation.Resource;
|
|
|
24
|
+import javax.servlet.http.HttpServletResponse;
|
|
20
|
25
|
import javax.validation.Valid;
|
|
21
|
26
|
import javax.validation.constraints.NotBlank;
|
|
|
27
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
28
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
29
|
+import org.apache.poi.util.IOUtils;
|
|
|
30
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
22
|
31
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
23
|
32
|
import org.springframework.validation.annotation.Validated;
|
|
24
|
33
|
import org.springframework.web.bind.annotation.*;
|
|
|
34
|
+import java.io.*;
|
|
|
35
|
+import java.time.format.DateTimeFormatter;
|
|
|
36
|
+import java.util.HashMap;
|
|
|
37
|
+import java.util.Map;
|
|
25
|
38
|
|
|
26
|
39
|
@Api(tags = "采购内贸资信调查表")
|
|
27
|
40
|
@Validated
|
|
|
41
|
+@Slf4j
|
|
28
|
42
|
@RestController
|
|
29
|
43
|
@RequestMapping("/procurement/domesticCustomerCredit")
|
|
30
|
44
|
public class ProcurementDomesticCustomerCreditController extends DefaultBaseController {
|
|
...
|
...
|
@@ -112,4 +126,183 @@ public class ProcurementDomesticCustomerCreditController extends DefaultBaseCont |
|
112
|
126
|
return InvokeResultBuilder.success(data);
|
|
113
|
127
|
}
|
|
114
|
128
|
}
|
|
|
129
|
+
|
|
|
130
|
+ @ApiOperation("打印")
|
|
|
131
|
+ @GetMapping("/print")
|
|
|
132
|
+ public void printPurchaseOrder(@NotBlank(message = "id不能为空") String id, HttpServletResponse response) throws IOException {
|
|
|
133
|
+ ProcurementDomesticCustomerCredit data = procurementDomesticCustomerCreditService.findById(id);
|
|
|
134
|
+
|
|
|
135
|
+ try {
|
|
|
136
|
+ // 加载模板文件
|
|
|
137
|
+ ClassPathResource templateResource = new ClassPathResource("templates/procurementDomesticCustomerCreditTemplate.xlsx");
|
|
|
138
|
+
|
|
|
139
|
+ try (InputStream inputStream = templateResource.getStream();
|
|
|
140
|
+ Workbook workbook = new XSSFWorkbook(inputStream)) {
|
|
|
141
|
+ try {
|
|
|
142
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
143
|
+
|
|
|
144
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
145
|
+ dataMap.put("reviewDate", dateFormatter.format(data.getCreateTime()));
|
|
|
146
|
+ dataMap.put("unitName", data.getUnitName() == null ? "" : data.getUnitName());
|
|
|
147
|
+ String companyNature = "①、进口贸易□ ②、国内贸易□\n" +
|
|
|
148
|
+ "③、终端产废□ ④、其他□";
|
|
|
149
|
+ if ("IMPORT_TRADE".equals(data.getCompanyNature())) {
|
|
|
150
|
+ companyNature = "①、进口贸易☑ ②、国内贸易□\n" +
|
|
|
151
|
+ "③、终端产废□ ④、其他□";
|
|
|
152
|
+ } else if ("DOMESTIC_TRADE".equals(data.getCompanyNature())) {
|
|
|
153
|
+ companyNature = "①、进口贸易□ ②、国内贸易☑\n" +
|
|
|
154
|
+ "③、终端产废□ ④、其他□";
|
|
|
155
|
+ } else if ("TERMINAL_WASTE".equals(data.getCompanyNature())) {
|
|
|
156
|
+ companyNature = "①、进口贸易□ ②、国内贸易□\n" +
|
|
|
157
|
+ "③、终端产废☑ ④、其他□";
|
|
|
158
|
+ } else if ("OTHER".equals(data.getCompanyNature())) {
|
|
|
159
|
+ companyNature = "①、进口贸易□ ②、国内贸易□\n" +
|
|
|
160
|
+ "③、终端产废□ ④、其他☑";
|
|
|
161
|
+ }
|
|
|
162
|
+ dataMap.put("companyNature", companyNature);
|
|
|
163
|
+ dataMap.put("bankName", data.getBankName() == null ? "" : data.getBankName());
|
|
|
164
|
+ dataMap.put("bankAccount", data.getBankAccount() == null ? "" : data.getBankAccount());
|
|
|
165
|
+ dataMap.put("registeredCapital", data.getRegisteredCapital() == null ? "" : data.getRegisteredCapital());
|
|
|
166
|
+ dataMap.put("legalRepresentative", data.getLegalRepresentative() == null ? "" : data.getLegalRepresentative());
|
|
|
167
|
+ dataMap.put("companyEstablishedTime", data.getCompanyEstablishedTime() == null ? "" : data.getCompanyEstablishedTime().format(dateFormatter));
|
|
|
168
|
+ dataMap.put("address", data.getAddress() == null ? "" : data.getAddress());
|
|
|
169
|
+ dataMap.put("businessPrincipal", data.getBusinessPrincipal() == null ? "" : data.getBusinessPrincipal());
|
|
|
170
|
+ dataMap.put("businessPrincipalPosition", data.getBusinessPrincipalPosition() == null ? "" : data.getBusinessPrincipalPosition());
|
|
|
171
|
+ dataMap.put("businessPrincipalPhone", data.getBusinessPrincipalPhone() == null ? "" : data.getBusinessPrincipalPhone());
|
|
|
172
|
+ dataMap.put("legalBusinessRelation", data.getLegalBusinessRelation() == null ? "" : data.getLegalBusinessRelation());
|
|
|
173
|
+ dataMap.put("factoryOfficeProperty", data.getFactoryOfficeProperty() == null ? "" : data.getFactoryOfficeProperty());
|
|
|
174
|
+ dataMap.put("factoryOfficeArea", data.getFactoryOfficeArea() == null ? "" : data.getFactoryOfficeArea());
|
|
|
175
|
+ dataMap.put("warehouseYardProperty", data.getWarehouseYardProperty() == null ? "" : data.getWarehouseYardProperty());
|
|
|
176
|
+ dataMap.put("warehouseYardArea", data.getWarehouseYardArea() == null ? "" : data.getWarehouseYardArea());
|
|
|
177
|
+ dataMap.put("mainEquipment", data.getMainEquipment() == null ? "" : data.getMainEquipment());
|
|
|
178
|
+ dataMap.put("normalInventory", data.getNormalInventory() == null ? "" : data.getNormalInventory());
|
|
|
179
|
+ dataMap.put("mainVarieties", data.getMainVarieties() == null ? "" : data.getMainVarieties());
|
|
|
180
|
+ dataMap.put("monthlyPurchaseVolume", data.getMonthlyPurchaseVolume() == null ? "" : data.getMonthlyPurchaseVolume());
|
|
|
181
|
+ String purchaseSource = " 国外进口□/本企业报废□/零散收购□/其它□";
|
|
|
182
|
+ if ("FOREIGN_IMPORTS".equals(data.getPurchaseSource())) {
|
|
|
183
|
+ purchaseSource = " 国外进口☑/本企业报废□/零散收购□/其它□";
|
|
|
184
|
+ } else if ("SCRAPPED_COMPANY".equals(data.getPurchaseSource())) {
|
|
|
185
|
+ purchaseSource = " 国外进口□/本企业报废☑/零散收购□/其它□";
|
|
|
186
|
+ } else if ("SCATTERED_TAKEOVER".equals(data.getPurchaseSource())) {
|
|
|
187
|
+ purchaseSource = " 国外进口□/本企业报废□/零散收购☑/其它□";
|
|
|
188
|
+ } else if ("OTHER".equals(data.getPurchaseSource())) {
|
|
|
189
|
+ purchaseSource = " 国外进口□/本企业报废□/零散收购□/其它☑";
|
|
|
190
|
+ }
|
|
|
191
|
+ dataMap.put("purchaseSource", purchaseSource);
|
|
|
192
|
+ dataMap.put("stockInProductName", data.getStockInProductName() == null ? "" : data.getStockInProductName());
|
|
|
193
|
+ dataMap.put("productName", data.getProductName() == null ? "" : data.getProductName());
|
|
|
194
|
+ dataMap.put("capacity", data.getCapacity() == null ? "" : data.getCapacity());
|
|
|
195
|
+ dataMap.put("salesChannel", data.getSalesChannel() == null ? "" : data.getSalesChannel());
|
|
|
196
|
+ String hasPreferentialPolicy;
|
|
|
197
|
+ if (data.getHasPreferentialPolicy()) {
|
|
|
198
|
+ hasPreferentialPolicy = "是☑/否□";
|
|
|
199
|
+ } else {
|
|
|
200
|
+ hasPreferentialPolicy = "是□/否☑";
|
|
|
201
|
+ }
|
|
|
202
|
+ dataMap.put("hasPreferentialPolicy", hasPreferentialPolicy);
|
|
|
203
|
+ String investInFutures;
|
|
|
204
|
+ if (data.getInvestInFutures()) {
|
|
|
205
|
+ investInFutures = "是☑/否□";
|
|
|
206
|
+ } else {
|
|
|
207
|
+ investInFutures = "是□/否☑";
|
|
|
208
|
+ }
|
|
|
209
|
+ dataMap.put("investInFutures", investInFutures);
|
|
|
210
|
+ String hasPenaltyRecord;
|
|
|
211
|
+ if (data.getHasPenaltyRecord()) {
|
|
|
212
|
+ hasPenaltyRecord = "是☑/否□";
|
|
|
213
|
+ } else {
|
|
|
214
|
+ hasPenaltyRecord = "是□/否☑";
|
|
|
215
|
+ }
|
|
|
216
|
+ dataMap.put("hasPenaltyRecord", hasPenaltyRecord);
|
|
|
217
|
+ String businessScopeMatch;
|
|
|
218
|
+ if (data.getBusinessScopeMatch()) {
|
|
|
219
|
+ businessScopeMatch = "是☑/否□";
|
|
|
220
|
+ } else {
|
|
|
221
|
+ businessScopeMatch = "是□/否☑";
|
|
|
222
|
+ }
|
|
|
223
|
+ dataMap.put("businessScopeMatch", businessScopeMatch);
|
|
|
224
|
+ dataMap.put("firstCooperationYear", data.getFirstCooperationYear() == null ? "" : data.getFirstCooperationYear());
|
|
|
225
|
+ String operationMode = "买断自提□\n" + "送货到厂□";
|
|
|
226
|
+ if ("BUYOUT_SELF-PICKUP".equals(data.getOperationMode())) {
|
|
|
227
|
+ operationMode = "买断自提☑\n" + "送货到厂□";
|
|
|
228
|
+ } else if ("DELIVERY_FACTORY".equals(data.getOperationMode())){
|
|
|
229
|
+ operationMode = "买断自提□\n" + "送货到厂☑";
|
|
|
230
|
+ }
|
|
|
231
|
+ dataMap.put("operationMode", operationMode);
|
|
|
232
|
+ String hasFailedPlanRecord;
|
|
|
233
|
+ if (data.getHasFailedPlanRecord()) {
|
|
|
234
|
+ hasFailedPlanRecord = "是☑/否□";
|
|
|
235
|
+ } else {
|
|
|
236
|
+ hasFailedPlanRecord = "是□/否☑";
|
|
|
237
|
+ }
|
|
|
238
|
+ dataMap.put("hasFailedPlanRecord", hasFailedPlanRecord);
|
|
|
239
|
+ String hasPlanPerformanceIssue;
|
|
|
240
|
+ if (data.getHasPlanPerformanceIssue()) {
|
|
|
241
|
+ hasPlanPerformanceIssue = "是☑/否□";
|
|
|
242
|
+ } else {
|
|
|
243
|
+ hasPlanPerformanceIssue = "是□/否☑";
|
|
|
244
|
+ }
|
|
|
245
|
+ dataMap.put("hasPlanPerformanceIssue", hasPlanPerformanceIssue);
|
|
|
246
|
+ String isNewDevelopment = "新客户□/再接轨□/老客户□";
|
|
|
247
|
+ if ("REGULAR_CUSTOMER".equals(data.getIsNewDevelopment())) {
|
|
|
248
|
+ isNewDevelopment = "新客户□/再接轨□/老客户☑";
|
|
|
249
|
+ } else if ("NEW_CUSTOMER".equals(data.getIsNewDevelopment())){
|
|
|
250
|
+ isNewDevelopment = "新客户☑/再接轨□/老客户□";
|
|
|
251
|
+ } else if ("REALIGN_WITH".equals(data.getIsNewDevelopment())){
|
|
|
252
|
+ isNewDevelopment = "新客户□/再接轨☑/老客户□";
|
|
|
253
|
+ }
|
|
|
254
|
+ dataMap.put("isNewDevelopment", isNewDevelopment);
|
|
|
255
|
+ dataMap.put("accountingProcess", data.getAccountingProcess() == null ? "" : data.getAccountingProcess());
|
|
|
256
|
+ String invoiceNameMatch;
|
|
|
257
|
+ if (data.getInvoiceNameMatch()) {
|
|
|
258
|
+ invoiceNameMatch = "是☑/否□";
|
|
|
259
|
+ } else {
|
|
|
260
|
+ invoiceNameMatch = "是□/否☑";
|
|
|
261
|
+ }
|
|
|
262
|
+ dataMap.put("invoiceNameMatch", invoiceNameMatch);
|
|
|
263
|
+ String outboundProcessStandard;
|
|
|
264
|
+ if (data.getOutboundProcessStandard()) {
|
|
|
265
|
+ outboundProcessStandard = "是☑/否□";
|
|
|
266
|
+ } else {
|
|
|
267
|
+ outboundProcessStandard = "是□/否☑";
|
|
|
268
|
+ }
|
|
|
269
|
+ dataMap.put("outboundProcessStandard", outboundProcessStandard);
|
|
|
270
|
+ dataMap.put("transportMode", data.getTransportMode() == null ? "" : data.getTransportMode());
|
|
|
271
|
+ dataMap.put("commonMaterialIssue", data.getCommonMaterialIssue() == null ? "" : data.getCommonMaterialIssue());
|
|
|
272
|
+ dataMap.put("otherIssue", data.getOtherIssue() == null ? "" : data.getOtherIssue());
|
|
|
273
|
+
|
|
|
274
|
+ DomesticReviewerDto reviewer = procurementDomesticCustomerCreditService.getReviewerById(id);
|
|
|
275
|
+ if (reviewer == null) {
|
|
|
276
|
+ reviewer = new DomesticReviewerDto();
|
|
|
277
|
+ }
|
|
|
278
|
+ //供应部
|
|
|
279
|
+ dataMap.put("supplyDepartment", reviewer.getSupplyDepartment() == null ? "" : reviewer.getSupplyDepartment());
|
|
|
280
|
+ //供应管理科
|
|
|
281
|
+ dataMap.put("supplyManagementSection", reviewer.getSupplyManagementSection() == null ? "" : reviewer.getSupplyManagementSection());
|
|
|
282
|
+ //采购处
|
|
|
283
|
+ dataMap.put("procurementOffice", reviewer.getProcurementOffice() == null ? "" : reviewer.getProcurementOffice());
|
|
|
284
|
+ //制单人
|
|
|
285
|
+ dataMap.put("createBy", data.getCreateBy());
|
|
|
286
|
+
|
|
|
287
|
+ ExcelUtil.processTemplate(workbook, dataMap);
|
|
|
288
|
+
|
|
|
289
|
+ ResponseUtil.setExcelResponseHead(response, data.getUnitName() + "-内贸客户资信调查表打印.xlsx");
|
|
|
290
|
+ // 写入响应流
|
|
|
291
|
+ workbook.write(response.getOutputStream());
|
|
|
292
|
+ response.getOutputStream().flush();
|
|
|
293
|
+
|
|
|
294
|
+ } finally {
|
|
|
295
|
+ IOUtils.closeQuietly(workbook);
|
|
|
296
|
+ }
|
|
|
297
|
+
|
|
|
298
|
+ } catch (FileNotFoundException e) {
|
|
|
299
|
+ throw new RuntimeException("模板文件不存在: templates/procurementDomesticCustomerCreditTemplate.xlsx", e);
|
|
|
300
|
+ } catch (IOException e) {
|
|
|
301
|
+ throw new RuntimeException("无法读取模板文件: templates/procurementDomesticCustomerCreditTemplate.xlsx", e);
|
|
|
302
|
+ }
|
|
|
303
|
+ } catch (Exception e) {
|
|
|
304
|
+ log.error("内贸客户资信调查表导出失败: {}", e.getMessage(), e);
|
|
|
305
|
+ throw new RuntimeException("内贸客户资信调查表导出失败:", e);
|
|
|
306
|
+ }
|
|
|
307
|
+ }
|
|
115
|
308
|
} |
...
|
...
|
|