Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jilinzhongdianrenqun
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
吴超
jilinzhongdianrenqun
Commits
9d95b93c
Commit
9d95b93c
authored
Dec 30, 2025
by
zhangtw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入
parent
d0f62691
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
182 行增加
和
0 行删除
+182
-0
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmInboundServiceImpl.java
+45
-0
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmInboundRecordDao.xml
+137
-0
没有找到文件。
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmInboundServiceImpl.java
View file @
9d95b93c
package
com
.
scpyun
.
platform
.
jilinsscgsdp
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
import
com.scpyun.base.bean.Page
;
import
com.scpyun.base.core.annotation.Api
;
import
com.scpyun.base.core.annotation.ApiOperation
;
import
com.scpyun.base.core.exception.CustomException
;
import
com.scpyun.base.db.service.CommonService
;
import
com.scpyun.platform.jilinsscgsdp.utils.InboundFileListener
;
import
com.scpyun.platform.jilinsscgsdp.utils.MaterialFileListener
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.PostConstruct
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
...
...
@@ -293,6 +305,39 @@ public class KeyDmInboundServiceImpl {
return
ret
;
}
@ApiOperation
(
value
=
"导入入库单"
,
desc
=
"解析 Excel 导入入库信息"
)
public
Map
<
String
,
Object
>
importInbound
(
Map
<
String
,
Object
>
map
,
MultipartFile
file
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
try
{
InboundFileListener
listener
=
new
InboundFileListener
(
commonService
,
namespace
,
map
);
EasyExcel
.
read
(
file
.
getInputStream
(),
com
.
scpyun
.
platform
.
jilinsscgsdp
.
bean
.
entity
.
InboundImp
.
class
,
listener
).
sheet
().
headRowNumber
(
1
).
doRead
();
result
=
listener
.
getResult
();
}
catch
(
IOException
e
)
{
throw
new
CustomException
(
"导入失败"
);
}
return
result
;
}
@ApiOperation
(
value
=
"导入模板下载"
,
desc
=
"下载入库导入模板"
)
public
void
templateDownload
(
Map
<
String
,
Object
>
map
,
HttpServletResponse
response
)
{
response
.
setContentType
(
"application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
response
.
setCharacterEncoding
(
"utf-8"
);
try
{
String
fileName
=
URLEncoder
.
encode
(
"入库导入模板"
,
"UTF-8"
).
replaceAll
(
"\\+"
,
"%20"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename*=utf-8''"
+
fileName
+
".xlsx"
);
response
.
setHeader
(
"filename"
,
fileName
+
".xlsx"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"filename,Content-Disposition"
);
String
tpl
=
"keyInboundImp.xlsx"
;
Resource
resource
=
new
ClassPathResource
(
tpl
);
InputStream
is
=
resource
.
getInputStream
();
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
response
.
getOutputStream
()).
withTemplate
(
is
).
excelType
(
ExcelTypeEnum
.
XLSX
).
build
();
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
throw
new
CustomException
(
"模板下载失败"
);
}
}
}
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmInboundRecordDao.xml
View file @
9d95b93c
...
...
@@ -185,6 +185,143 @@
left join jl_key_dm_borrow_application as ba on bad.application_id = ba.id
where ba.id = #{id}
</select>
<!-- 将物料code为键做成字典-->
<select
id=
"getMaterialMap"
resultType=
"map"
>
select *
from jl_key_dm_material
where is_used = 1
</select>
<insert
id=
"batchInsertInboundMasters"
parameterType=
"map"
>
INSERT INTO jl_key_dm_inbound_record (
id,
inbound_no,
batch_no,
inbound_type,
inbound_status,
inbound_date,
is_used,
storage_location,
remark,
create_by,
create_time
) VALUES
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(
#{item.id},
#{item.inbound_no},
#{item.batch_no},
#{item.inbound_type},
#{item.inbound_status},
#{item.inbound_date},
#{item.is_used},
#{item.storage_location},
#{item.remark},
#{item.create_by},
#{item.create_time}
)
</foreach>
</insert>
<insert
id=
"batchInsertInboundDetails"
parameterType=
"map"
>
INSERT INTO jl_key_dm_inbound_detail (
id,
inbound_id,
material_id,
inbound_type,
inbound_quantity,
unit_price,
total_amount,
production_date,
expiry_date,
is_used,
create_by,
create_time
) VALUES
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(
#{item.id},
#{item.inbound_id},
#{item.material_id},
#{item.inbound_type},
#{item.inbound_quantity},
#{item.unit_price},
#{item.total_amount},
#{item.production_date},
#{item.expiry_date},
#{item.is_used},
#{item.create_by},
#{item.create_time}
)
</foreach>
</insert>
<update
id=
"batchUpdateMaterialStock"
parameterType=
"map"
>
UPDATE jl_key_dm_inventory
SET total_quantity = total_quantity + CASE id
<foreach
collection=
"list"
item=
"item"
>
WHEN #{item.material_id} THEN #{item.quantity}
</foreach>
ELSE 0
END,
update_time = NOW()
WHERE id IN
<foreach
collection=
"list"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item.material_id}
</foreach>
</update>
<insert
id=
"insertInboundMaster"
parameterType=
"map"
>
INSERT INTO jl_key_dm_inbound_record (
id,
inbound_no,
batch_no,
inbound_type,
inbound_status,
inbound_date,
is_used,
storage_location,
remark,
create_by,
create_time
) VALUES (
#{id},
#{inbound_no},
#{batch_no},
#{inbound_type},
#{inbound_status},
#{inbound_date},
#{is_used},
#{storage_location},
#{remark},
#{create_by},
#{create_time}
)
</insert>
<insert
id=
"insertInboundDetail"
parameterType=
"map"
>
INSERT INTO jl_key_dm_inbound_detail (
id,
inbound_id,
material_id,
inbound_type,
inbound_quantity,
unit_price,
total_amount,
production_date,
expiry_date,
create_by,
create_time
) VALUES (
#{id},
#{inbound_id},
#{material_id},
#{inbound_type},
#{inbound_quantity},
#{unit_price},
#{total_amount},
#{production_date},
#{expiry_date},
#{create_by},
#{create_time}
)
</insert>
</mapper>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论