Commit fc10533a by zhanglt

出库信息,物资领用模块调整

parent 5d0ed57c
......@@ -6,6 +6,7 @@ package com.jeeplus.modules.warehouse.materialrequisition.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
/**
* 领用明细表Entity
......@@ -16,12 +17,16 @@ public class MaterialRequisitionInfo extends DataEntity<MaterialRequisitionInfo>
private static final long serialVersionUID = 1L;
private MaterialRequisition materialRequisition; // 物资领用主表ID
private String ledgerInfo; // 物资台账明细ID
private LedgerInfo ledgerInfo; // 物资台账明细ID
public MaterialRequisitionInfo() {
super();
}
public MaterialRequisitionInfo(MaterialRequisition materialRequisition) {
this.materialRequisition = materialRequisition;
}
public MaterialRequisitionInfo(String id){
super(id);
}
......@@ -36,11 +41,11 @@ public class MaterialRequisitionInfo extends DataEntity<MaterialRequisitionInfo>
}
@ExcelField(title="物资台账明细ID", align=2, sort=2)
public String getLedgerInfo() {
public LedgerInfo getLedgerInfo() {
return ledgerInfo;
}
public void setLedgerInfo(String ledgerInfo) {
public void setLedgerInfo(LedgerInfo ledgerInfo) {
this.ledgerInfo = ledgerInfo;
}
......
......@@ -35,6 +35,9 @@
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="materialRequisition != null and materialRequisition.id != null and materialRequisition.id != ''">
AND a.material_requisition_id = #{materialRequisition.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
......@@ -54,6 +57,10 @@
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="materialRequisition != null and materialRequisition.id != null and materialRequisition.id != ''">
AND a.material_requisition_id = #{materialRequisition.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
......
......@@ -31,7 +31,7 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
public MaterialRequisition get(String id) {
MaterialRequisition materialRequisition = super.get(id);
materialRequisition.setMaterialRequisitionInfoList(materialRequisitionInfoMapper.findList(new MaterialRequisitionInfo(materialRequisition.getId())));
materialRequisition.setMaterialRequisitionInfoList(materialRequisitionInfoMapper.findList(new MaterialRequisitionInfo(materialRequisition)));
return materialRequisition;
}
......@@ -47,6 +47,7 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
public void save(MaterialRequisition materialRequisition) {
super.save(materialRequisition);
for (MaterialRequisitionInfo materialRequisitionInfo : materialRequisition.getMaterialRequisitionInfoList()){
materialRequisitionInfo.setMaterialRequisition(materialRequisition);
if (materialRequisitionInfo.getId() == null){
continue;
}
......@@ -67,7 +68,7 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
@Transactional(readOnly = false)
public void delete(MaterialRequisition materialRequisition) {
super.delete(materialRequisition);
materialRequisitionInfoMapper.delete(new MaterialRequisitionInfo(materialRequisition.getId()));
materialRequisitionInfoMapper.delete(new MaterialRequisitionInfo(materialRequisition));
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
import com.google.common.collect.Lists;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
/**
* 出库信息Entity
* @author zhanglt
* @version 2023-02-14
*/
public class Outbound extends DataEntity<Outbound> {
private static final long serialVersionUID = 1L;
private String number; // 出库单号
private String relationId; // 相关表单ID
private Date outboundTime; // 出库时间
private String type; // 出库分类
private String operator; // 操作人
private Date beginOutboundTime; // 开始 出库时间
private Date endOutboundTime; // 结束 出库时间
private List<OutboundInfo> outboundInfoList = Lists.newArrayList(); // 子表列表
public Outbound() {
super();
}
public Outbound(String id){
super(id);
}
@ExcelField(title="出库单号", align=2, sort=1)
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
@ExcelField(title="相关表单ID", align=2, sort=2)
public String getRelationId() {
return relationId;
}
public void setRelationId(String relationId) {
this.relationId = relationId;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="出库时间", align=2, sort=3)
public Date getOutboundTime() {
return outboundTime;
}
public void setOutboundTime(Date outboundTime) {
this.outboundTime = outboundTime;
}
@ExcelField(title="出库分类", dictType="", align=2, sort=4)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@ExcelField(title="操作人", align=2, sort=5)
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public Date getBeginOutboundTime() {
return beginOutboundTime;
}
public void setBeginOutboundTime(Date beginOutboundTime) {
this.beginOutboundTime = beginOutboundTime;
}
public Date getEndOutboundTime() {
return endOutboundTime;
}
public void setEndOutboundTime(Date endOutboundTime) {
this.endOutboundTime = endOutboundTime;
}
public List<OutboundInfo> getOutboundInfoList() {
return outboundInfoList;
}
public void setOutboundInfoList(List<OutboundInfo> outboundInfoList) {
this.outboundInfoList = outboundInfoList;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.entity;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
/**
* 出库单明细表Entity
* @author zhanglt
* @version 2023-02-14
*/
public class OutboundInfo extends DataEntity<OutboundInfo> {
private static final long serialVersionUID = 1L;
private Outbound outbound; // 出库单主表id
private LedgerInfo ledgerInfo; // 台账明细表id
public OutboundInfo() {
super();
}
public OutboundInfo(String id){
super(id);
}
public OutboundInfo(Outbound outbound, LedgerInfo ledgerInfo) {
this.outbound = outbound;
this.ledgerInfo = ledgerInfo;
}
public OutboundInfo(Outbound outbound) {
this.outbound = outbound;
}
public OutboundInfo(String id, Outbound outbound, LedgerInfo ledgerInfo) {
super(id);
this.outbound = outbound;
this.ledgerInfo = ledgerInfo;
}
@ExcelField(title="出库单主表id", align=2, sort=1)
public Outbound getOutbound() {
return outbound;
}
public void setOutbound(Outbound outbound) {
this.outbound = outbound;
}
@ExcelField(title="台账明细表id", align=2, sort=2)
public LedgerInfo getLedgerInfo() {
return ledgerInfo;
}
public void setLedgerInfo(LedgerInfo ledgerInfo) {
this.ledgerInfo = ledgerInfo;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
/**
* 出库单明细表MAPPER接口
* @author zhanglt
* @version 2023-02-14
*/
@MyBatisMapper
public interface OutboundInfoMapper extends BaseMapper<OutboundInfo> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.warehouse.outbound.entity.Outbound;
/**
* 出库信息MAPPER接口
* @author zhanglt
* @version 2023-02-14
*/
@MyBatisMapper
public interface OutboundMapper extends BaseMapper<Outbound> {
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.modules.warehouse.outbound.mapper.OutboundInfoMapper">
<sql id="outboundInfoColumns">
a.id AS "id",
a.outbound_id AS "outbound.id",
a.ledger_info_id AS "ledgerInfo.id",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="outboundInfoJoins">
</sql>
<select id="get" resultType="OutboundInfo" >
SELECT
<include refid="outboundInfoColumns"/>
FROM t_wh_outbound_info a
<include refid="outboundInfoJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="OutboundInfo" >
SELECT
<include refid="outboundInfoColumns"/>
FROM t_wh_outbound_info a
<include refid="outboundInfoJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="outbound != null and outbound.id != null and outbound.id != ''">
AND a.outbound_id = #{outbound.id}
</if>
<if test="ledgerInfo != null and ledgerInfo.id != null and ledgerInfo.id != ''">
AND a.ledger_info_id = #{ledgerInfo.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="OutboundInfo" >
SELECT
<include refid="outboundInfoColumns"/>
FROM t_wh_outbound_info a
<include refid="outboundInfoJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO t_wh_outbound_info(
id,
outbound_id,
ledger_info_id,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{outbound.id},
#{ledgerInfo.id},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE t_wh_outbound_info SET
outbound_id = #{outbound.id},
ledger_info_id = #{ledgerInfo.id},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM t_wh_outbound_info
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE t_wh_outbound_info SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="OutboundInfo" statementType="STATEMENT">
select * FROM t_wh_outbound_info where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.modules.warehouse.outbound.mapper.OutboundMapper">
<sql id="outboundColumns">
a.id AS "id",
a.number AS "number",
a.relation_id AS "relationId",
a.outbound_time AS "outboundTime",
a.type AS "type",
a.operator AS "operator",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag"
</sql>
<sql id="outboundJoins">
</sql>
<select id="get" resultType="Outbound" >
SELECT
<include refid="outboundColumns"/>
FROM t_wh_outbound a
<include refid="outboundJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Outbound" >
SELECT
<include refid="outboundColumns"/>
FROM t_wh_outbound a
<include refid="outboundJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="number != null and number != ''">
AND a.number LIKE
<if test="dbName == 'oracle'">'%'||#{number}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{number}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{number},'%')</if>
</if>
<if test="relationId != null and relationId != ''">
AND a.relation_id = #{relationId}
</if>
<if test="beginOutboundTime != null and endOutboundTime != null ">
AND a.outbound_time BETWEEN #{beginOutboundTime} AND #{endOutboundTime}
</if>
<if test="type != null and type != ''">
AND a.type = #{type}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Outbound" >
SELECT
<include refid="outboundColumns"/>
FROM t_wh_outbound a
<include refid="outboundJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO t_wh_outbound(
id,
number,
relation_id,
outbound_time,
type,
operator,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{number},
#{relationId},
#{outboundTime},
#{type},
#{operator},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE t_wh_outbound SET
number = #{number},
relation_id = #{relationId},
outbound_time = #{outboundTime},
type = #{type},
operator = #{operator},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
WHERE id = #{id}
</update>
<!--物理删除-->
<update id="delete">
DELETE FROM t_wh_outbound
WHERE id = #{id}
</update>
<!--逻辑删除-->
<update id="deleteByLogic">
UPDATE t_wh_outbound SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
<select id="findUniqueByProperty" resultType="Outbound" statementType="STATEMENT">
select * FROM t_wh_outbound where ${propertyName} = '${value}'
</select>
</mapper>
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.modules.warehouse.outbound.entity.Outbound;
import com.jeeplus.modules.warehouse.outbound.mapper.OutboundMapper;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import com.jeeplus.modules.warehouse.outbound.mapper.OutboundInfoMapper;
/**
* 出库信息Service
* @author zhanglt
* @version 2023-02-14
*/
@Service
@Transactional(readOnly = true)
public class OutboundService extends CrudService<OutboundMapper, Outbound> {
@Autowired
private OutboundInfoMapper outboundInfoMapper;
public Outbound get(String id) {
Outbound outbound = super.get(id);
outbound.setOutboundInfoList(outboundInfoMapper.findList(new OutboundInfo(outbound)));
return outbound;
}
public List<Outbound> findList(Outbound outbound) {
return super.findList(outbound);
}
public Page<Outbound> findPage(Page<Outbound> page, Outbound outbound) {
return super.findPage(page, outbound);
}
@Transactional(readOnly = false)
public void save(Outbound outbound) {
super.save(outbound);
for (OutboundInfo outboundInfo : outbound.getOutboundInfoList()){
if (outboundInfo.getId() == null){
continue;
}
if (OutboundInfo.DEL_FLAG_NORMAL.equals(outboundInfo.getDelFlag())){
if (StringUtils.isBlank(outboundInfo.getId())){
outboundInfo.setOutbound(outbound);
outboundInfo.preInsert();
outboundInfoMapper.insert(outboundInfo);
}else{
outboundInfo.setOutbound(outbound);
outboundInfo.preUpdate();
outboundInfoMapper.update(outboundInfo);
}
}else{
outboundInfoMapper.delete(outboundInfo);
}
}
}
@Transactional(readOnly = false)
public void delete(Outbound outbound) {
super.delete(outbound);
outboundInfoMapper.delete(new OutboundInfo(outbound));
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
*/
package com.jeeplus.modules.warehouse.outbound.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.modules.warehouse.outbound.entity.Outbound;
import com.jeeplus.modules.warehouse.outbound.service.OutboundService;
/**
* 出库信息Controller
* @author zhanglt
* @version 2023-02-14
*/
@Controller
@RequestMapping(value = "${adminPath}/warehouse/outbound/outbound")
public class OutboundController extends BaseController {
@Autowired
private OutboundService outboundService;
@ModelAttribute
public Outbound get(@RequestParam(required=false) String id) {
Outbound entity = null;
if (StringUtils.isNotBlank(id)){
entity = outboundService.get(id);
}
if (entity == null){
entity = new Outbound();
}
return entity;
}
/**
* 出库信息列表页面
*/
@RequiresPermissions("warehouse:outbound:outbound:list")
@RequestMapping(value = {"list", ""})
public String list(Outbound outbound, Model model) {
model.addAttribute("outbound", outbound);
return "modules/warehouse/outbound/outboundList";
}
/**
* 出库信息列表数据
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:list")
@RequestMapping(value = "data")
public Map<String, Object> data(Outbound outbound, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Outbound> page = outboundService.findPage(new Page<Outbound>(request, response), outbound);
return getBootstrapData(page);
}
/**
* 查看,增加,编辑出库信息表单页面
*/
@RequiresPermissions(value={"warehouse:outbound:outbound:view","warehouse:outbound:outbound:add","warehouse:outbound:outbound:edit"},logical=Logical.OR)
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, Outbound outbound, Model model) {
model.addAttribute("outbound", outbound);
model.addAttribute("mode", mode);
return "modules/warehouse/outbound/outboundForm";
}
/**
* 保存出库信息
*/
@ResponseBody
@RequiresPermissions(value={"warehouse:outbound:outbound:add","warehouse:outbound:outbound:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public AjaxJson save(Outbound outbound, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(outbound);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
outboundService.save(outbound);//保存
j.setSuccess(true);
j.setMsg("保存出库信息成功");
return j;
}
/**
* 删除出库信息
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:del")
@RequestMapping(value = "delete")
public AjaxJson delete(Outbound outbound) {
AjaxJson j = new AjaxJson();
outboundService.delete(outbound);
j.setMsg("删除出库信息成功");
return j;
}
/**
* 批量删除出库信息
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:del")
@RequestMapping(value = "deleteAll")
public AjaxJson deleteAll(String ids) {
AjaxJson j = new AjaxJson();
String idArray[] =ids.split(",");
for(String id : idArray){
outboundService.delete(outboundService.get(id));
}
j.setMsg("删除出库信息成功");
return j;
}
/**
* 导出excel文件
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:export")
@RequestMapping(value = "export")
public AjaxJson exportFile(Outbound outbound, HttpServletRequest request, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "出库信息"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<Outbound> page = outboundService.findPage(new Page<Outbound>(request, response, -1), outbound);
new ExportExcel("出库信息", Outbound.class).setDataList(page.getList()).write(response, fileName).dispose();
j.setSuccess(true);
j.setMsg("导出成功!");
return j;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导出出库信息记录失败!失败信息:"+e.getMessage());
}
return j;
}
@ResponseBody
@RequestMapping(value = "detail")
public Outbound detail(String id) {
return outboundService.get(id);
}
/**
* 导入Excel数据
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:import")
@RequestMapping(value = "import")
public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<Outbound> list = ei.getDataList(Outbound.class);
for (Outbound outbound : list){
try{
outboundService.save(outbound);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条出库信息记录。");
}
j.setMsg( "已成功导入 "+successNum+" 条出库信息记录"+failureMsg);
} catch (Exception e) {
j.setSuccess(false);
j.setMsg("导入出库信息失败!失败信息:"+e.getMessage());
}
return j;
}
/**
* 下载导入出库信息数据模板
*/
@ResponseBody
@RequiresPermissions("warehouse:outbound:outbound:import")
@RequestMapping(value = "import/template")
public AjaxJson importFileTemplate(HttpServletResponse response) {
AjaxJson j = new AjaxJson();
try {
String fileName = "出库信息数据导入模板.xlsx";
List<Outbound> list = Lists.newArrayList();
new ExportExcel("出库信息数据", Outbound.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
j.setSuccess(false);
j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
}
return j;
}
}
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
<title>出库信息管理</title>
<meta name="decorator" content="ani"/>
<script type="text/javascript">
$(document).ready(function() {
jp.ajaxForm("#inputForm",function(data){
if(data.success){
jp.success(data.msg);
jp.go("${ctx}/warehouse/outbound/outbound");
}else{
jp.error(data.msg);
$("#inputForm").find("button:submit").button("reset");
}
});
$('#outboundTime').datetimepicker({
format: "YYYY-MM-DD HH:mm:ss"
});
});
function addRow(list, idx, tpl, row){
$(list).append(Mustache.render(tpl, {
idx: idx, delBtn: true, row: row
}));
$(list+idx).find("select").each(function(){
$(this).val($(this).attr("data-value"));
});
$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
var ss = $(this).attr("data-value").split(',');
for (var i=0; i<ss.length; i++){
if($(this).val() == ss[i]){
$(this).attr("checked","checked");
}
}
});
$(list+idx).find(".form_datetime").each(function(){
$(this).datetimepicker({
format: "YYYY-MM-DD HH:mm:ss"
});
});
}
function delRow(obj, prefix){
var id = $(prefix+"_id");
var delFlag = $(prefix+"_delFlag");
if (id.val() == ""){
$(obj).parent().parent().remove();
}else if(delFlag.val() == "0"){
delFlag.val("1");
$(obj).html("&divide;").attr("title", "撤销删除");
$(obj).parent().parent().addClass("error");
}else if(delFlag.val() == "1"){
delFlag.val("0");
$(obj).html("&times;").attr("title", "删除");
$(obj).parent().parent().removeClass("error");
}
}
</script>
</head>
<body>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
<a class="panelButton" href="${ctx}/warehouse/outbound/outbound"><i class="ti-angle-left"></i> 返回</a>
</h3>
</div>
<div class="panel-body">
<form:form id="inputForm" modelAttribute="outbound" action="${ctx}/warehouse/outbound/outbound/save" method="post" class="form-horizontal">
<form:hidden path="id"/>
<div class="form-group">
<label class="col-sm-2 control-label">出库单号:</label>
<div class="col-sm-10">
<form:input path="number" htmlEscape="false" class="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">相关表单ID:</label>
<div class="col-sm-10">
<form:input path="relationId" htmlEscape="false" class="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">出库时间:</label>
<div class="col-sm-10">
<div class='input-group form_datetime' id='outboundTime'>
<input type='text' name="outboundTime" class="form-control " value="<fmt:formatDate value="${outbound.outboundTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">出库分类:</label>
<div class="col-sm-10">
<form:select path="type" class="form-control ">
<form:option value="" label=""/>
<form:options items="${fns:getDictList('')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">操作人:</label>
<div class="col-sm-10">
<form:input path="operator" htmlEscape="false" class="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">备注信息:</label>
<div class="col-sm-10">
<form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control "/>
</div>
</div>
<div class="tabs-container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">出库单明细表:</a>
</li>
</ul>
<div class="tab-content">
<div id="tab-1" class="tab-pane fade in active">
<a class="btn btn-white btn-sm" onclick="addRow('#outboundInfoList', outboundInfoRowIdx, outboundInfoTpl);outboundInfoRowIdx = outboundInfoRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th class="hide"></th>
<th>出库单主表id</th>
<th>台账明细表id</th>
<th>备注信息</th>
<th width="10">&nbsp;</th>
</tr>
</thead>
<tbody id="outboundInfoList">
</tbody>
</table>
<script type="text/template" id="outboundInfoTpl">//<!--
<tr id="outboundInfoList{{idx}}">
<td class="hide">
<input id="outboundInfoList{{idx}}_id" name="outboundInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
<input id="outboundInfoList{{idx}}_delFlag" name="outboundInfoList[{{idx}}].delFlag" type="hidden" value="0"/>
</td>
<td>
<input id="outboundInfoList{{idx}}_outbound" name="outboundInfoList[{{idx}}].outbound.id" type="text" value="{{row.outbound.id}}" class="form-control "/>
</td>
<td>
<input id="outboundInfoList{{idx}}_ledgerInfo" name="outboundInfoList[{{idx}}].ledgerInfo.id" type="text" value="{{row.ledgerInfo.id}}" class="form-control "/>
</td>
<td>
<textarea id="outboundInfoList{{idx}}_remarks" name="outboundInfoList[{{idx}}].remarks" rows="4" class="form-control ">{{row.remarks}}</textarea>
</td>
<td class="text-center" width="10">
{{#delBtn}}<span class="close" onclick="delRow(this, '#outboundInfoList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
</td>
</tr>//-->
</script>
<script type="text/javascript">
var outboundInfoRowIdx = 0, outboundInfoTpl = $("#outboundInfoTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
$(document).ready(function() {
var data = ${fns:toJson(outbound.outboundInfoList)};
for (var i=0; i<data.length; i++){
addRow('#outboundInfoList', outboundInfoRowIdx, outboundInfoTpl, data[i]);
outboundInfoRowIdx = outboundInfoRowIdx + 1;
}
});
</script>
</div>
</div>
</div>
<c:if test="${mode == 'add' || mode=='edit'}">
<div class="col-lg-3"></div>
<div class="col-lg-6">
<div class="form-group text-center">
<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
</div>
</div>
</div>
</c:if>
</form:form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<script>
$(document).ready(function() {
$('#outboundTable').bootstrapTable({
//请求方法
method: 'post',
//类型json
dataType: "json",
contentType: "application/x-www-form-urlencoded",
//显示检索按钮
showSearch: true,
//显示刷新按钮
showRefresh: true,
//显示切换手机试图按钮
showToggle: true,
//显示 内容列下拉框
showColumns: true,
//显示到处按钮
showExport: true,
//显示切换分页按钮
showPaginationSwitch: true,
//显示详情按钮
detailView: true,
//显示详细内容函数
detailFormatter: "detailFormatter",
//最低显示2行
minimumCountColumns: 2,
//是否显示行间隔色
striped: true,
//是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
cache: false,
//是否显示分页(*)
pagination: true,
//排序方式
sortOrder: "asc",
//初始化加载第一页,默认第一页
pageNumber:1,
//每页的记录行数(*)
pageSize: 10,
//可供选择的每页的行数(*)
pageList: [10, 25, 50, 100],
//这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
url: "${ctx}/warehouse/outbound/outbound/data",
//默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
//queryParamsType:'',
////查询参数,每次调用是会带上这个参数,可自定义
queryParams : function(params) {
var searchParam = $("#searchForm").serializeJSON();
searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
searchParam.pageSize = params.limit === undefined? -1 : params.limit;
searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
return searchParam;
},
//分页方式:client客户端分页,server服务端分页(*)
sidePagination: "server",
contextMenuTrigger:"right",//pc端 按右键弹出菜单
contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
contextMenu: '#context-menu',
onContextMenuItem: function(row, $el){
if($el.data("item") == "edit"){
edit(row.id);
}else if($el.data("item") == "view"){
view(row.id);
} else if($el.data("item") == "delete"){
jp.confirm('确认要删除该出库信息记录吗?', function(){
jp.loading();
jp.get("${ctx}/warehouse/outbound/outbound/delete?id="+row.id, function(data){
if(data.success){
$('#outboundTable').bootstrapTable('refresh');
jp.success(data.msg);
}else{
jp.error(data.msg);
}
})
});
}
},
onClickRow: function(row, $el){
},
onShowSearch: function () {
$("#search-collapse").slideToggle();
},
columns: [{
checkbox: true
}
,{
field: 'number',
title: '出库单号',
sortable: true,
sortName: 'number'
,formatter:function(value, row , index){
value = jp.unescapeHTML(value);
<c:choose>
<c:when test="${fns:hasPermission('warehouse:outbound:outbound:edit')}">
return "<a href='javascript:edit(\""+row.id+"\")'>"+value+"</a>";
</c:when>
<c:when test="${fns:hasPermission('warehouse:outbound:outbound:view')}">
return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
</c:when>
<c:otherwise>
return value;
</c:otherwise>
</c:choose>
}
}
,{
field: 'relationId',
title: '相关表单ID',
sortable: true,
sortName: 'relationId'
}
,{
field: 'outboundTime',
title: '出库时间',
sortable: true,
sortName: 'outboundTime'
}
,{
field: 'type',
title: '出库分类',
sortable: true,
sortName: 'type',
formatter:function(value, row , index){
return jp.getDictLabel(${fns:toJson(fns:getDictList(''))}, value, "-");
}
}
,{
field: 'operator',
title: '操作人',
sortable: true,
sortName: 'operator'
}
,{
field: 'remarks',
title: '备注信息',
sortable: true,
sortName: 'remarks'
}
]
});
if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
$('#outboundTable').bootstrapTable("toggleView");
}
$('#outboundTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
'check-all.bs.table uncheck-all.bs.table', function () {
$('#remove').prop('disabled', ! $('#outboundTable').bootstrapTable('getSelections').length);
$('#view,#edit').prop('disabled', $('#outboundTable').bootstrapTable('getSelections').length!=1);
});
$("#btnImport").click(function(){
jp.open({
type: 2,
area: [500, 200],
auto: true,
title:"导入数据",
content: "${ctx}/tag/importExcel" ,
btn: ['下载模板','确定', '关闭'],
btn1: function(index, layero){
jp.downloadFile('${ctx}/warehouse/outbound/outbound/import/template');
},
btn2: function(index, layero){
var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
iframeWin.contentWindow.importExcel('${ctx}/warehouse/outbound/outbound/import', function (data) {
if(data.success){
jp.success(data.msg);
refresh();
}else{
jp.error(data.msg);
}
jp.close(index);
});//调用保存事件
return false;
},
btn3: function(index){
jp.close(index);
}
});
});
$("#export").click(function(){//导出Excel文件
var searchParam = $("#searchForm").serializeJSON();
searchParam.pageNo = 1;
searchParam.pageSize = -1;
var sortName = $('#outboundTable').bootstrapTable("getOptions", "none").sortName;
var sortOrder = $('#outboundTable').bootstrapTable("getOptions", "none").sortOrder;
var values = "";
for(var key in searchParam){
values = values + key + "=" + searchParam[key] + "&";
}
if(sortName != undefined && sortOrder != undefined){
values = values + "orderBy=" + sortName + " "+sortOrder;
}
jp.downloadFile('${ctx}/warehouse/outbound/outbound/export?'+values);
})
$("#search").click("click", function() {// 绑定查询按扭
$('#outboundTable').bootstrapTable('refresh');
});
$("#reset").click("click", function() {// 绑定查询按扭
$("#searchForm input").val("");
$("#searchForm select").val("");
$("#searchForm .select-item").html("");
$('#outboundTable').bootstrapTable('refresh');
});
$('#beginOutboundTime').datetimepicker({
format: "YYYY-MM-DD HH:mm:ss"
});
$('#endOutboundTime').datetimepicker({
format: "YYYY-MM-DD HH:mm:ss"
});
});
function getIdSelections() {
return $.map($("#outboundTable").bootstrapTable('getSelections'), function (row) {
return row.id
});
}
function deleteAll(){
jp.confirm('确认要删除该出库信息记录吗?', function(){
jp.loading();
jp.get("${ctx}/warehouse/outbound/outbound/deleteAll?ids=" + getIdSelections(), function(data){
if(data.success){
$('#outboundTable').bootstrapTable('refresh');
jp.success(data.msg);
}else{
jp.error(data.msg);
}
})
})
}
//刷新列表
function refresh(){
$('#outboundTable').bootstrapTable('refresh');
}
function add(){
jp.go("${ctx}/warehouse/outbound/outbound/form/add");
}
function edit(id){
if(id == undefined){
id = getIdSelections();
}
jp.go("${ctx}/warehouse/outbound/outbound/form/edit?id=" + id);
}
function view(id){//没有权限时,不显示确定按钮
if(id == undefined){
id = getIdSelections();
}
jp.go("${ctx}/warehouse/outbound/outbound/form/view?id=" + id);
}
function detailFormatter(index, row) {
var htmltpl = $("#outboundChildrenTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
var html = Mustache.render(htmltpl, {
idx:row.id
});
$.get("${ctx}/warehouse/outbound/outbound/detail?id="+row.id, function(outbound){
var outboundChild1RowIdx = 0, outboundChild1Tpl = $("#outboundChild1Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
var data1 = outbound.outboundInfoList;
for (var i=0; i<data1.length; i++){
data1[i].dict = {};
addRow('#outboundChild-'+row.id+'-1-List', outboundChild1RowIdx, outboundChild1Tpl, data1[i]);
outboundChild1RowIdx = outboundChild1RowIdx + 1;
}
})
return html;
}
function addRow(list, idx, tpl, row){
$(list).append(Mustache.render(tpl, {
idx: idx, delBtn: true, row: row
}));
}
</script>
<script type="text/template" id="outboundChildrenTpl">//<!--
<div class="tabs-container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab-{{idx}}-1" aria-expanded="true">出库单明细表</a></li>
</ul>
<div class="tab-content">
<div id="tab-{{idx}}-1" class="tab-pane fade in active">
<table class="ani table">
<thead>
<tr>
<th>出库单主表id</th>
<th>台账明细表id</th>
<th>备注信息</th>
</tr>
</thead>
<tbody id="outboundChild-{{idx}}-1-List">
</tbody>
</table>
</div>
</div>//-->
</script>
<script type="text/template" id="outboundChild1Tpl">//<!--
<tr>
<td>
{{row.outbound.id}}
</td>
<td>
{{row.ledgerInfo.id}}
</td>
<td>
{{row.remarks}}
</td>
</tr>//-->
</script>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
<title>出库信息管理</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="decorator" content="ani"/>
<%@ include file="/webpage/include/bootstraptable.jsp"%>
<%@include file="/webpage/include/treeview.jsp" %>
<%@include file="outboundList.js" %>
</head>
<body>
<div class="wrapper wrapper-content">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">出库信息列表</h3>
</div>
<div class="panel-body">
<!-- 搜索 -->
<div id="search-collapse" class="collapse">
<div class="accordion-inner">
<form:form id="searchForm" modelAttribute="outbound" class="form form-horizontal well clearfix">
<div class="col-xs-12 col-sm-6 col-md-4">
<label class="label-item single-overflow pull-left" title="出库单号:">出库单号:</label>
<form:input path="number" htmlEscape="false" maxlength="64" class=" form-control"/>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<label class="label-item single-overflow pull-left" title="相关表单ID:">相关表单ID:</label>
<form:input path="relationId" htmlEscape="false" maxlength="64" class=" form-control"/>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="form-group">
<label class="label-item single-overflow pull-left" title="出库时间:">&nbsp;出库时间:</label>
<div class="col-xs-12">
<div class="col-xs-12 col-sm-5">
<div class='input-group date' id='beginOutboundTime' style="left: -10px;" >
<input type='text' name="beginOutboundTime" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="col-xs-12 col-sm-1">
~
</div>
<div class="col-xs-12 col-sm-5">
<div class='input-group date' id='endOutboundTime' style="left: -10px;" >
<input type='text' name="endOutboundTime" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<label class="label-item single-overflow pull-left" title="出库分类:">出库分类:</label>
<form:select path="type" class="form-control m-b">
<form:option value="" label=""/>
<form:options items="${fns:getDictList('')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div style="margin-top:26px">
<a id="search" class="btn btn-primary btn-rounded btn-bordered btn-sm"><i class="fa fa-search"></i> 查询</a>
<a id="reset" class="btn btn-primary btn-rounded btn-bordered btn-sm" ><i class="fa fa-refresh"></i> 重置</a>
</div>
</div>
</form:form>
</div>
</div>
<!-- 工具栏 -->
<div id="toolbar">
<shiro:hasPermission name="warehouse:outbound:outbound:add">
<button id="add" class="btn btn-primary" onclick="add()">
<i class="glyphicon glyphicon-plus"></i> 新建
</button>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:edit">
<button id="edit" class="btn btn-success" disabled onclick="edit()">
<i class="glyphicon glyphicon-edit"></i> 修改
</button>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:del">
<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
<i class="glyphicon glyphicon-remove"></i> 删除
</button>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:import">
<button id="btnImport" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入</button>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:export">
<button id="export" class="btn btn-warning">
<i class="fa fa-file-excel-o"></i> 导出
</button>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:view">
<button id="view" class="btn btn-default" disabled onclick="view()">
<i class="fa fa-search-plus"></i> 查看
</button>
</shiro:hasPermission>
</div>
<!-- 表格 -->
<table id="outboundTable" data-toolbar="#toolbar"></table>
<!-- context menu -->
<ul id="context-menu" class="dropdown-menu">
<shiro:hasPermission name="warehouse:outbound:outbound:view">
<li data-item="view"><a>查看</a></li>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:edit">
<li data-item="edit"><a>编辑</a></li>
</shiro:hasPermission>
<shiro:hasPermission name="warehouse:outbound:outbound:del">
<li data-item="delete"><a>删除</a></li>
</shiro:hasPermission>
<li data-item="action1"><a>取消</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment