Explorar el Código

封仓确认单bug修改

ZeroLiYi hace 1 año
padre
commit
f076a06599

+ 1 - 1
src/main/java/com/chinaitop/depot/storage/mapper/ClearanceConfirmationMapper.java

@@ -28,5 +28,5 @@ public interface ClearanceConfirmationMapper {
28 28
 
29 29
     Map<String, BigDecimal> getexcessLossQuantity(Integer warehouseId);
30 30
 
31
-    Map<String, String> getStoreHouse(Integer warehouseId);
31
+    Map<String, Object> getStoreHouse(Integer warehouseId);
32 32
 }

+ 2 - 0
src/main/java/com/chinaitop/depot/storage/mapper/GrainSituationCardMapper.xml

@@ -476,6 +476,7 @@
476 476
       cc.createdate,
477 477
       cc.updatedate,
478 478
       cc.fill_org_id,
479
+      o.org_name orgName,
479 480
       cc.keep_org_id,
480 481
       cc.storage_org_id,
481 482
       cc.warehouse_sealing_record_id,
@@ -507,6 +508,7 @@
507 508
               LEFT JOIN depot_qh.basic_enum tffs on xz.enumId = Bs.draftType
508 509
               LEFT JOIN depot_qh.basic_enum ccfs on xz.enumId = cc.keeping_way
509 510
               LEFT JOIN depot_qh.basic_enum cflx on xz.enumId = cc.storehouse_type
511
+              LEFT JOIN depot_qh.org_info o ON cc.fill_org_id = o.org_id
510 512
     where  cc.id=#{id}
511 513
   </select>
512 514
 

+ 8 - 1
src/main/java/com/chinaitop/depot/storage/service/impl/GrainSituationCardServiceImpl.java

@@ -168,11 +168,14 @@ public class GrainSituationCardServiceImpl implements GrainSituationCardService
168 168
         List<BusinessQcQualityInspection> bqqs =new ArrayList<>();
169 169
         BusinessQcQualityInspection businessQcQualityInspection=new BusinessQcQualityInspection();
170 170
         Map<Integer, List<String>> date =new HashMap<>();
171
+        Map<String,String> MAP=new HashMap<>();
171 172
         if(grainSituationCardVO.getCheckRecordIds()!=null) {
172 173
             String[] ids = grainSituationCardVO.getCheckRecordIds().split(",");
173 174
             for (int i = 0; i < ids.length; i++) {
174 175
                 //查询导检验类型,建议时间。。
175 176
                 businessQcQualityInspection=  businessQcQualityInspectionMapper.findByqualityId(ids[i]);
177
+                MAP.put("zjbgdh",businessQcQualityInspection.getZjbgdh());
178
+                MAP.put("jylb",businessQcQualityInspection.getJylb());
176 179
                 //查询质检明细
177 180
                 List<Map<String,Object>> itm =businessQcQualityInspectionItemMapper.findByqualityId(ids[i]);
178 181
                 date =    cat(itm);
@@ -182,10 +185,14 @@ public class GrainSituationCardServiceImpl implements GrainSituationCardService
182 185
                 businessQcQualityInspectionList.add(businessQcQualityInspection);
183 186
             }
184 187
         }
188
+        List<Map<String, String>> dataList = new ArrayList<>();
189
+        dataList.add(MAP);
190
+
191
+
185 192
         String fileName = "D:\\Temp\\aaa.xlsx";
186 193
         List<GrainSituationCardVO> data=new ArrayList<>();
187 194
         data.add(grainSituationCardVO);
188
-        ExcelExporter.exportToExcel(data,grainSituationCardWarehouseRecordList,businessQcQualityInspectionList,date,fileName);
195
+        ExcelExporter.exportToExcel(data,grainSituationCardWarehouseRecordList,dataList,date,fileName);
189 196
 
190 197
 
191 198
         return null;

+ 53 - 13
src/main/java/com/chinaitop/depot/storage/service/impl/WarehouseSealingRecordServiceImpl.java

@@ -14,6 +14,7 @@ import com.chinaitop.depot.storage.service.WarehouseSealingRecordService;
14 14
 import com.fasterxml.jackson.databind.ObjectMapper;
15 15
 import org.apache.commons.lang.ObjectUtils;
