浏览代码

feat:商品进销存

Joburgess 5 年之前
父节点
当前提交
8fe3730802

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -65,6 +65,15 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
     /**
      * @describe 根据货号查找商品
      * @author Joburgess
+     * @date 2020.10.10
+     * @param sn:
+     * @return com.ym.mec.biz.dal.entity.Goods
+     */
+    Goods findBySn(@Param("sn") String sn);
+
+    /**
+     * @describe 根据货号查找商品
+     * @author Joburgess
      * @date 2020.09.28
      * @param sns:
      * @return java.util.List<com.ym.mec.biz.dal.entity.Goods>

+ 14 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Goods.java

@@ -126,16 +126,27 @@ public class Goods {
 	private String supplyChannel;
 
 	@ApiModelProperty(value = "客户端是否展示")
-	private Integer clientShow;
+	private YesOrNoEnum clientShow;
 
 	@ApiModelProperty(value = "库存类型")
 	private StockType stockType;
 
-	public Integer getClientShow() {
+	@ApiModelProperty(value = "库存预警")
+	private YesOrNoEnum stockWarning;
+
+	public YesOrNoEnum getStockWarning() {
+		return stockWarning;
+	}
+
+	public void setStockWarning(YesOrNoEnum stockWarning) {
+		this.stockWarning = stockWarning;
+	}
+
+	public YesOrNoEnum getClientShow() {
 		return clientShow;
 	}
 
-	public void setClientShow(Integer clientShow) {
+	public void setClientShow(YesOrNoEnum clientShow) {
 		this.clientShow = clientShow;
 	}
 

+ 23 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/GoodsProcurement.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -7,35 +8,38 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
  */
 public class GoodsProcurement {
 
-	/**  */
+	@ApiModelProperty(value = "编号")
 	private Long id;
 	
-	/** 商品编号 */
+	@ApiModelProperty(value = "商品编号")
 	private Integer goodsId;
 	
-	/** 商品分类 */
+	@ApiModelProperty(value = "商品分类")
 	private Integer goodsCategoryId;
 	
-	/** 进货渠道 */
+	@ApiModelProperty(value = "进货渠道")
 	private String supplyChannel;
 	
-	/** 采购价一 */
+	@ApiModelProperty(value = "采购价一")
 	private java.math.BigDecimal discountPrice;
 	
-	/** 采购价二 */
+	@ApiModelProperty(value = "采购价二")
 	private java.math.BigDecimal agreeCostPrice;
 	
-	/** 总进货数量 */
+	@ApiModelProperty(value = "总进货数量")
 	private Integer totalQuantity;
 	
-	/** 税务数量 */
+	@ApiModelProperty(value = "税务数量")
 	private Integer taxQuantity;
 	
-	/** 进货人编号 */
+	@ApiModelProperty(value = "进货人编号")
 	private Integer operatorId;
 
-	/** 批次号 */
+	@ApiModelProperty(value = "批次号")
 	private String batchNo;
+
+	@ApiModelProperty(value = "售出数量")
+	private int soldNum;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -138,7 +142,15 @@ public class GoodsProcurement {
 	public java.util.Date getUpdateTime(){
 		return this.updateTime;
 	}
-			
+
+	public int getSoldNum() {
+		return soldNum;
+	}
+
+	public void setSoldNum(int soldNum) {
+		this.soldNum = soldNum;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 0 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsProcurementService.java

@@ -3,7 +3,6 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.page.GoodsProcurementQueryInfo;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface GoodsProcurementService extends BaseService<Long, GoodsProcurement> {
@@ -17,13 +16,4 @@ public interface GoodsProcurementService extends BaseService<Long, GoodsProcurem
      */
     PageInfo<GoodsProcurement> queryGoodsProcurements(GoodsProcurementQueryInfo queryInfo);
 
-    /**
-     * @describe 修改进货清单
-     * @author Joburgess
-     * @date 2020.10.09
-     * @param goodsProcurement:
-     * @return void
-     */
-    void updateGoodsProcurements(GoodsProcurement goodsProcurement);
-
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -11,6 +11,8 @@ import java.util.List;
 
 public interface GoodsService extends BaseService<Integer, Goods> {
 
+    void addGoodsProcurement(Goods goods, Integer operatorId);
+
     /**
      * 通过科目编号查询商品(教材、辅件)列表
      *
@@ -52,4 +54,13 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @return java.util.List<com.ym.mec.biz.dal.entity.Goods>
      */
     List<Goods> importGoods(MultipartFile file, Integer operatorId) throws Exception;
+
+    /**
+     * @describe 扣减商品库存
+     * @author Joburgess
+     * @date 2020.10.12
+     * @param goodsIds:
+     * @return java.lang.String
+     */
+    String subtractStock(List<Integer> goodsIds);
 }

+ 0 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsProcurementServiceImpl.java

@@ -6,10 +6,8 @@ import com.ym.mec.biz.dal.page.GoodsProcurementQueryInfo;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.service.GoodsProcurementService;
@@ -46,16 +44,4 @@ public class GoodsProcurementServiceImpl extends BaseServiceImpl<Long, GoodsProc
 		pageInfo.setRows(dataList);
 		return pageInfo;
 	}
-
-	@Override
-	public void updateGoodsProcurements(GoodsProcurement goodsProcurement) {
-		if(Objects.isNull(goodsProcurement.getId())){
-			throw new BizException("请指定进货清单");
-		}
-		GoodsProcurement existsGoodsProcurement = goodsProcurementDao.get(goodsProcurement.getId());
-		if(Objects.isNull(existsGoodsProcurement)){
-			throw new BizException("进货清单不存在");
-		}
-
-	}
 }

+ 45 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
@@ -55,6 +56,34 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addGoodsProcurement(Goods goods, Integer operatorId) {
+		Goods existsGood = goodsDao.findBySn(goods.getSn());
+		if(Objects.nonNull(existsGood)){
+			existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
+			existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
+			goodsDao.update(existsGood);
+		}else{
+			goodsDao.insert(existsGood);
+		}
+
+		String batchNo = idGeneratorService.generatorId("payment") + "";
+
+		GoodsProcurement gp = new GoodsProcurement();
+		gp.setGoodsId(existsGood.getId());
+		gp.setGoodsCategoryId(goods.getGoodsCategoryId());
+		gp.setSupplyChannel(goods.getSupplyChannel());
+		gp.setDiscountPrice(goods.getDiscountPrice());
+		gp.setAgreeCostPrice(goods.getAgreeCostPrice());
+		gp.setTotalQuantity(goods.getStockCount());
+		gp.setTaxQuantity(goods.getTaxStockCount());
+		gp.setOperatorId(operatorId);
+		gp.setBatchNo(batchNo);
+
+		goodsProcurementDao.insert(gp);
+	}
+
+	@Override
 	public List<Goods> findGoodsBySubId(Integer subjectId,String type) {
 		return goodsDao.findGoodsBySubId(subjectId,type);
 	}
@@ -138,7 +167,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					goods = JSONObject.parseObject(objectMap.toJSONString(),Goods.class);
 					goodsList.add(goods);
 				} catch (Exception ex) {
-					throw new BizException("导入数据出错");
+					throw new BizException("导入数据出错", ex);
 				}
 			}
 		}
