王佳豪
2021-03-06 9ba14d26e2ae8f5b5c3dfae07ea8558e7776bcec
1.0.2
新增平仓管理功能
13个文件已添加
1个文件已删除
1个文件已修改
1315 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/LocNormalController.java 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/LocNormal.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/LocNormalMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/LocNormalService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/LocNormalServiceImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/excel/locNomal/LocNormalExcel.java 184 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/excel/locNomal/LocNormalExcelListener.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/LocNormalMapper.xml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/locNormal/addLocNormal.js 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/locNormal/locNormal.js 294 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/locNormal/addLocNormal.html 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/locNormal/locNormal.html 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
version/v1.0.1/wjh.sql 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
version/version/wjh.sql 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/LocNormalController.java
New file
@@ -0,0 +1,126 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.LocNormal;
import com.zy.asrs.service.LocNormalService;
import com.zy.common.utils.excel.locNomal.LocNormalExcel;
import com.zy.common.utils.excel.locNomal.LocNormalExcelListener;
import com.zy.common.utils.excel.matcode.MatCodeExcel;
import com.zy.common.utils.excel.matcode.MatCodeExcelListener;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
import static jdk.nashorn.api.scripting.ScriptUtils.convert;
@RestController
public class LocNormalController extends BaseController{
    @Autowired
    private LocNormalService locNormalService;
    @RequestMapping(value = "/locNomal/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
        excludeTrash(param);
        EntityWrapper<LocNormal> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        allLike(LocNormal.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        wrapper.eq("state", "1").or().eq("state", "2");
        return R.ok(locNormalService.selectPage(new Page<>(curr, limit), wrapper));
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
            } else {
                wrapper.like(entry.getKey(), String.valueOf(entry.getValue()));
            }
        }
    }
    @RequestMapping(value = "/locNomal/add/auth")
    @ManagerAuth
    public R add(LocNormal locNormalList) {
        // 插入创建信息
        locNormalList.setModiUser(getUserId());
        locNormalList.setModiTime(new Date());
        locNormalList.setAppeUser(getUserId());
        locNormalList.setAppeTime(new Date());
        // 默认新增为已入库
        locNormalList.setState("1");
        locNormalService.insert(locNormalList);
        return R.ok();
    }
    @RequestMapping(value = "/matnr/check/column/auth")
    @ManagerAuth
    public R query(@RequestBody JSONObject param) {
        Wrapper<LocNormal> wrapper = new EntityWrapper<LocNormal>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
        if (null != locNormalService.selectOne(wrapper)){
            return R.parse(BaseRes.REPEAT).add(getComment(LocNormal.class, String.valueOf(param.get("key"))));
        }
        return R.ok();
    }
    @RequestMapping(value = "/locNormal/update/auth")
    @ManagerAuth
    public void updateLocNormal(LocNormal param) {
        Long modiUser = getUserId();
        Date modiTime = new Date();
        locNormalService.updateLocNormal(param.getMatnr(), param.getAnfme(), modiUser, modiTime);
    }
    @RequestMapping(value = "/locNormal/outLoc/auth")
    @ManagerAuth
    public void outLocNormal(LocNormal param) {
        Long modiUser = getUserId();
        Date modiTime = new Date();
        locNormalService.outLocNormal(param.getMatnr(), modiUser, modiTime);
    }
    @RequestMapping(value = "/locNormal/removeLoc/auth")
    @ManagerAuth
    public void removeLoc(LocNormal param) {
        Long modiUser = getUserId();
        Date modiTime = new Date();
        locNormalService.removeLocNormal(param.getMatnr(), modiUser, modiTime);
    }
    // 导入
    @RequestMapping(value = "/locNormal/import/auth")
    @ManagerAuth(memo = "平仓管理导入")
    @Transactional
    public R matCodeImport(MultipartFile file) throws IOException, InterruptedException {
        LocNormalExcelListener listener = new LocNormalExcelListener(getUserId());
        EasyExcel.read(file.getInputStream(), LocNormalExcel.class, listener).sheet().doRead();
        return R.ok("成功导入"+listener.getTotal()+"条物料信息");
    }
}
src/main/java/com/zy/asrs/entity/LocNormal.java
New file
@@ -0,0 +1,115 @@
package com.zy.asrs.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.zy.asrs.service.LocMastService;
import com.zy.system.entity.User;
import com.zy.system.service.UserService;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data
@TableName("asr_loc_normal")
public class LocNormal implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value= "物料")
    @TableId(value = "matnr", type = IdType.INPUT)
    private String matnr;
    @ApiModelProperty(value= "物料描述")
    private String maktx;
    @ApiModelProperty(value= "规格")
    private String lgnum;
    @ApiModelProperty(value= "物料类别")
    private String type;
    @ApiModelProperty(value= "助记码")
    private String mnemonic;
    @ApiModelProperty(value= "通知单号")
    private String supplier;
    @ApiModelProperty(value= "仓库")
    private String warehouse;
    @ApiModelProperty(value= "品牌")
    private String brand;
    @ApiModelProperty(value= "数量")
    private Double anfme;
    @ApiModelProperty(value= "单位")
    private String altme;
    @ApiModelProperty(value= "用户ID")
    private String bname;
    @ApiModelProperty(value= "备注")
    private String memo;
    @ApiModelProperty(value= "修改人员")
    @TableField("modi_user")
    private Long modiUser;
    @ApiModelProperty(value= "修改时间")
    @TableField("modi_time")
    private Date modiTime;
    @ApiModelProperty(value= "创建者")
    @TableField("appe_user")
    private Long appeUser;
    @ApiModelProperty(value= "添加时间")
    @TableField("appe_time")
    private Date appeTime;
    @ApiModelProperty(value= "物料出入库状态")
    @TableField("state")
    private String state;
    public String getModiUser$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.modiUser);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        return null;
    }
    public String getModiTime$(){
        if (Cools.isEmpty(this.modiTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.modiTime);
    }
    public String getAppeUser$(){
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.appeUser);
        if (!Cools.isEmpty(user)){
            return String.valueOf(user.getUsername());
        }
        return null;
    }
    public String getAppeTime$(){
        if (Cools.isEmpty(this.appeTime)){
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.appeTime);
    }
}
src/main/java/com/zy/asrs/mapper/LocNormalMapper.java
New file
@@ -0,0 +1,26 @@
package com.zy.asrs.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zy.asrs.entity.LocNormal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Mapper
@Repository
public interface LocNormalMapper extends BaseMapper<LocNormal> {
    List<LocNormal> getLocNormalData();
    public void updateLocNormal(@Param("matnr") String matnr,@Param("anfme") Double anfme, @Param("modiUser") Long modiUser, @Param("modiTime") Date modiTime);
    public void outLocNormal(@Param("matnr") String matnr, @Param("modiUser") Long modiUser, @Param("modiTime") Date modiTime);
    public void removeLocNormal(@Param("matnr") String matnr, @Param("modiUser") Long modiUser, @Param("modiTime") Date modiTime);
}
src/main/java/com/zy/asrs/service/LocNormalService.java
New file
@@ -0,0 +1,18 @@
package com.zy.asrs.service;
import com.baomidou.mybatisplus.service.IService;
import com.zy.asrs.entity.LocNormal;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public interface LocNormalService extends IService<LocNormal> {
  List<LocNormal> getLocNormalData();
  public void updateLocNormal(String matnr, Double anfme, Long modiUser, Date modiTime);
  public void outLocNormal(String matnr, Long modiUser, Date modiTime);
  public void removeLocNormal(String matnr, Long modiUser, Date modiTime);
}
src/main/java/com/zy/asrs/service/impl/LocNormalServiceImpl.java
New file
@@ -0,0 +1,37 @@
package com.zy.asrs.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.asrs.entity.LocNormal;
import com.zy.asrs.mapper.LocNormalMapper;
import com.zy.asrs.service.LocNormalService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Service("locNormalService")
public class LocNormalServiceImpl extends ServiceImpl<LocNormalMapper, LocNormal> implements LocNormalService {
    @Override
    public List<LocNormal> getLocNormalData() {
        return baseMapper.getLocNormalData();
    }
    @Override
    public void updateLocNormal(String matnr, Double anfme, Long modiUser, Date modiTime) {
        baseMapper.updateLocNormal(matnr, anfme, modiUser, modiTime);
    }
    @Override
    public void outLocNormal(String matnr, Long modiUser, Date modiTime) {
        baseMapper.outLocNormal(matnr, modiUser, modiTime);
    }
    @Override
    public void removeLocNormal(String matnr, Long modiUser, Date modiTime) {
        baseMapper.removeLocNormal(matnr, modiUser, modiTime);
    }
}
src/main/java/com/zy/common/utils/excel/locNomal/LocNormalExcel.java
New file
@@ -0,0 +1,184 @@
package com.zy.common.utils.excel.locNomal;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ExcelIgnoreUnannotated
public class LocNormalExcel {
    @ExcelProperty(index = 0)
    private String matnr;
    @ExcelProperty(index = 1)
    private String maktx;
    @ExcelProperty(index = 2)
    private String lgnum;
    @ExcelProperty(index = 3)
    private String type;
    @ExcelProperty(index = 4)
    private String mnemonic;
    @ExcelProperty(index = 5)
    private String supplier;
    @ExcelProperty(index = 6)
    private String warehouse;
    @ExcelProperty(index = 7)
    private String brand;
    @ExcelProperty(index = 8)
    private Double anfme;
    @ExcelProperty(index = 9)
    private String altme;
    @ExcelProperty(index = 10)
    private String bname;
    @ExcelProperty(index = 11)
    private String memo;
    private Long appeUser;
    private Date appeTime;
    @ExcelProperty(index = 12)
    private String state;
    public LocNormalExcel() {
    }
    public LocNormalExcel(String matnr, String maktx, String lgnum, String type, String mnemonic, String supplier, String warehouse, String brand, Double anfme, String altme, String bname, String memo, Long appeUser, Date appeTime,String state) {
        this.matnr = matnr;
        this.maktx = maktx;
        this.lgnum = lgnum;
        this.type = type;
        this.mnemonic = mnemonic;
        this.supplier = supplier;
        this.warehouse = warehouse;
        this.brand = brand;
        this.anfme = anfme;
        this.altme = altme;
        this.bname = bname;
        this.memo = memo;
        this.appeUser = appeUser;
        this.appeTime = appeTime;
        this.state = state;
    }
    public String getMatnr() {
        return matnr;
    }
    public void setMatnr(String matnr) {
        this.matnr = matnr;
    }
    public String getMaktx() {
        return maktx;
    }
    public void setMaktx(String maktx) {
        this.maktx = maktx;
    }
    public String getLgnum() {
        return lgnum;
    }
    public void setLgnum(String lgnum) {
        this.lgnum = lgnum;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getMnemonic() {
        return mnemonic;
    }
    public void setMnemonic(String mnemonic) {
        this.mnemonic = mnemonic;
    }
    public String getSupplier() {
        return supplier;
    }
    public void setSupplier(String supplier) {
        this.supplier = supplier;
    }
    public String getWarehouse() {
        return warehouse;
    }
    public void setWarehouse(String warehouse) {
        this.warehouse = warehouse;
    }
    public String getBrand() {
        return brand;
    }
    public void setBrand(String brand) {
        this.brand = brand;
    }
    public Double getAnfme() {
        return anfme;
    }
    public void setAnfme(Double anfme) {
        this.anfme = anfme;
    }
    public String getAltme() {
        return altme;
    }
    public void setAltme(String altme) {
        this.altme = altme;
    }
    public String getBname() {
        return bname;
    }
    public void setBname(String bname) {
        this.bname = bname;
    }
    public String getMemo() {
        return memo;
    }
    public void setMemo(String memo) {
        this.memo = memo;
    }
    public Long getAppeUser() {
        return appeUser;
    }
    public void setAppeUser(Long appeUser) {
        this.appeUser = appeUser;
    }
    public Date getAppeTime() {
        return appeTime;
    }
    public void setAppeTime(Date appeTime) {
        this.appeTime = appeTime;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}
src/main/java/com/zy/common/utils/excel/locNomal/LocNormalExcelListener.java
New file
@@ -0,0 +1,93 @@
package com.zy.common.utils.excel.locNomal;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.LocNormal;
import com.zy.asrs.entity.MatCode;
import com.zy.asrs.service.LocNormalService;
import com.zy.asrs.service.MatCodeService;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.utils.excel.matcode.MatCodeExcel;
import com.zy.common.utils.excel.matcode.MatCodeExcelListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class LocNormalExcelListener extends AnalysisEventListener<LocNormalExcel> {
    private static final Logger LOGGER = LoggerFactory.getLogger(MatCodeExcelListener.class);
    private int total = 0;
    private Long userId;
    public LocNormalExcelListener(Long userId) {
        this.userId = userId;
    }
    /**
     * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
     */
    private static final int BATCH_COUNT = 50;
    private final List<LocNormal> list = new ArrayList<>();
    /**
     * 这里会一行行的返回头
     */
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
    }
    /**
     * 这个每一条数据解析都会来调用
     */
    @Override
    public void invoke(LocNormalExcel data, AnalysisContext ctx) {
        LocNormalService locNormalService = SpringUtils.getBean(LocNormalService.class);
        if (locNormalService.selectById(data.getMatnr()) == null) {
            LocNormal locNormal = new LocNormal();
            // 插入
            locNormal.setMatnr(data.getMatnr());
            locNormal.setMaktx(data.getMaktx());
            locNormal.setLgnum(data.getLgnum());
            locNormal.setType(data.getType());
            locNormal.setMnemonic(data.getMnemonic());
            locNormal.setSupplier(data.getSupplier());
            locNormal.setWarehouse(data.getWarehouse());
            locNormal.setBrand(data.getBrand());
            locNormal.setAnfme(data.getAnfme());
            locNormal.setAltme(data.getAltme());
            locNormal.setBname(data.getBname());
            locNormal.setMemo(data.getMemo());
            locNormal.setState(data.getState());
            locNormal.setModiTime(new Date());
            locNormal.setModiUser(this.userId);
            locNormal.setAppeTime(new Date());
            locNormal.setAppeUser(this.userId);
            if (!locNormalService.insert(locNormal)) {
                throw new CoolException("导入数据异常");
            }
            total ++;
        }
    }
    /**
     * 所有数据解析完成了调用
     * 适合事务
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext ctx) {
        LOGGER.info("新增{}条物料信息!", total);
    }
    public int getTotal() {
        return total;
    }
}
src/main/resources/mapper/LocNormalMapper.xml
New file
@@ -0,0 +1,45 @@
<?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.zy.asrs.mapper.LocNormalMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.LocNormal">
        <result column="matnr" property="matnr" />
        <result column="maktx" property="maktx" />
        <result column="lgnum" property="lgnum" />
        <result column="type" property="type" />
        <result column="mnemonic" property="mnemonic" />
        <result column="supplier" property="supplier" />
        <result column="warehouse" property="warehouse" />
        <result column="brand" property="brand" />
        <result column="anfme" property="anfme" />
        <result column="bname" property="bname" />
        <result column="memo" property="memo" />
        <result column="modi_user" property="modiUser" />
        <result column="modi_time" property="modiTime" />
        <result column="appe_user" property="appeUser" />
        <result column="appe_time" property="appeTime" />
        <result column="state" property="state" />
    </resultMap>
    <select id="getLocNormalData" resultMap="BaseResultMap">
      select * from asr_loc_normal
    </select>
    <!-- 更新平仓物料的数量 -->
    <update id="updateLocNormal">
        update asr_loc_normal set anfme = #{anfme,jdbcType=DECIMAL},
        modi_user = #{modiUser, jdbcType=DECIMAL}, modi_time = #{modiTime, jdbcType=TIMESTAMP}
        where matnr = #{matnr,jdbcType=VARCHAR}
    </update>
    <update id="outLocNormal">
        update asr_loc_normal set state = '2',modi_user = #{modiUser, jdbcType=DECIMAL},
        modi_time = #{modiTime, jdbcType=TIMESTAMP} where matnr = #{matnr,jdbcType=VARCHAR}
    </update>
    <update id="removeLocNormal">
        update asr_loc_normal set state = '3',modi_user = #{modiUser, jdbcType=DECIMAL},
        modi_time = #{modiTime, jdbcType=TIMESTAMP} where matnr = #{matnr,jdbcType=VARCHAR}
    </update>
</mapper>
src/main/webapp/static/js/common.js
@@ -216,3 +216,14 @@
    ,{field: 'zpallet', align: 'center',title: '托盘条码'}
]
var locNormalCols = [
    {field: 'matnr', align: 'center',title: '物料编码'}
    ,{field: 'maktx', align: 'center',title: '物料名称', width: 400}
    ,{field: 'lgnum', align: 'center',title: '规格'}
    ,{field: 'type', align: 'center',title: '物料类别'}
    ,{field: 'mnemonic', align: 'center',title: '单据编号', hide: true}
    ,{field: 'supplier', align: 'center',title: '通知单号'}
    ,{field: 'warehouse', align: 'center',title: '仓库', hide: true}
    ,{field: 'brand', align: 'center',title: '品牌', hide: true}
    ,{field: 'altme', align: 'center',title: '单位'}
]
src/main/webapp/static/js/locNormal/addLocNormal.js
New file
@@ -0,0 +1,65 @@
// 关闭动作
$(document).on('click', '#data-detail-close', function () {
    parent.layer.closeAll();
});
layui.use(['table', 'laydate', 'form', 'upload'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var upload = layui.upload;
    var form = layui.form;
    // 数据保存动作
    form.on('submit(save)', function () {
        if (banMsg != null) {
            layer.msg(banMsg);
            return;
        }
        // 数量输入校验
        var reg=/^\d{1,}$/
        var pattern=new RegExp(reg);
        var anfme = $('#anfme').val();
        if (!pattern.test(anfme)) {
            layer.msg("请输入正确的数量");
            return;
        }
        // loading加载效果
        var loadingIndex = layer.load(1, {
            shade: [0.5,'#000']
        });
        // 表单入参
        var data = {
            matnr: $('#matnr').val(),
            maktx: $('#maktx').val(),
            lgnum: $('#lgnum').val(),
            type: $('#type').val(),
            mnemonic: $('#mnemonic').val(),
            supplier: $('#supplier').val(),
            warehouse: $('#warehouse').val(),
            brand: $('#brand').val(),
            anfme: $('#anfme').val(),
            altme: $('#altme').val(),
        };
        // 请求保存接口
        $.ajax({
            url: baseUrl+"/locNomal/add/auth",
            headers: {'token': localStorage.getItem('token')},
            data: top.reObject(data),
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    parent.layer.closeAll();
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                }else {
                    layer.msg(res.msg);
                }
                // 关闭loading加载效果
                layer.close(loadingIndex);
            },
        });
    });
});
src/main/webapp/static/js/locNormal/locNormal.js
New file
@@ -0,0 +1,294 @@
var pageCurr;
var locNormalList = [];
function getCol() {
    var cols = [];
    cols.push(
        {field: 'anfme', align: 'center', title: '数量', sort: true, edit: 'text'}
    )
    cols.push.apply(cols, locNormalCols);
    cols.push(
        {field: 'state', align: 'center', title: '出入库状态', templet: '#locNormalState'}
        , {field: 'modiUser$', align: 'center', title: '修改人员', hide: true}
        , {field: 'modiTime$', align: 'center', title: '修改时间', hide: true}
        , {field: 'appeTime$', align: 'center', title: '创建时间', hide: true}
        , {field: '', align: 'center', title: '操作', width: 135, fixed: 'right', templet: '#operate'}
    );
    return cols;
}
layui.use(['table', 'laydate', 'form', 'upload'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    var upload = layui.upload;
    // 导入excel
    var uploader = upload.render({
        elem: '#uploadEx'
        , url: baseUrl + '/locNormal/import/auth'
        , headers: {token: localStorage.getItem('token')}
        , accept: 'file'
        , exts: 'xls|excel|xlsx'
        , auto: false
        , bindAction: '#uploadDo'
        , before: function(obj){
            layer.closeAll();
            layer.load(1, {shade: [0.1,'#fff']});
        }
        , choose: function(obj){
            $('#uploadDesc').hide();
            $('#uploadDemoView').show();
            obj.preview(function(index, file, result){
                $('#fileMame').html(file.name);
            });
        }
        , done: function (res) {
            limit();
            $('#uploadDesc').show();
            $('#uploadDemoView').hide();
            $('#fileMame').html("");
            layer.closeAll('loading');
            layer.msg(res.msg);
            tableReload(false);
        }
        , error: function(index, upload){
            layer.closeAll('loading');
        }
    });
    /* 导入 */
    table.on('toolbar(locNormal)', function (obj) {
        debugger
        switch(obj.event) {
            // 导入
            case 'intoData':
                layer.open({
                    type: 1,
                    title: '数据导入',
                    shadeClose: true,
                    content: $('#importDataDiv'),
                    success: function(layero, index){
                        uploader.reload();
                    },
                    end: function () {
                        $('#uploadDesc').show();
                        $('#uploadDemoView').hide();
                        $('#fileMame').html("");
                    }
                });
                break;
        }
    });
    // 数据渲染
    tableIns = table.render({
        elem: '#locNormal',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl + '/locNomal/list/auth',
        page: true,
        limit: 16,
        limits: [16, 30, 50, 100, 200, 500],
        even: true,
        toolbar: '#toolbar',
        cellMinWidth: 50,
        cols: [getCol()],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl + "/";
            }
            pageCurr = curr;
            limit();
            // 当前分页数据存储
            locNormalList = res.data;
        }
    });
    // 监听排序事件
    table.on('sort(locNormal)', function (obj) {
        var searchData = {};
        $.each($('#search-box [name]').serializeArray(), function () {
            searchData[this.name] = this.value;
        });
        searchData['orderByField'] = obj.field;
        searchData['orderByType'] = obj.type;
        tableIns.reload({
            where: searchData,
            page: {
                curr: 1
            },
            done: function (res, curr, count) {
                if (res.code === 403) {
                    top.location.href = baseUrl + "/";
                }
                pageCurr = curr;
                limit();
                // 当前分页数据存储
                locNormalList = res.data;
            }
        });
    });
    // 页面修改
    table.on('edit(locNormal)', function (obj) {
        var count = obj.value;
        var matnr = obj.data.matnr;
        if (isNaN(count)) {
            layer.msg("请输入数字");
            // 数据重载
            tableIns.reload({
                data: locNormalList, done: function (res) {
                    limit();
                }
            });
        } else {
            if (count > 0) {
                for (var i = 0; i < locNormalList.length; i++) {
                    if (locNormalList[i]["matnr"] === matnr) {
                        locNormalList[i]["anfme"] = count;
                    }
                }
            } else {
                layer.msg("数量必须大于零");
            }
        }
        // 请求更新接口完成数量的更新
        const param = {
            matnr: matnr,
            anfme: count,
        }
        $.ajax({
            url: baseUrl + "/locNormal/update/auth",
            headers: {'token': localStorage.getItem('token')},
            data: top.reObject(param),
            method: 'POST',
            success: function (res) {
            },
        });
    });
    // 搜索栏重置事件
    form.on('submit(reset)', function (data) {
        pageCurr = 1;
        clearFormVal($('#search-box'));
        tableReload(false);
    });
    // 搜索栏搜索事件
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        tableReload(false);
    });
    // 监听行工具事件
    table.on('tool(locNormal)', function (obj) {
        var data = obj.data;
        var param = {
            matnr: data.matnr,
        }
        switch (obj.event) {
            case 'outLocNormal':
                // 出库
                $.ajax({
                    url: baseUrl + "/locNormal/outLoc/auth",
                    headers: {'token': localStorage.getItem('token')},
                    data: top.reObject(param),
                    method: 'POST',
                    success: function (res) {
                        tableReload(false);
                    },
                });
                break;
            case 'removeLocNormal':
                // 移除
                $.ajax({
                    url: baseUrl + "/locNormal/removeLoc/auth",
                    headers: {'token': localStorage.getItem('token')},
                    data: top.reObject(param),
                    method: 'POST',
                    success: function (res) {
                        tableReload(false);
                    },
                });
                break;
        }
    });
});
/* 表格数据重载 */
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function () {
        searchData[this.name] = this.value;
    });
    (child ? parent.tableIns : tableIns).reload({
        where: searchData,
        page: {
            curr: pageCurr
        },
        done: function (res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl + "/";
            }
            pageCurr = curr;
            if (res.data.length === 0 && count !== 0) {
                tableIns.reload({
                    where: searchData,
                    page: {
                        curr: pageCurr - 1
                    }
                });
                pageCurr -= 1;
            }
            limit(child);
            // 当前分页数据存储
            locNormalList = res.data;
        }
    });
}
/* 监听回车事件 */
$('body').keydown(function () {
    if (event.keyCode === 13) {
        $("#search").click();
    }
});
// 提取物料
var addLocNormalIdx;
function addLocNormal() {
    addLocNormalIdx = layer.open({
        type: 2,
        title: '新增',
        maxmin: true,
        area: [top.detailWidth, '550px'],
        shadeClose: true,
        content: 'addLocNormal.html',
        success: function (layero, index) {
        }
    });
}
src/main/webapp/views/locNormal/addLocNormal.html
New file
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/cool.css" media="all">
    <link rel="stylesheet" href="../../static/css/common.css" media="all">
