Commit b8a7dbe5382ba0db9d7a10ed9b3e3d9df560948d
1 parent
273906e9
添加容器导入和导出导入模板
Showing
6 changed files
with
103 additions
and
21 deletions
.idea/workspace.xml
... | ... | @@ -2,22 +2,11 @@ |
2 | 2 | <project version="4"> |
3 | 3 | <component name="ChangeListManager"> |
4 | 4 | <list default="true" id="9ff7b25e-dc1a-4859-8a0c-00039489e359" name="Default Changelist" comment=""> |
5 | - <change afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/config/excelTemplate/controller/excelTemplateController.java" afterDir="false" /> | |
6 | - <change afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/config/excelTemplate/domain/ExcelTemplate.java" afterDir="false" /> | |
7 | - <change afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/config/excelTemplate/mapper/ExcelTemplateMapper.java" afterDir="false" /> | |
8 | - <change afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/config/excelTemplate/service/ExcelTemplateService.java" afterDir="false" /> | |
9 | - <change afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/config/excelTemplate/service/ExcelTemplateServiceImpl.java" afterDir="false" /> | |
10 | - <change afterPath="$PROJECT_DIR$/src/main/resources/mybatis/config/ExcelTemplateMapper.xml" afterDir="false" /> | |
11 | - <change afterPath="$PROJECT_DIR$/src/main/resources/templates/config/excelTemplate/add.html" afterDir="false" /> | |
12 | - <change afterPath="$PROJECT_DIR$/src/main/resources/templates/config/excelTemplate/edit.html" afterDir="false" /> | |
13 | - <change afterPath="$PROJECT_DIR$/src/main/resources/templates/config/excelTemplate/excelTemplate.html" afterDir="false" /> | |
14 | - <change beforePath="$PROJECT_DIR$/.idea/MyBatisCodeHelperDatasource.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/MyBatisCodeHelperDatasource.xml" afterDir="false" /> | |
15 | - <change beforePath="$PROJECT_DIR$/.idea/dataSources.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" /> | |
16 | - <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | |
17 | - <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/shipment/shipmentDetail/controller/ShipmentDetailController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/shipment/shipmentDetail/controller/ShipmentDetailController.java" afterDir="false" /> | |
18 | - <change beforePath="$PROJECT_DIR$/src/main/resources/templates/config/receiptType/edit.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/config/receiptType/edit.html" afterDir="false" /> | |
19 | - <change beforePath="$PROJECT_DIR$/src/main/resources/templates/config/receiptType/receiptType.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/config/receiptType/receiptType.html" afterDir="false" /> | |
20 | - <change beforePath="$PROJECT_DIR$/src/main/resources/templates/tool/import/import.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/tool/import/import.html" afterDir="false" /> | |
5 | + <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/controller/ContainerController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/controller/ContainerController.java" afterDir="false" /> | |
6 | + <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/domain/Container.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/domain/Container.java" afterDir="false" /> | |
7 | + <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/service/ContainerService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/service/ContainerService.java" afterDir="false" /> | |
8 | + <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/service/ContainerServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/container/service/ContainerServiceImpl.java" afterDir="false" /> | |
9 | + <change beforePath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/material/service/MaterialService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/huaheng/pc/general/material/service/MaterialService.java" afterDir="false" /> | |
21 | 10 | </list> |
22 | 11 | <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> |
23 | 12 | <option name="SHOW_DIALOG" value="false" /> |
... | ... | @@ -52,6 +41,13 @@ |
52 | 41 | <item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" /> |
53 | 42 | <item name="wms_v2: schema" type="76f4a085:MysqlImplModel$Schema" /> |
54 | 43 | </path> |
44 | + <path> | |
45 | + <item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" /> | |
46 | + <item name="@172.16.29.45" type="feb32156:DbDataSourceImpl" /> | |
47 | + <item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" /> | |
48 | + <item name="wms_v2: schema" type="76f4a085:MysqlImplModel$Schema" /> | |
49 | + <item name="container: table" type="285a2a93:MysqlImplModel$Table" /> | |
50 | + </path> | |
55 | 51 | </expand> |
56 | 52 | <select /> |
57 | 53 | </component> |
... | ... | @@ -212,7 +208,7 @@ |
212 | 208 | <workItem from="1565829438280" duration="3502000" /> |
213 | 209 | <workItem from="1565832950552" duration="86000" /> |
214 | 210 | <workItem from="1565833039573" duration="288000" /> |
215 | - <workItem from="1565833342181" duration="18527000" /> | |
211 | + <workItem from="1565833342181" duration="20192000" /> | |
216 | 212 | </task> |
217 | 213 | <task id="LOCAL-00001" summary="添加库位、库位类型增删改查接口"> |
218 | 214 | <created>1565226427512</created> |
... | ... | @@ -312,7 +308,14 @@ |
312 | 308 | <option name="project" value="LOCAL" /> |
313 | 309 | <updated>1565856453372</updated> |
314 | 310 | </task> |
315 | - <option name="localTasksCounter" value="15" /> | |
311 | + <task id="LOCAL-00015" summary="添加导入模板列表"> | |
312 | + <created>1565861068194</created> | |
313 | + <option name="number" value="00015" /> | |
314 | + <option name="presentableId" value="LOCAL-00015" /> | |
315 | + <option name="project" value="LOCAL" /> | |
316 | + <updated>1565861068194</updated> | |
317 | + </task> | |
318 | + <option name="localTasksCounter" value="16" /> | |
316 | 319 | <servers /> |
317 | 320 | </component> |
318 | 321 | <component name="TypeScriptGeneratedFilesManager"> |
... | ... | @@ -360,7 +363,8 @@ |
360 | 363 | <MESSAGE value="添加承运商" /> |
361 | 364 | <MESSAGE value="添加物料导入、导出模板,添加Excel导入导出配置文件" /> |
362 | 365 | <MESSAGE value="添加承运商页面,入库单类型" /> |
363 | - <option name="LAST_COMMIT_MESSAGE" value="添加承运商页面,入库单类型" /> | |
366 | + <MESSAGE value="添加导入模板列表" /> | |
367 | + <option name="LAST_COMMIT_MESSAGE" value="添加导入模板列表" /> | |
364 | 368 | </component> |
365 | 369 | <component name="XDebuggerManager"> |
366 | 370 | <breakpoint-manager> |
... | ... |
src/main/java/com/huaheng/pc/general/container/controller/ContainerController.java
... | ... | @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
6 | 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
7 | 7 | import com.huaheng.common.support.Convert; |
8 | 8 | import com.huaheng.common.utils.StringUtils; |
9 | +import com.huaheng.common.utils.poi.ExcelUtil; | |
9 | 10 | import com.huaheng.common.utils.security.ShiroUtils; |
10 | 11 | import com.huaheng.framework.aspectj.lang.annotation.Log; |
11 | 12 | import com.huaheng.framework.aspectj.lang.constant.BusinessType; |
... | ... | @@ -16,6 +17,7 @@ import com.huaheng.framework.web.page.TableDataInfo; |
16 | 17 | import com.huaheng.framework.web.page.TableSupport; |
17 | 18 | import com.huaheng.pc.general.container.domain.Container; |
18 | 19 | import com.huaheng.pc.general.container.service.ContainerService; |
20 | +import com.huaheng.pc.general.material.domain.Material; | |
19 | 21 | import io.swagger.annotations.Api; |
20 | 22 | import io.swagger.annotations.ApiOperation; |
21 | 23 | import io.swagger.annotations.ApiParam; |
... | ... | @@ -23,6 +25,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; |
23 | 25 | import org.springframework.stereotype.Controller; |
24 | 26 | import org.springframework.ui.ModelMap; |
25 | 27 | import org.springframework.web.bind.annotation.*; |
28 | +import org.springframework.web.multipart.MultipartFile; | |
26 | 29 | |
27 | 30 | import javax.annotation.Resource; |
28 | 31 | import java.util.List; |
... | ... | @@ -155,4 +158,22 @@ public class ContainerController extends BaseController { |
155 | 158 | } |
156 | 159 | return AjaxResult.success("删除成功!"); |
157 | 160 | } |
161 | + | |
162 | + @PostMapping("/importData") | |
163 | + @ResponseBody | |
164 | + public AjaxResult importData(MultipartFile file) throws Exception { | |
165 | + ExcelUtil<Material> util = new ExcelUtil<>(Material.class); | |
166 | + List<Material> materialList = util.importExcel(file.getInputStream()); | |
167 | + String operName = ShiroUtils.getLoginName(); | |
168 | + Boolean updateSupport = false; | |
169 | + String message = containerService.importMaterial(materialList, updateSupport, operName); | |
170 | + return AjaxResult.success(message); | |
171 | + } | |
172 | + | |
173 | + @GetMapping("/importTemplate") | |
174 | + @ResponseBody | |
175 | + public AjaxResult importTemplate() { | |
176 | + ExcelUtil<Material> util = new ExcelUtil<>(Material.class); | |
177 | + return util.importTemplateExcel("容器"); | |
178 | + } | |
158 | 179 | } |
... | ... |
src/main/java/com/huaheng/pc/general/container/domain/Container.java
... | ... | @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; |
4 | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
5 | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
6 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
7 | +import com.huaheng.framework.aspectj.lang.annotation.Excel; | |
7 | 8 | import io.swagger.annotations.ApiModel; |
8 | 9 | import io.swagger.annotations.ApiModelProperty; |
9 | 10 | import lombok.Data; |
... | ... | @@ -20,6 +21,7 @@ public class Container implements Serializable { |
20 | 21 | */ |
21 | 22 | @TableId(value = "id", type = IdType.AUTO) |
22 | 23 | @ApiModelProperty(value="内部号") |
24 | + @Excel(name = "内部号", type = Excel.Type.EXPORT) | |
23 | 25 | private Integer id; |
24 | 26 | |
25 | 27 | /** |
... | ... | @@ -27,6 +29,7 @@ public class Container implements Serializable { |
27 | 29 | */ |
28 | 30 | @TableField(value = "name") |
29 | 31 | @ApiModelProperty(value="容器名字") |
32 | + @Excel(name = "容器名字") | |
30 | 33 | private String name; |
31 | 34 | |
32 | 35 | /** |
... | ... | @@ -34,6 +37,7 @@ public class Container implements Serializable { |
34 | 37 | */ |
35 | 38 | @TableField(value = "code") |
36 | 39 | @ApiModelProperty(value="容器编码") |
40 | + @Excel(name = "容器编码") | |
37 | 41 | private String code; |
38 | 42 | |
39 | 43 | /** |
... | ... | @@ -41,6 +45,7 @@ public class Container implements Serializable { |
41 | 45 | */ |
42 | 46 | @TableField(value = "warehouseCode") |
43 | 47 | @ApiModelProperty(value="仓库代码") |
48 | + @Excel(name = "仓库编码") | |
44 | 49 | private String warehouseCode; |
45 | 50 | |
46 | 51 | /** |
... | ... | @@ -48,6 +53,7 @@ public class Container implements Serializable { |
48 | 53 | */ |
49 | 54 | @TableField(value = "companyCode") |
50 | 55 | @ApiModelProperty(value="货主编码") |
56 | + @Excel(name = "货主编码") | |
51 | 57 | private String companyCode; |
52 | 58 | |
53 | 59 | @TableField(value = "locationCode") |
... | ... | @@ -59,6 +65,7 @@ public class Container implements Serializable { |
59 | 65 | */ |
60 | 66 | @TableField(value = "containerType") |
61 | 67 | @ApiModelProperty(value="容器类型") |
68 | + @Excel(name = "容器类型") | |
62 | 69 | private String containerType; |
63 | 70 | |
64 | 71 | /** |
... | ... | @@ -101,6 +108,7 @@ public class Container implements Serializable { |
101 | 108 | */ |
102 | 109 | @TableField(value = "enable") |
103 | 110 | @ApiModelProperty(value="启用;0—禁用") |
111 | + @Excel(name = "是否启用", prompt = "启用;0 禁用:1") | |
104 | 112 | private Integer enable; |
105 | 113 | |
106 | 114 | /** |
... | ... |
src/main/java/com/huaheng/pc/general/container/service/ContainerService.java
... | ... | @@ -3,10 +3,13 @@ package com.huaheng.pc.general.container.service; |
3 | 3 | import com.huaheng.framework.web.domain.AjaxResult; |
4 | 4 | import com.huaheng.pc.general.container.domain.Container; |
5 | 5 | import com.baomidou.mybatisplus.extension.service.IService; |
6 | +import com.huaheng.pc.general.material.domain.Material; | |
6 | 7 | |
7 | 8 | import java.util.List; |
8 | 9 | |
9 | 10 | public interface ContainerService extends IService<Container>{ |
10 | 11 | |
11 | - public AjaxResult<List<Container>> insertContainer(String type, Integer quantity); | |
12 | + AjaxResult<List<Container>> insertContainer(String type, Integer quantity); | |
13 | + | |
14 | + String importMaterial(List<Container> containerList, Boolean updateSupport, String operName); | |
12 | 15 | } |
... | ... |
src/main/java/com/huaheng/pc/general/container/service/ContainerServiceImpl.java
... | ... | @@ -2,12 +2,15 @@ package com.huaheng.pc.general.container.service; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
5 | +import com.huaheng.common.exception.BusinessException; | |
5 | 6 | import com.huaheng.common.exception.service.ServiceException; |
7 | +import com.huaheng.common.utils.StringUtils; | |
6 | 8 | import com.huaheng.common.utils.security.ShiroUtils; |
7 | 9 | import com.huaheng.framework.web.domain.AjaxResult; |
8 | 10 | import com.huaheng.pc.config.containerType.domain.ContainerType; |
9 | 11 | import com.huaheng.pc.config.containerType.service.ContainerTypeService; |
10 | 12 | import com.huaheng.pc.general.container.domain.ContainerStatus; |
13 | +import com.huaheng.pc.general.material.domain.Material; | |
11 | 14 | import org.apache.commons.collections.functors.ConstantFactory; |
12 | 15 | import org.springframework.stereotype.Service; |
13 | 16 | import javax.annotation.Resource; |
... | ... | @@ -65,4 +68,47 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container |
65 | 68 | return 0; |
66 | 69 | } |
67 | 70 | } |
71 | + | |
72 | + public String importMaterial(List<Container> containerList, Boolean updateSupport, String operName){ | |
73 | + if (StringUtils.isNull(containerList) || containerList.size() == 0) { | |
74 | + throw new BusinessException("导入数据不能为空!"); | |
75 | + } | |
76 | + int successNum = 0; | |
77 | + int failureNum = 0; | |
78 | + StringBuilder successMsg = new StringBuilder(); | |
79 | + StringBuilder failureMsg = new StringBuilder(); | |
80 | + for (Container container : containerList) { | |
81 | + try { | |
82 | + LambdaQueryWrapper<Container> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
83 | + lambdaQueryWrapper.eq(Container::getCode, container.getCode()); | |
84 | + // 验证是否存在这个容器 | |
85 | + Container m = this.getOne(lambdaQueryWrapper); | |
86 | + | |
87 | + if (StringUtils.isNull(m)) { | |
88 | + System.out.println(ShiroUtils.getLoginName()); | |
89 | + container.setCreatedBy(ShiroUtils.getUser().getLoginName()); | |
90 | + container.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
91 | + this.save(container); | |
92 | + successNum++; | |
93 | + successMsg.append("<br/>" + successNum + "、编码 " + container.getCode() + " 导入成功"); | |
94 | + } else { | |
95 | + String msg = "<br/>" + failureNum + "、编码" + container.getCode() + " 已存在:"; | |
96 | + failureMsg.append(msg); | |
97 | + log.error(msg); | |
98 | + } | |
99 | + } catch (Exception e) { | |
100 | + failureNum++; | |
101 | + String msg = "<br/>" + failureNum + "、编码" + container.getCode() + " 导入失败:"; | |
102 | + failureMsg.append(msg + e.getMessage()); | |
103 | + log.error(msg, e); | |
104 | + } | |
105 | + } | |
106 | + if (failureNum > 0) { | |
107 | + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); | |
108 | + throw new BusinessException(failureMsg.toString()); | |
109 | + } else { | |
110 | + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); | |
111 | + } | |
112 | + return successMsg.toString(); | |
113 | + } | |
68 | 114 | } |
... | ... |
src/main/java/com/huaheng/pc/general/material/service/MaterialService.java
... | ... | @@ -11,7 +11,7 @@ public interface MaterialService extends IService<Material>{ |
11 | 11 | AjaxResult removeByIds(String ids); |
12 | 12 | |
13 | 13 | |
14 | - public String importMaterial(List<Material> materialList, Boolean updateSupport,String operName); | |
14 | + String importMaterial(List<Material> materialList, Boolean updateSupport,String operName); | |
15 | 15 | |
16 | 16 | |
17 | 17 | } |
... | ... |