@@ -190,4 +219,19 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 		return goodsList;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public String subtractStock(List<Integer> goodsIds) {
+		List result = new ArrayList();
+		if(CollectionUtils.isEmpty(goodsIds)){
+			return JSONObject.toJSONString(result);
+		}
+		List<Goods> tempGoods = goodsDao.getGoodies(goodsIds);
+		List<Integer> realGoodIds = new ArrayList<>();
+		for (Goods tempGood : tempGoods) {
+
+		}
+		return null;
+	}
 }

+ 4 - 6
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -144,9 +144,6 @@
             <if test="taxStockCount != null">
                 tax_stock_count_ = #{taxStockCount},
             </if>
-            <if test="supplyChannel != null">
-                supply_channel_ = #{supplyChannel},
-            </if>
         </set>
         WHERE id_ = #{id}
     </update>
@@ -221,9 +218,6 @@
                 <if test="goods.taxStockCount != null">
                     tax_stock_count_ = #{goods.taxStockCount},
                 </if>
-                <if test="goods.supplyChannel != null">
-                    supply_channel_ = #{goods.supplyChannel},
-                </if>
                     update_time_ = NOW()
             </set>
             WHERE id_ = #{goods.id}
@@ -302,6 +296,10 @@
         </foreach>
     </select>
 
