Commit bfec1bf4 by yubin

Merge remote-tracking branch 'origin/master'

parents d1b4d4ab 69a8a9fc
package com.scpyun.platform.jilinsscgsdp.bean.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class InboundImp {
@ExcelProperty(value = "入库单号", index = 0)
private String inbound_no;
@ExcelProperty(value = "批次号", index = 1)
private String batch_no;
@ExcelProperty(value = "入库日期", index = 2)
private String inbound_date;
@ExcelProperty(value = "存放位置", index = 3)
private String storage_location;
@ExcelProperty(value = "备注", index = 4)
private String remark;
@ExcelProperty(value = "物料编号", index = 5)
private String material_code;
@ExcelProperty(value = "物料名称", index = 6)
private String material_name;
@ExcelProperty(value = "入库数量", index = 7)
private String inbound_quantity;
@ExcelProperty(value = "单价", index = 8)
private String unit_price;
@ExcelProperty(value = "生产日期", index = 9)
private String production_date;
@ExcelProperty(value = "有效期至", index = 10)
private String expiry_date;
}
...@@ -84,7 +84,6 @@ public class KeyDmBorrowServiceImpl { ...@@ -84,7 +84,6 @@ public class KeyDmBorrowServiceImpl {
} }
map.put("expected_return_date", expected_return_date); map.put("expected_return_date", expected_return_date);
if (id == null || String.valueOf(id).trim().isEmpty()) { if (id == null || String.valueOf(id).trim().isEmpty()) {
map.put("id",UUID.randomUUID().toString());
map.put("application_no","borrow"); map.put("application_no","borrow");
map.put("applicant_id",user.get("id")); map.put("applicant_id",user.get("id"));
map.put("applicant_name", user.get("name")); map.put("applicant_name", user.get("name"));
......
package com.scpyun.platform.jilinsscgsdp.service.impl; 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.bean.Page;
import com.scpyun.base.core.annotation.Api; import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation; import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException; import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct; 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.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
...@@ -293,6 +305,39 @@ public class KeyDmInboundServiceImpl { ...@@ -293,6 +305,39 @@ public class KeyDmInboundServiceImpl {
return ret; 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("模板下载失败");
}
}
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
INSERT INTO jl_key_dm_borrow_application_detail( INSERT INTO jl_key_dm_borrow_application_detail(
id,application_id,material_id,material_code,material_name,apply_quantity,unit,issue_remark,returned_quantity,damaged_quantity,is_used,create_by,create_time id,application_id,material_id,material_code,material_name,apply_quantity,unit,issue_remark,returned_quantity,damaged_quantity,is_used,create_by,create_time
) VALUES ( ) VALUES (
#{id},#{application_id},#{material_id},#{material_code},#{material_name},#{apply_quantity},#{unit},#{issue_remark},COALESCE(#{returned_quantity},0),COALESCE(#{damaged_quantity},0),1,#{_user.id},NOW() UUID(),#{application_id},#{material_id},#{material_code},#{material_name},#{apply_quantity},#{unit},#{issue_remark},COALESCE(#{returned_quantity},0),COALESCE(#{damaged_quantity},0),1,#{_user.id},NOW()
) )
</insert> </insert>
......
...@@ -185,6 +185,143 @@ ...@@ -185,6 +185,143 @@
left join jl_key_dm_borrow_application as ba on bad.application_id = ba.id left join jl_key_dm_borrow_application as ba on bad.application_id = ba.id
where ba.id = #{id} where ba.id = #{id}
</select> </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> </mapper>
...@@ -33,10 +33,12 @@ ...@@ -33,10 +33,12 @@
</foreach> </foreach>
</insert> </insert>
<select id="selectLogsByApplicationId" parameterType="map" resultType="map"> <select id="selectLogsByApplicationId" parameterType="map" resultType="map">
SELECT ml.*,m.material_name SELECT ml.*,m.material_name,u.name
FROM jl_key_dm_material_log as ml FROM jl_key_dm_material_log as ml
left join jl_key_dm_material as m left join jl_key_dm_material as m
on ml.material_id = m.id on ml.material_id = m.id
left join jl_key_dm_user as u
on u.id = ml.create_by
WHERE relation_id = #{id} WHERE relation_id = #{id}
AND ml.is_used = 1 ORDER BY ml.create_time ASC AND ml.is_used = 1 ORDER BY ml.create_time ASC
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论