</head>
<body>
<!-- 详情 -->
<div id="data-detail" class="layer_self_wrap">
    <form id="detail" class="layui-form">
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label"><span class="not-null">*</span>物料编码:</label>
            <div class="layui-input-inline">
                <input id="matnr" class="layui-input" type="text" onkeyup="check(this.id, 'matnr')" lay-verify="required" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">物料名称:</label>
            <div class="layui-input-inline">
                <input id="maktx" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">规格:</label>
            <div class="layui-input-inline">
                <input id="lgnum" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">类别:</label>
            <div class="layui-input-inline">
                <input id="type" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">单据编号:</label>
            <div class="layui-input-inline">
                <input id="mnemonic" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">通知单号:</label>
            <div class="layui-input-inline">
                <input id="supplier" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">仓库:</label>
            <div class="layui-input-inline">
                <input id="warehouse" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">品牌:</label>
            <div class="layui-input-inline">
                <input id="brand" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">数量:</label>
            <div class="layui-input-inline">
                <input id="anfme" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline"  style="width:31%;">
            <label class="layui-form-label">单位:</label>
            <div class="layui-input-inline">
                <input id="altme" class="layui-input" type="text" autocomplete="off">
            </div>
        </div>
        <hr class="layui-bg-gray">
        <div id="data-detail-btn" class="layui-btn-container layui-form-item">
            <div id="data-detail-submit-save" type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">保存</div>
            <div id="data-detail-close" type="button" class="layui-btn" lay-submit lay-filter="close">关闭</div>
        </div>
        <div id="prompt">
            温馨提示:请仔细填写相关信息,<span class="extrude"><span class="not-null">*</span> 为必填选项。</span>
        </div>
    </form>