+    <select id="findBySn" resultMap="Goods">
+        SELECT * FROM goods WHERE sn_ = #{sn}
+    </select>
+
     <select id="findBySns" resultMap="Goods">
         SELECT * FROM goods WHERE sn_ IN
         <foreach collection="sns" item="sn" separator="," open="(" close=")">

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/GoodsProcurementMapper.xml

@@ -94,7 +94,7 @@
 			<if test="goodsId!=null">
 				AND goods_id_ = #{goodsId}
 			</if>
-			<if test="enterStorageStartTime!=null AND enterStorageEndTime!=null">
+			<if test="enterStorageStartTime!=null and enterStorageEndTime!=null">
 				AND DATE_FORMAT(create_time_, '%Y-%m-%d') BETWEEN #{enterStorageStartTime} AND #{enterStorageEndTime}
 			</if>
 			<if test="search!=null and search!=''">

+ 10 - 1
mec-web/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -1,5 +1,7 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -25,12 +27,19 @@ public class GoodsController extends BaseController {
 
     @Autowired
     private GoodsService goodsService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation(value = "新增商品(教材、辅件)")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('goods/add')")
     public Object add(Goods goods){
-        return succeed(goodsService.insert(goods));
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        goodsService.addGoodsProcurement(goods,sysUser.getId());
+        return succeed();
     }
 
     @ApiOperation(value = "删除商品(教材、辅件)")

+ 9 - 3
mec-web/src/main/java/com/ym/mec/web/controller/GoodsProcurementContrller.java

@@ -1,18 +1,25 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.page.GoodsProcurementQueryInfo;
 import com.ym.mec.biz.service.GoodsProcurementService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @Author Joburgess
  * @Date 2020.10.09
  */
+@Api(tags = "进货清单")
 @RestController
 @RequestMapping("goodsProcurement")
 public class GoodsProcurementContrller extends BaseController {
@@ -20,11 +27,10 @@ public class GoodsProcurementContrller extends BaseController {
     @Autowired
     private GoodsProcurementService goodsProcurementService;
 
+    @ApiOperation(value = "分页查询进货清单")
     @GetMapping("queryGoodsProcurements")
-    public HttpResponseResult queryGoodsProcurements(GoodsProcurementQueryInfo queryInfo){
+    public HttpResponseResult<PageInfo<GoodsProcurement>> queryGoodsProcurements(GoodsProcurementQueryInfo queryInfo){
         return succeed(goodsProcurementService.queryGoodsProcurements(queryInfo));
     }
 
-
-
 }

+ 6 - 2
mec-web/src/main/resources/columnMapper.ini

@@ -11,9 +11,13 @@
 商品图片(插入一张图片) = image
 商品明细 = desc
 商品采购价2(元) = agreeCostPrice
-商品数量 = stockCount
-税务数量 = taxStockCount
+内部库存 = stockCount
+税务库存 = taxStockCount
 备查货号 = supplyChannel
+是否App展示 = clientShow
+库存类型 = stockType
+商品详情 = desc
+库存预警 = stockWarning
 
 [财务支出导入模板]
 财务流程编号 = financialProcessNo

二进制
mec-web/src/main/resources/excelTemplate/商品导入模板.xls