|
@@ -1,21 +1,27 @@
|
|
|
package com.gree.mall.manager.logic.material.stock;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
|
import com.gree.mall.manager.bean.listvo.material.WorkerStockAccPVO;
|
|
|
import com.gree.mall.manager.bean.listvo.material.WorkerStockAccVO;
|
|
|
import com.gree.mall.manager.bean.listvo.material.WorkerStockPVO;
|
|
|
import com.gree.mall.manager.bean.listvo.material.WorkerStockVO;
|
|
|
+import com.gree.mall.manager.bean.material.stock.WorkerStockDTO;
|
|
|
import com.gree.mall.manager.commonmapper.CommonMapper;
|
|
|
import com.gree.mall.manager.enums.material.DirectFlagEnum;
|
|
|
+import com.gree.mall.manager.enums.material.PartsAttrEnum;
|
|
|
import com.gree.mall.manager.enums.material.WebsitGoodsTypeEnum;
|
|
|
+import com.gree.mall.manager.enums.material.WorkerStockFlagEnum;
|
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.plus.entity.User;
|
|
|
import com.gree.mall.manager.plus.entity.WebsitGoods;
|
|
|
+import com.gree.mall.manager.plus.entity.WorkerGoods;
|
|
|
import com.gree.mall.manager.plus.entity.WorkerStock;
|
|
|
-import com.gree.mall.manager.plus.entity.WorkerStockAcc;
|
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
import com.gree.mall.manager.utils.CommonUtils;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
@@ -27,7 +33,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
@@ -37,17 +42,21 @@ public class WorkerStockLogic {
|
|
|
|
|
|
private final CommonLogic commonLogic;
|
|
|
private final CommonMapper commonMapper;
|
|
|
- private final WebsitGoodsService websitGoodsService;
|
|
|
+ private final WorkerGoodsService workerGoodsService;
|
|
|
private final WorkerStockService workerStockService;
|
|
|
private final WorkerStockAccService workerStockAccService;
|
|
|
private final AdminWebsitService adminWebsitService;
|
|
|
private final UserService userService;
|
|
|
+ private final WebsitGoodsStockLogic websitGoodsStockLogic;
|
|
|
+ private final WebsitGoodsService websitGoodsService;
|
|
|
+
|
|
|
/**
|
|
|
* 师傅辅材库存列表
|
|
|
+ *
|
|
|
* @param zfireParamBean
|
|
|
* @return
|
|
|
*/
|
|
|
- public IPage<WorkerStockVO> workerStockList(ZfireParamBean zfireParamBean){
|
|
|
+ public IPage<WorkerStockVO> workerStockList(ZfireParamBean zfireParamBean) {
|
|
|
final AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
FieldUtils.materialParam(zfireParamBean, WorkerStockVO.class, adminUser);
|
|
|
|
|
@@ -57,12 +66,13 @@ public class WorkerStockLogic {
|
|
|
|
|
|
/**
|
|
|
* 师傅辅材库存明细
|
|
|
+ *
|
|
|
* @param zfireParamBean
|
|
|
* @return
|
|
|
*/
|
|
|
- public IPage<WorkerStockAccVO> workerStockAccList(ZfireParamBean zfireParamBean){
|
|
|
+ public IPage<WorkerStockAccVO> workerStockAccList(ZfireParamBean zfireParamBean) {
|
|
|
zfireParamBean.setCompanyWechatId(commonLogic.getAdminUser().getCompanyWechatId());
|
|
|
- FieldUtils.supplyParam(zfireParamBean,WorkerStockAccVO.class);
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, WorkerStockAccVO.class);
|
|
|
IPage<WorkerStockAccVO> page = commonMapper.workerStockAccList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
return page;
|
|
|
}
|
|
@@ -70,24 +80,26 @@ public class WorkerStockLogic {
|
|
|
|
|
|
/**
|
|
|
* 师傅配件库存列表
|
|
|
+ *
|
|
|
* @param zfireParamBean
|
|
|
* @return
|
|
|
*/
|
|
|
- public IPage<WorkerStockPVO> workerStockPList(ZfireParamBean zfireParamBean){
|
|
|
+ public IPage<WorkerStockPVO> workerStockPList(ZfireParamBean zfireParamBean) {
|
|
|
zfireParamBean.setCompanyWechatId(commonLogic.getAdminUser().getCompanyWechatId());
|
|
|
- FieldUtils.supplyParam(zfireParamBean,WorkerStockPVO.class);
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, WorkerStockPVO.class);
|
|
|
IPage<WorkerStockPVO> page = commonMapper.workerStockPList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 师傅配件库存明细
|
|
|
+ *
|
|
|
* @param zfireParamBean
|
|
|
* @return
|
|
|
*/
|
|
|
- public IPage<WorkerStockAccPVO> workerStockAccPList(ZfireParamBean zfireParamBean){
|
|
|
+ public IPage<WorkerStockAccPVO> workerStockAccPList(ZfireParamBean zfireParamBean) {
|
|
|
zfireParamBean.setCompanyWechatId(commonLogic.getAdminUser().getCompanyWechatId());
|
|
|
- FieldUtils.supplyParam(zfireParamBean,WorkerStockAccPVO.class);
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, WorkerStockAccPVO.class);
|
|
|
IPage<WorkerStockAccPVO> page = commonMapper.workerStockAccPList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
return page;
|
|
|
}
|
|
@@ -95,99 +107,163 @@ public class WorkerStockLogic {
|
|
|
|
|
|
/**
|
|
|
* 导入师傅库存(各个商品只能导第一次)
|
|
|
+ *
|
|
|
* @param datas
|
|
|
*/
|
|
|
- public void importData(List<Object> datas, WebsitGoodsTypeEnum websitGoodsTypeEnum){
|
|
|
+ public void importData(List<Object> datas, WebsitGoodsTypeEnum websitGoodsTypeEnum) throws Exception {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
- List<WorkerStock> workerStocks = new ArrayList<>();
|
|
|
- List<WorkerStockAcc> workerStockAccs = new ArrayList<>();
|
|
|
- for(int i= 0 ;i<datas.size() ; i++){
|
|
|
- List<String> row = (List<String>)datas.get(i);
|
|
|
- CommonUtils.initList(row,10);
|
|
|
- String goodsId = row.get(0);
|
|
|
- String stock = row.get(1);
|
|
|
- String wayQty = row.get(2);
|
|
|
- String oldQty = row.get(3);
|
|
|
- //String websitName = row.get(4);
|
|
|
- String workerMobile = row.get(4);
|
|
|
- if(StringUtils.isAnyBlank(goodsId,stock,wayQty,oldQty,workerMobile)){
|
|
|
- throw new RemoteServiceException("第"+(i+1)+"行请补充完整内容");
|
|
|
- }
|
|
|
- WebsitGoods websitGoods = websitGoodsService.lambdaQuery()
|
|
|
- .eq(WebsitGoods::getCompanyWechatId,adminUser.getCompanyWechatId())
|
|
|
- .eq(WebsitGoods::getGoodsType,websitGoodsTypeEnum.getKey())
|
|
|
- .eq(WebsitGoods::getGoodsId,goodsId).one();
|
|
|
- if(websitGoods == null){
|
|
|
- throw new RemoteServiceException("商品编号【"+goodsId+"】不存在");
|
|
|
- }
|
|
|
-// AdminWebsit adminWebsit = adminWebsitService.lambdaQuery()
|
|
|
-// .eq(AdminWebsit::getName, websitName)
|
|
|
-// .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()),AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId()).one();
|
|
|
-// if(adminWebsit == null){
|
|
|
-// throw new RemoteServiceException("网点名字【"+websitName+"】不存在");
|
|
|
-// }
|
|
|
- //判断师傅信息
|
|
|
- User user = userService.lambdaQuery()
|
|
|
- .eq(User::getMobile, workerMobile)
|
|
|
- .eq(User::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
- .last("limit 1").one();
|
|
|
- if(user == null){
|
|
|
- throw new RemoteServiceException("师傅手机号【"+workerMobile+"】不存在");
|
|
|
- }
|
|
|
- Integer count = workerStockService.lambdaQuery()
|
|
|
- .eq(WorkerStock::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
- .eq(WorkerStock::getWorkerId,user.getUserId())
|
|
|
- .eq(WorkerStock::getGoodsId, goodsId).count();
|
|
|
- if(count > 0){
|
|
|
- throw new RemoteServiceException("商品编号【"+goodsId+"】的库存记录已存在于系统,导入失败");
|
|
|
- }
|
|
|
|
|
|
- WorkerStock bean = new WorkerStock();
|
|
|
- bean.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
- bean.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
-// bean.setWebsitId(adminWebsit.getWebsitId());
|
|
|
-// bean.setWebsitName(adminWebsit.getName());
|
|
|
- bean.setGoodsType(websitGoodsTypeEnum.getKey());
|
|
|
- bean.setGoodsId(goodsId);
|
|
|
- bean.setGoodsName(websitGoods.getGoodsName());
|
|
|
- bean.setGoodsType(websitGoods.getGoodsType());
|
|
|
- bean.setQty(new BigDecimal(stock));
|
|
|
- bean.setWayQty(new BigDecimal(wayQty));
|
|
|
- bean.setOldQty(new BigDecimal(oldQty));
|
|
|
- bean.setWorkerId(user.getUserId());
|
|
|
- bean.setIdentity(user.getIdCard());
|
|
|
- bean.setCreateBy(adminUser.getNickName());
|
|
|
- bean.setUpdateBy(adminUser.getNickName());
|
|
|
- workerStocks.add(bean);
|
|
|
-
|
|
|
- //网点库存三级帐
|
|
|
- WorkerStockAcc workerStockAcc = new WorkerStockAcc();
|
|
|
- workerStockAcc.setCompanyWechatId(bean.getCompanyWechatId());
|
|
|
- workerStockAcc.setCompanyWechatName(bean.getCompanyWechatName());
|
|
|
-// workerStockAcc.setWebsitId(bean.getWebsitId());
|
|
|
-// workerStockAcc.setWebsitName(bean.getWebsitName());
|
|
|
- workerStockAcc.setGoodsType(bean.getGoodsType());
|
|
|
- workerStockAcc.setWorkerId(bean.getWorkerId());
|
|
|
-// workerStockAcc.setWorkerWebsitName(bean.getWebsitName());
|
|
|
-// workerStockAcc.setWorkerWebsitId(bean.getWebsitId());
|
|
|
- //workerStockAcc.setPartsAttr(PartsAttrEnum.NEW.getKey());
|
|
|
- workerStockAcc.setGoodsId(bean.getGoodsId());
|
|
|
- workerStockAcc.setGoodsName(bean.getGoodsName());
|
|
|
- workerStockAcc.setSdate(new Date());
|
|
|
- workerStockAcc.setDirectFlag(DirectFlagEnum.ADD.getKey());
|
|
|
- workerStockAcc.setChangeQty(bean.getQty());
|
|
|
- workerStockAcc.setCloseQty(bean.getQty());
|
|
|
- workerStockAcc.setRef("system");
|
|
|
- workerStockAcc.setObj("system");
|
|
|
- workerStockAcc.setCreateBy(adminUser.getNickName());
|
|
|
- workerStockAcc.setCreateTime(new Date());
|
|
|
- workerStockAcc.setFlag("INIT");
|
|
|
- workerStockAcc.setRemark("期初导入");
|
|
|
- workerStockAccs.add(workerStockAcc);
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WorkerStockDTO> workerStockDTOS = new ArrayList<>();
|
|
|
+ final DateTime curDate = DateUtil.date();
|
|
|
+ final String idStr = IdWorker.getIdStr();
|
|
|
+
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ List<String> row = (List<String>) datas.get(i);
|
|
|
+ CommonUtils.initList(row, 10);
|
|
|
+ if (websitGoodsTypeEnum.getKey().equals(WebsitGoodsTypeEnum.M.getKey())) {
|
|
|
+ String goodsId = row.get(0);
|
|
|
+ String workerNumber = row.get(1);
|
|
|
+ String qty = row.get(2);
|
|
|
+ String price = row.get(3);
|
|
|
+ if (StringUtils.isAnyBlank(goodsId, workerNumber, qty, price)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行请补充完整内容");
|
|
|
+ }
|
|
|
+ WorkerGoods workerGoods = workerGoodsService.lambdaQuery()
|
|
|
+ .eq(WorkerGoods::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .eq(WorkerGoods::getGoodsId, goodsId)
|
|
|
+ .one();
|
|
|
+ if (workerGoods == null) {
|
|
|
+ throw new RemoteServiceException("商品编号【" + goodsId + "】不存在");
|
|
|
+ }
|
|
|
|
|
|
+ //判断师傅信息
|
|
|
+ User user = userService.lambdaQuery()
|
|
|
+ .eq(User::getWorkerNumber, workerNumber)
|
|
|
+ .eq(User::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+ if (user == null) {
|
|
|
+ throw new RemoteServiceException("师傅编号【" + workerNumber + "】不存在");
|
|
|
+ }
|
|
|
+ Integer count = workerStockService.lambdaQuery()
|
|
|
+ .eq(WorkerStock::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .eq(WorkerStock::getWorkerId, user.getUserId())
|
|
|
+ .eq(WorkerStock::getGoodsId, goodsId).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("商品编号【" + goodsId + "】的库存记录已存在于系统,导入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ WorkerStockDTO workerStockDTO = new WorkerStockDTO();
|
|
|
+ workerStockDTO.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
+ workerStockDTO.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
+ workerStockDTO.setIdentity(user.getIdCard());
|
|
|
+ workerStockDTO.setWorkerId(user.getWorkerNumber());
|
|
|
+ workerStockDTO.setWorkerName(user.getNickName());
|
|
|
+ workerStockDTO.setSdate(curDate);
|
|
|
+ workerStockDTO.setGoodsId(goodsId);
|
|
|
+ workerStockDTO.setGoodsName(workerGoods.getGoodsName());
|
|
|
+ workerStockDTO.setGoodsType(WebsitGoodsTypeEnum.M.getKey());
|
|
|
+ workerStockDTO.setPrice(new BigDecimal(price));
|
|
|
+ workerStockDTO.setUnitName(workerGoods.getSalesUnit());
|
|
|
+ workerStockDTO.setRef(idStr);
|
|
|
+ workerStockDTO.setRefType("库存导入");
|
|
|
+ workerStockDTO.setPartsAttr(PartsAttrEnum.NEW.getKey());
|
|
|
+ workerStockDTO.setChangeQty(new BigDecimal(qty));
|
|
|
+ workerStockDTO.setDirectFlag(DirectFlagEnum.ADD.getKey());
|
|
|
+ workerStockDTO.setFlag(WorkerStockFlagEnum.INIT.getKey());
|
|
|
+ workerStockDTO.setObj("师傅");
|
|
|
+ workerStockDTO.setWorkerOrderNo("");
|
|
|
+ workerStockDTO.setOperateBy(adminUser.getJoinNickName());
|
|
|
+ workerStockDTO.setOperateTime(curDate);
|
|
|
+ workerStockDTOS.add(workerStockDTO);
|
|
|
+ } else {
|
|
|
+ String goodsId = row.get(0);
|
|
|
+ String stock = row.get(1);
|
|
|
+ String oldQty = row.get(2);
|
|
|
+ //String websitName = row.get(4);
|
|
|
+ String workerId = row.get(4);
|
|
|
+ if (StringUtils.isAnyBlank(goodsId, stock, oldQty, workerId)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行请补充完整内容");
|
|
|
+ }
|
|
|
+ WebsitGoods websitGoods = websitGoodsService.lambdaQuery()
|
|
|
+ .eq(WebsitGoods::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .eq(WebsitGoods::getGoodsType, websitGoodsTypeEnum.getKey())
|
|
|
+ .eq(WebsitGoods::getGoodsId, goodsId)
|
|
|
+ .one();
|
|
|
+ if (websitGoods == null) {
|
|
|
+ throw new RemoteServiceException("商品编号【" + goodsId + "】不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断师傅信息
|
|
|
+ User user = userService.lambdaQuery()
|
|
|
+ .eq(User::getWorkerNumber, workerId)
|
|
|
+ .eq(User::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+ if (user == null) {
|
|
|
+ throw new RemoteServiceException("师傅编号【" + workerId + "】不存在");
|
|
|
+ }
|
|
|
+ Integer count = workerStockService.lambdaQuery()
|
|
|
+ .eq(WorkerStock::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .eq(WorkerStock::getWorkerId, user.getWorkerNumber())
|
|
|
+ .eq(WorkerStock::getGoodsId, goodsId)
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("商品编号【" + goodsId + "】的库存记录已存在于系统,导入失败");
|
|
|
+ }
|
|
|
+ WorkerStockDTO workerStockDTO = new WorkerStockDTO();
|
|
|
+ workerStockDTO.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
+ workerStockDTO.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
+ workerStockDTO.setIdentity(user.getIdCard());
|
|
|
+ workerStockDTO.setWorkerId(user.getWorkerNumber());
|
|
|
+ workerStockDTO.setWorkerName(user.getNickName());
|
|
|
+ workerStockDTO.setSdate(curDate);
|
|
|
+ workerStockDTO.setGoodsId(goodsId);
|
|
|
+ workerStockDTO.setGoodsName(websitGoods.getGoodsName());
|
|
|
+ workerStockDTO.setGoodsType(WebsitGoodsTypeEnum.M.getKey());
|
|
|
+ workerStockDTO.setUnitName(websitGoods.getGoodsSalesUnit());
|
|
|
+ workerStockDTO.setRef(idStr);
|
|
|
+ workerStockDTO.setRefType("库存导入");
|
|
|
+ workerStockDTO.setPartsAttr(PartsAttrEnum.OLD.getKey());
|
|
|
+ workerStockDTO.setChangeQty(new BigDecimal(stock));
|
|
|
+ workerStockDTO.setDirectFlag(DirectFlagEnum.ADD.getKey());
|
|
|
+ workerStockDTO.setFlag(WorkerStockFlagEnum.INIT.getKey());
|
|
|
+ workerStockDTO.setObj("师傅");
|
|
|
+ workerStockDTO.setWorkerOrderNo("");
|
|
|
+ workerStockDTO.setOperateBy(adminUser.getJoinNickName());
|
|
|
+ workerStockDTO.setOperateTime(curDate);
|
|
|
+ if (new BigDecimal(oldQty).compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ WorkerStockDTO workerStockDTO2 = new WorkerStockDTO();
|
|
|
+ workerStockDTO2.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
+ workerStockDTO2.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
+ workerStockDTO2.setIdentity(user.getIdCard());
|
|
|
+ workerStockDTO2.setWorkerId(user.getWorkerNumber());
|
|
|
+ workerStockDTO2.setWorkerName(user.getNickName());
|
|
|
+ workerStockDTO2.setSdate(curDate);
|
|
|
+ workerStockDTO2.setGoodsId(goodsId);
|
|
|
+ workerStockDTO2.setGoodsName(websitGoods.getGoodsName());
|
|
|
+ workerStockDTO2.setGoodsType(WebsitGoodsTypeEnum.M.getKey());
|
|
|
+ workerStockDTO2.setUnitName(websitGoods.getGoodsSalesUnit());
|
|
|
+ workerStockDTO2.setRef(idStr);
|
|
|
+ workerStockDTO2.setRefType("库存导入");
|
|
|
+ workerStockDTO2.setPartsAttr(PartsAttrEnum.NEW.getKey());
|
|
|
+ workerStockDTO2.setChangeQty(new BigDecimal(oldQty));
|
|
|
+ workerStockDTO2.setDirectFlag(DirectFlagEnum.ADD.getKey());
|
|
|
+ workerStockDTO2.setFlag(WorkerStockFlagEnum.INIT.getKey());
|
|
|
+ workerStockDTO2.setObj("师傅");
|
|
|
+ workerStockDTO2.setWorkerOrderNo("");
|
|
|
+ workerStockDTO2.setOperateBy(adminUser.getJoinNickName());
|
|
|
+ workerStockDTO2.setOperateTime(curDate);
|
|
|
+ }
|
|
|
+ workerStockDTOS.add(workerStockDTO);
|
|
|
+ }
|
|
|
}
|
|
|
- workerStockService.saveBatch(workerStocks);
|
|
|
- workerStockAccService.saveBatch(workerStockAccs);
|
|
|
+ // 开始处理库存
|
|
|
+ websitGoodsStockLogic.handleWorkerStock(workerStockDTOS);
|
|
|
}
|
|
|
|
|
|
}
|