</div>
</body>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/locNormal/addLocNormal.js" charset="utf-8"></script>
</html>
src/main/webapp/views/locNormal/locNormal.html
New file
@@ -0,0 +1,171 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/cool.css" media="all">
    <link rel="stylesheet" href="../../static/css/common.css" media="all">
    <link rel="stylesheet" href="../../static/css/print.css" media="all">
</head>
<style>
    #search-box {
        padding: 30px 30px 10px 30px;
    }
    #search-box .layui-inline {
        margin-right: 5px;
    }
    #data-search-btn {
        margin-top: 10px;
    }
    #data-search-btn.layui-btn-container .layui-btn {
        margin-right: 20px;
    }
    .btn-print {
        display: none;
    }
    #btn-print-batch {
        display: none;
    }
    .layui-btn-danger {
        background-color: lightsalmon;
        color: #333;
    }
    /* ------------------------- 打印表格 -----------------------  */
    .template-preview {
        height: 200px;
        display: inline-block;
    }
    .contain {
    }
    .contain td {
        border: 1px solid #000;
        /*line-height: 46px;*/
    }
    .function-area {
        padding: 15px 0 20px 40px;
    }
    .function-btn {
        font-size: 16px;
        padding: 1px 1px 1px 1px;
        width: 120px;
        height: 40px;
        border-color: #2b425b;
        border-radius: 4px;
        border-width: 1px;
        background: none;
        border-style: solid;
        transition: 0.4s;
        cursor: pointer;
    }
    .function-btn:hover {
        background-color: #2b425b;
        color: #fff;
    }