16 16
 import org.springframework.stereotype.Service;
17
+import org.springframework.transaction.annotation.Transactional;
17 18
 
18 19
 import javax.annotation.Resource;
19 20
 import javax.servlet.http.HttpServletRequest;
@@ -52,7 +53,7 @@ public class WarehouseSealingRecordServiceImpl implements WarehouseSealingRecord
52 53
     public WarehouseSealingRecord findByWarehouseSea(Integer id) {
53 54
         return WarehouseSealingRecordMapper.findByWarehouseSea(id);
54 55
     }
55
-
56
+    @Transactional
56 57
     @Override
57 58
     public Map<String, Object> saveOrUpdate(HttpServletRequest request, String warehouseSealingRecordJson, String userInfo) throws Exception {
58 59
         Map<String, Object> modelMap = new HashMap<String, Object>();
@@ -157,22 +158,32 @@ public class WarehouseSealingRecordServiceImpl implements WarehouseSealingRecord
157 158
         if(WarehouseSealingRecord.getStatus()==1){
158 159
             //查询出清确认单时间
159 160
             int sum =0;
160
-            Date cqsj;
161
-            BigDecimal cksl;
161
+            Date cqsj=new Date();
162
+            BigDecimal cksl=BigDecimal.valueOf(0.00);
162 163
             ClearanceConfirmation clearanceConfirmation = clearanceConfirmationMapper.selectCqqrd(WarehouseSealingRecord.getWarehouseId());
163
-            if(clearanceConfirmation.getUpdatedate()==null){
164
-                cqsj= new Date();
164
+            if(clearanceConfirmation!=null){
165
+                if(clearanceConfirmation.getUpdatedate()==null&&!"".equals(clearanceConfirmation.getUpdatedate())){
166
+                    cqsj= new Date();
167
+                }
168
+                cqsj =clearanceConfirmation.getUpdatedate();
165 169
             }
166
-             cqsj =clearanceConfirmation.getUpdatedate();
170
+
171
+
167 172
             //查询fcbgz
168 173
             Map map =new HashMap<>();
169 174
             map.put("warehouseId",WarehouseSealingRecord.getWarehouseId());
170 175
             map.put("cqsj",cqsj);
171 176
             map.put("fcsj",date);
172 177
             Map<String, Double> map1=clearanceConfirmationMapper.selectFcbgz(map);
173
-             cksl =BigDecimal.valueOf(map1.get("cksl"));
178
+            if(map1 != null && !map1.isEmpty()){
179
+                if(map1.get("cksl")!=null){
180
+                    cksl =BigDecimal.valueOf(map1.get("cksl"));
181
+                }
182
+
183
+            }
184
+
174 185
             Map<String,BigDecimal> mmap=clearanceConfirmationMapper.getexcessLossQuantity(WarehouseSealingRecord.getWarehouseId());
175
-            Map<String,String> stoMap =clearanceConfirmationMapper.getStoreHouse(WarehouseSealingRecord.getWarehouseId());
186
+            Map<String,Object> stoMap =clearanceConfirmationMapper.getStoreHouse(WarehouseSealingRecord.getWarehouseId());
176 187
             GrainSituationCard grainSituationCard =new GrainSituationCard();
177 188
             grainSituationCard.setCreatedate(date);
178 189
             grainSituationCard.setUpdatedate(date);
@@ -192,12 +203,41 @@ public class WarehouseSealingRecordServiceImpl implements WarehouseSealingRecord
192 203
             grainSituationCard.setOutQuantity(cksl);
193 204
             grainSituationCard.setFormWarehouseTime(WarehouseSealingRecord.getZhgxsj());
194 205
             grainSituationCard.setStorageOrgId(WarehouseSealingRecord.getOrgId());
195
-            grainSituationCard.setExcessLossQuantity(mmap.get("getexcessLossQuantity"));
206
+            BigDecimal getexcessLossQuantity =BigDecimal.valueOf(0.00);
207
+            if(mmap!=null&&!mmap.isEmpty()){
208
+                if(mmap.get("getexcessLossQuantity")!=null){
209
+                    getexcessLossQuantity=mmap.get("getexcessLossQuantity");
210
+                }
211
+
212
+            }
213
+            grainSituationCard.setExcessLossQuantity(getexcessLossQuantity);
196 214
             grainSituationCard.setGlfs(WarehouseSealingRecord.getGlfs());
197
-            grainSituationCard.setKeepingWay(Integer.parseInt(stoMap.get("keepingWay")));
198
-            grainSituationCard.setDesignCapacity(BigDecimal.valueOf(Double.parseDouble(stoMap.get("designCapacity"))));
199
-            grainSituationCard.setDrafttype(Integer.parseInt(stoMap.get("draftType")));
200
-            grainSituationCard.setTemperatureMeasureType(Integer.parseInt(stoMap.get("temperatureMeasureType")));
215
+
216
+            BigDecimal designCapacity =BigDecimal.valueOf(0.00);
217
+            Integer keepingWay =null;
218
+            Integer draftType =null;
219
+            Integer temperatureMeasureType=null;
220
+
221
+                    if(stoMap != null && !stoMap.isEmpty()){
222
+                        if(stoMap.get("designCapacity")!=null){
223
+                            System.out.println("============================="+stoMap.get("designCapacity").toString());
224
+                            designCapacity =(BigDecimal)(stoMap.get("designCapacity"));
225
+                        }
226
+                        if(stoMap.get("keepingWay")!=null){
227
+                            keepingWay=(Integer)(stoMap.get("keepingWay"));
228
+                        }
229
+                        if(stoMap.get("draftType")!=null){
230
+                            draftType =(Integer)(stoMap.get("draftType"));
231
+                        }
232
+                        if(stoMap.get("temperatureMeasureType")!=null){
233
+                            temperatureMeasureType =(Integer)(stoMap.get("temperatureMeasureType"));
234
+                        }
235
+                    }
236
+
237
+            grainSituationCard.setKeepingWay(keepingWay);
238
+            grainSituationCard.setDesignCapacity(designCapacity);
239
+            grainSituationCard.setDrafttype(draftType);
240
+            grainSituationCard.setTemperatureMeasureType(temperatureMeasureType);
201 241
             grainSituationCardMapper.insert(grainSituationCard);
202 242
         }
203 243
         modelMap.put("status", "success");

+ 86 - 41
src/main/java/com/chinaitop/depot/storage/utils/ExcelExporter.java

@@ -19,15 +19,13 @@ import java.util.*;
19 19
 public class ExcelExporter {
20 20
 
21 21
 
22
-        public static void exportToExcel(List<GrainSituationCardVO> data, List<GrainSituationCardWarehouseRecord> records, List<BusinessQcQualityInspection> bq, Map<Integer, List<String>> jsonData, String fileName) throws IOException{
22
+        public static void exportToExcel(List<GrainSituationCardVO> data, List<GrainSituationCardWarehouseRecord> records, List<Map<String, String>> dataList, Map<Integer, List<String>> inspectionItems, String fileName) throws IOException{
23 23
             XSSFWorkbook workbook = new XSSFWorkbook();
24 24
             XSSFSheet sheet = workbook.createSheet("原粮专卡");
25 25
 
26 26
             // 设置列标题和样式
27 27
             int rowIndex;
28
-            rowIndex= 1;
29
-            // 设置主标题并居中
30
-            Row titleRow = sheet.createRow(rowIndex++);
28
+            rowIndex= 0;
31 29
 
32 30
             Row headerRow = sheet.createRow(0);
33 31
             CellStyle headerCellStyle = workbook.createCellStyle();
@@ -100,20 +98,27 @@ public class ExcelExporter {
100 98
                         cell.setCellValue(card.getKeepingWayName() != null ? card.getKeepingWayName() : "无");
101 99
                     } else if ("通风方式".equals(field)) {
102 100
                         cell.setCellValue(card.getDrafttypeName() != null ? card.getDrafttypeName() : "无");
101
+                    } else if ("存储地点".equals(field)) {
102
+                        cell.setCellValue(card.getOrgName() != null ? card.getOrgName() : "无");
103
+                    }else if ("存储方式".equals(field)) {
104
+                        cell.setCellValue(card.getKeepingWay() == null ? 0 : card.getKeepingWay());
105
+                    }else if ("修改时间".equals(field)) {
106
+                        cell.setCellValue(card.getUpdatedate() == null ? "" : sdf.format(card.getUpdatedate()));
103 107
                     }
104 108
                 }
105 109
             }
106 110
 
107
-            rowIndex++; // 新增一行用于标题
108 111
 
109 112
             // 处理 GrainSituationCardWarehouseRecord 数据之前的表头
110 113
             rowIndex++; // 新增一行作为记录变更的表头行
111 114
             columnIndex = 0; // 重置列索引
115
+            Row headerForRowRecords = sheet.createRow(rowIndex);
112 116
             for (String field : getFieldsss()) {
113
-                Cell cell = sheet.createRow(rowIndex).createCell(columnIndex++);
117
+                Cell cell = headerForRowRecords.createCell(columnIndex++);
114 118
                 cell.setCellValue(field);
115 119
                 cell.setCellStyle(headerCellStyle);
116 120
             }
121
+            // 填充 GrainSituationCardWarehouseRecord 数据
117 122
             for (GrainSituationCardWarehouseRecord record : records) {
118 123
                 if (record == null) {
119 124
                     continue;
@@ -121,9 +126,10 @@ public class ExcelExporter {
121 126
 
122 127
                 rowIndex++; // 新增一行用于记录数据
123 128
                 columnIndex = 0;
124
-                Row row = sheet.createRow(rowIndex++);
125
-                for (String field : getFieldsss()) { // 假定使用getFieldsss()作为仓库记录的字段列表
126
-                    Cell cell = row.createCell(columnIndex++);
129
+                Row rowForRecord = sheet.createRow(rowIndex);
130
+                for (String field : getFieldsss()) {
131
+                    Cell cell = rowForRecord.createCell(columnIndex++);
132
+
127 133
                     if ("变更时间".equals(field)) {
128 134
                         cell.setCellValue(record.getChangeTime() == null ? "" : sdf.format(record.getChangeTime()));
129 135
                     } else if ("新货位号".equals(field)) {
@@ -133,50 +139,89 @@ public class ExcelExporter {
133 139
                     } else if ("变更原因".equals(field)) {
134 140
                         cell.setCellValue(record.getChangeReason() != null ? record.getChangeReason() : "无");
135 141
                     }
136
-                    // 根据需要继续添加其它字段的处理逻辑
142
+                    // 根据GrainSituationCardWarehouseRecord类的实际属性添加更多处理逻辑
137 143
                 }
138 144
             }
139 145
 
146
+            rowIndex++; // 新增一行作为记录变更的表头行
147
+            columnIndex = 0; // 重置列索引
148
+            // 确定所有可能的检验项目
149
+            Set<String> allInspectionCategories = new HashSet<>();
150
+            for (List<String> values : inspectionItems.values()) {
151
+                for (String item : values) {
152
+                    String category = item.split(":")[0].trim(); // 假设项目名称在冒号前
153
+                    allInspectionCategories.add(category);
154
+                }
155
+            }
156
+            rowIndex++;
157
+            // 创建表头
158
+            Row headerRow1 = sheet.createRow(0);
159
+            headerRow1.createCell(0).setCellValue("质检报告单号");
160
+            headerRow1.createCell(1).setCellValue("检验类别");
161
+            int colIndex = 2; // 从第三列开始放置动态检验项目
162
+            for (String category : allInspectionCategories) {
163
+                headerRow1.createCell(colIndex++).setCellValue(category);
164
+            }
165
+            // 检查inspectionItems是否只有一个键,如果是,则获取该键
166
+            Integer singleKeyId = inspectionItems.keySet().iterator().next();
140 167
 
168
+             rowIndex ++; // 从第二行开始写入数据
169
+            for (Map<String, String> data2 : dataList) {
170
+                Row dataRow = sheet.createRow(rowIndex++);
171
+                dataRow.createCell(0).setCellValue(data2.getOrDefault("zjbgdh", ""));
172
+                dataRow.createCell(1).setCellValue(data2.getOrDefault("jylb", ""));
141 173
 
142
-            rowIndex++; // 新增一行作为质量检验的表头行
143
-            headerRow.createCell(0).setCellValue("质检报告单号");
144
-            headerRow.createCell(1).setCellValue("检验时间");
145
-            columnIndex = 0; // 重置列索引
146
-            for (String field : getFieldss()) {
147
-                Cell cell = sheet.createRow(rowIndex).createCell(columnIndex++);
148
-                cell.setCellValue(field);
149
-                cell.setCellStyle(headerCellStyle);
174
+
175
+                // 填充动态检验项目值,这里直接根据单个键获取其值列表
176
+                List<String> items = inspectionItems.get(singleKeyId);
177
+
178
+                // 填充动态检验项目值
179
+                for (int i = 0; i < items.size(); i++) {
180
+                    String[] keyValue = items.get(i).split(": ");
181
+                    dataRow.createCell(i + 2).setCellValue(keyValue.length > 1 ? keyValue[1] : "");
182
+                }
150 183
             }
151
-//            // 填充数据
152
-            int rowNum = 1;
153
-//            for (Map<String, Object> record : jsonData) {
154
-//                Row row = sheet.createRow(rowNum++);
155
-//                row.createCell(0).setCellValue((String) record.get("zjbgdh"));
156
-//                row.createCell(1).setCellValue((String) record.get("jysj"));
157
-//
158
-//                // 填充动态检验项目值
159
-//                Map<String, Object> maps = (Map<String, Object>) record.get("maps");
160
-//                if (maps != null) {
161
-//                    List<String> items = (List<String>) maps.get(record.get("id").toString());
162
-//                    if (items != null) {
163
-//                        int col = 2; // 从第2列开始填充动态数据
164
-//                        for (String item : allInspectionItems) {
165
-//                            String value = "";
166
-//                            for (String checkItem : items) {
167
-//                                if (checkItem.startsWith(item + ":")) {
168
-//                                    value = checkItem.split(": ")[1];
169
-//                                    break;
184
+
185
+
186
+//            rowIndex++; // 新增一行作为质量检验的表头行
187
+//            columnIndex = 0; // 重置列索引
188
+//            Row rowForRecord = sheet.createRow(rowIndex);
189
+//            for (String field : getFieldss()) {
190
+//                Cell cell = sheet.createRow(rowIndex).createCell(columnIndex++);
191
+//                cell.setCellValue(field);
192
+//                cell.setCellStyle(headerCellStyle);
193
+//            }
194
+////            // 填充数据
195
+//            Row row = sheet.createRow(rowIndex++);
196
+//            for (Map<String, String> data2 : dataList) {
197
+//                if (data2 == null) {
198
+//                    continue;
199
+//                }
200
+//                row.createCell(0).setCellValue(data2.getOrDefault("zjbgdh", ""));
201
+//                row.createCell(1).setCellValue(data2.getOrDefault("jylb", ""));
202
+//                for (Map<Integer, Object> jd : jsonData) {
203
+//                    // 填充动态检验项目值
204
+//                    Map<String, Object> maps = (Map<String, Object>) jd.get("maps");
205
+//                    if (maps != null) {
206
+//                        List<String> items = (List<String>) maps.get(id.get("id").toString());
207
+//                        if (items != null) {
208
+//                            int col = 2; // 从第2列开始填充动态数据
209
+//                            for (String item : allInspectionItems) {
210
+//                                String value = "";
211
+//                                for (String checkItem : items) {
212
+//                                    if (checkItem.startsWith(item + ":")) {
213
+//                                        value = checkItem.split(": ")[1];
214
+//                                        break;
215
+//                                    }
170 216
 //                                }
171 217
 //                            }
218
+//                            row.createCell(col++).setCellValue(value);
172 219
 //                        }
173
-//                        row.createCell(col++).setCellValue(value);
174 220
 //                    }
175 221
 //                }
176 222
 //            }
177
-//        }
178 223
 //
179
-
224
+//        }
180 225
 
181 226
 
182 227
 
@@ -194,7 +239,7 @@ public class ExcelExporter {
194 239
     }
195 240
 
196 241
     private static String[] getFieldsss() {
197
-        return new String[]{"变更时间","新货位号"," 原货位号","变更原因"};
242
+        return new String[]{"变更时间","新货位号","原货位号","变更原因"};
198 243
     }
199 244
     private static String[] getFieldss() {
200 245
         return new String[]{"检验类型","质检报告单号","容重","水分","杂质","不完善粒","色泽,气味","硬度指数",