</style>
<body>
<div>
    <!-- 搜索栏 -->
    <div id="search-box" class="layui-form layui-card-header">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="matnr" placeholder="物料编码" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
            <select id="matStatusSelect" name="state">
                <option value="">请选择出入库状态</option>
                <option value="1">已入库</option>
                <option value="2">已出库</option>
            </select>
        </div>
        <!-- 待添加 -->
        <div id="data-search-btn" class="layui-btn-container layui-form-item" style="display: inline-block">
            <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">搜索
            </button>
            <button id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">重置
            </button>
        </div>
    </div>
    <!-- 功能区 -->
    <div class="function-area">
        <button id="mat-query" class="function-btn" onclick="addLocNormal()">新增库存</button>
    </div>
    <!-- 表格 -->
    <div class="layui-form">
        <table class="layui-hide" id="locNormal" lay-filter="locNormal"></table>
    </div>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" id="btn-locNormal-into" lay-event="intoData">导入</button>
        </div>
    </script>
    <!-- 导入操作弹窗 -->
    <div id="importDataDiv" style="display: none;padding: 20px 40px">
        <div class="layui-upload-drag" id="uploadEx"
             style="width: 200px; font-size: x-small; padding: 10px; text-align: center; box-sizing: border-box">
            <div id="uploadDesc" style="display: inline-block; ">
                <i class="layui-icon"></i>
                <p>点击添加,或将文件拖拽到此处</p>
            </div>
            <div id="uploadDemoView" style="display: none">
                <img src="../../static/image/Excel.png" alt="上传成功后渲染" style="max-width: 196px; padding: 20px 0 10px 0">
                <span id="fileMame" style="display: block; font-size: small; color: #333"></span>
            </div>
        </div>
        <div style="text-align: center; margin-top: 20px">
            <button class="layui-btn layui-btn-radius" id="uploadDo">开始导入</button>
        </div>
    </div>
    <!-- 表格自定义列 -->
    <script type="text/html" id="locNormalState">
        {{#  if(d.state === '1'){ }}
        <span style="color: green">已入库</span>
        {{# } else if(d.state === '2'){ }}
        <span style="color: red">已出库</span>
        {{#  } else { }}
        {{#  } }}
    </script>
    <script type="text/html" id="operate">
        <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="outLocNormal">出库</button>
        <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="removeLocNormal">移除</button>
    </script>
</div>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/locNormal/locNormal.js"></script>
</body>
</html>
version/v1.0.1/wjh.sql
File was deleted
version/version/wjh.sql
New file
@@ -0,0 +1,29 @@
/* v1.0.1  */
--表结构变更
alter table dbo.asr_loc_detl add mat_status varchar(10);
alter table dbo.asr_wrk_detl add mat_status varchar(10);
/* v1.0.2 2021.03.05 */
--表结构变更
CREATE TABLE [dbo].[asr_loc_normal](
    [matnr] [varchar](50) NOT NULL,
    [maktx] [nvarchar](50) NULL,
    [lgnum] [varchar](255) NULL,
    [type] [varchar](50) NULL,
    [mnemonic] [varchar](255) NULL,
    [supplier] [varchar](255) NULL,
    [warehouse] [varchar](255) NULL,
    [brand] [varchar](255) NULL,
    [anfme] [decimal](24, 9) NULL,
    [altme] [nvarchar](50) NULL,
    [bname] [nvarchar](50) NULL,
    [memo] [varchar](600) NULL,
    [modi_user] [bigint] NULL,
    [modi_time] [datetime] NULL,
    [appe_user] [bigint] NULL,
    [appe_time] [datetime] NULL,
    [state] [varchar](10) NULL,
 CONSTRAINT [PK_asr_loc_normal] PRIMARY KEY CLUSTERED
(
    [matnr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]