Sfoglia il codice sorgente

Merge branch 'master_liaozeyong' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie

# Conflicts:
#	jshERP-web/src/views/system/modules/userSupplierModal.vue
#	src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java
#	src/main/resources/mapper_xml/DepotHeadMapper.xml
huang 1 mese fa
parent
commit
db7155e1bd

+ 9 - 13
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -74,6 +74,9 @@ public class PdaController extends BaseController {
     @Resource
     private ApkVersionService apkVersionService;
 
+    @Resource
+    private DepotService depotService;
+
     /**
      * 采购入库
      * @return
@@ -135,7 +138,7 @@ public class PdaController extends BaseController {
         } else {
             type = "出库";
         }
-        List<PDADepotItemVO> list = depotItemService.materialDepotDetail(type , materialId);
+        List<PDADepotItemVO> list = depotItemService.materialDepotDetail(type, materialId);
         return getDataTable(list);
     }
 
@@ -247,18 +250,6 @@ public class PdaController extends BaseController {
         return AjaxResult.success(spinnerVOList);
     }
 
-    @ApiOperation("订单-用于返回字段说明")
-    @GetMapping("test")
-    public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
-        return AjaxResult.success();
-    }
-
-    @ApiOperation("盘点-用于字段返回说明")
-    @GetMapping("taskTest")
-    public AjaxResult taskTest(PDATaskStocktakingVO pdaTaskStocktakingVO){
-        return AjaxResult.success();
-    }
-
     /**
      * PDA订单提交
      */
@@ -294,6 +285,11 @@ public class PdaController extends BaseController {
         return AjaxResult.success(materialCategoryService.getMaterialCategoryTree(null));
     }
 
+    @ApiOperation("仓库下拉框")
+    @GetMapping("/depotSpinnerList")
+    public AjaxResult depotSpinnerList() {
+        return AjaxResult.success(depotService.depotSpinnerList());
+    }
 
     @ApiOperation("下载安装包")
     @PostMapping("/downloadApk")

+ 1 - 1
src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingItemQueryDTO.java

@@ -21,7 +21,7 @@ public class TaskStocktakingItemQueryDTO {
     private String batchNumber;
 
     @ApiModelProperty("仓库货架")
-    private Long position;
+    private String position;
 
     @ApiModelProperty("是否存在差异 1:是,2:否,其他是全部")
     private String isDifference;

+ 0 - 3
src/main/java/com/jsh/erp/datasource/entities/DepotHead.java

@@ -139,9 +139,6 @@ public class DepotHead {
     @ApiModelProperty("收货人地址")
     private String receiverAddress;
 
-    @ApiModelProperty("仓库id")
-    private Long depotId;
-
     @ApiModelProperty("操作人")
     private Long operId;
 

+ 1 - 1
src/main/java/com/jsh/erp/datasource/entities/TaskStocktaking.java

@@ -43,7 +43,7 @@ public class TaskStocktaking {
     private Integer categoryCount;
 
     @ApiModelProperty("商品数")
-    private int materialCount;
+    private Integer materialCount;
 
     @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消,5.已更新")
     private Integer taskStatus;

+ 1 - 1
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapper.java

@@ -29,7 +29,7 @@ public interface DepotItemMapper  extends BaseMapperX<DepotItem>{
      * @param materialId 商品ID
      * @return
      */
-    List<PDADepotItemVO> materialDepotDetail(@Param("type")String type , @Param("materialId") Long materialId);
+    List<PDADepotItemVO> materialDepotDetail(@Param("type")String type, @Param("materialId") Long materialId);
 
     long countByExample(DepotItemExample example);
 

+ 10 - 1
src/main/java/com/jsh/erp/datasource/mappers/DepotMapper.java

@@ -3,9 +3,18 @@ package com.jsh.erp.datasource.mappers;
 import com.jsh.erp.datasource.entities.Depot;
 import com.jsh.erp.datasource.entities.DepotExample;
 import java.util.List;
+
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import org.apache.ibatis.annotations.Param;
 
-public interface DepotMapper {
+public interface DepotMapper extends BaseMapperX<Depot> {
+
+    /**
+     * 仓库下拉框
+     * @return
+     */
+    List<SpinnerVO> depotSpinnerList();
+
     long countByExample(DepotExample example);
 
     int deleteByExample(DepotExample example);

+ 3 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotItemVO.java

@@ -65,5 +65,8 @@ public class PDADepotItemVO{
     @ApiModelProperty("图片名称")
     private String imgName;
 
+    @ApiModelProperty("出入库时间")
+    private Date warehousingTime;
+
 
 }

+ 18 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingItemVO.java

@@ -80,4 +80,22 @@ public class TaskStocktakingItemVO {
     @ApiModelProperty("删除标记,0.未删除,1.已删除")
     private boolean deleteFlag;
 
+    @ApiModelProperty("商品规格")
+    private String standard;
+
+    @ApiModelProperty("商品型号")
+    private String model;
+
+    @ApiModelProperty("商品颜色")
+    private String color;
+
+    @ApiModelProperty("商品品牌")
+    private String brand;
+
+    @ApiModelProperty("商品多属性")
+    private String sku;
+
+    @ApiModelProperty("商品保质期天数")
+    private String expiryNum;
+
 }

+ 29 - 334
src/main/java/com/jsh/erp/service/DepotService.java

@@ -1,370 +1,65 @@
 package com.jsh.erp.service;
 
+
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.entities.*;
-import com.jsh.erp.datasource.mappers.*;
-import com.jsh.erp.exception.BusinessRunTimeException;
-import com.jsh.erp.exception.JshException;
-import com.jsh.erp.utils.PageUtils;
-import com.jsh.erp.utils.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.Depot;
+import com.jsh.erp.datasource.entities.DepotEx;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
-@Service
-public class DepotService {
-    private Logger logger = LoggerFactory.getLogger(DepotService.class);
+public interface DepotService extends IService<Depot> {
 
-    @Resource
-    private DepotMapper depotMapper;
-    @Resource
-    private DepotMapperEx depotMapperEx;
-    @Resource
-    private UserService userService;
-    @Resource
-    private SystemConfigService systemConfigService;
-    @Resource
-    private UserBusinessService userBusinessService;
-    @Resource
-    private LogService logService;
-    @Resource
-    private DepotItemMapperEx depotItemMapperEx;
-    @Resource
-    private MaterialInitialStockMapperEx materialInitialStockMapperEx;
-    @Resource
-    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+    /**
+     * 获取下拉框
+     * @return
+     */
+    List<SpinnerVO> depotSpinnerList();
 
-    public Depot getDepot(long id)throws Exception {
-        Depot result=null;
-        try{
-            result=depotMapper.selectByPrimaryKey(id);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return result;
-    }
+    Depot getDepot(long id)throws Exception;
 
-    public List<Depot> getDepotListByIds(String ids)throws Exception {
-        List<Long> idList = StringUtil.strToLongList(ids);
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdIn(idList);
-        return depotMapper.selectByExample(example);
-    }
+    List<Depot> getDepotListByIds(String ids)throws Exception;
 
-    public List<Depot> getDepot()throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list=null;
-        try{
-            list=depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<Depot> getDepot()throws Exception;
 
-    public List<Depot> getAllList()throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        example.setOrderByClause("sort asc, id desc");
-        List<Depot> list=null;
-        try{
-            list=depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<Depot> getAllList()throws Exception;
 
-    public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
-        List<DepotEx> list=null;
-        try{
-            PageUtils.startPage();
-            list=depotMapperEx.selectByConditionDepot(name, type, remark);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<DepotEx> select(String name, Integer type, String remark)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception {
-        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
-        int result=0;
-        try{
-            depot.setType(0);
-            List<Depot> depotList = getDepot();
-            if(depotList.size() == 0) {
-                depot.setIsDefault(true);
-            } else {
-                depot.setIsDefault(false);
-            }
-            depot.setEnabled(true);
-            result=depotMapper.insertSelective(depot);
-            //新增仓库时给当前用户自动授权
-            Long userId = userService.getUserId(request);
-            Long depotId = getIdByName(depot.getName());
-            String ubKey = "[" + depotId + "]";
-            List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserDepot");
-            if(ubList ==null || ubList.size() == 0) {
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("type", "UserDepot");
-                ubObj.put("keyId", userId);
-                ubObj.put("value", ubKey);
-                userBusinessService.insertUserBusiness(ubObj, request);
-            } else {
-                UserBusiness ubInfo = ubList.get(0);
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("id", ubInfo.getId());
-                ubObj.put("type", ubInfo.getType());
-                ubObj.put("keyId", ubInfo.getKeyId());
-                ubObj.put("value", ubInfo.getValue() + ubKey);
-                userBusinessService.updateUserBusiness(ubObj, request);
-            }
-            logService.insertLog("仓库",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception{
-        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
-        int result=0;
-        try{
-            result= depotMapper.updateByPrimaryKeySelective(depot);
-            logService.insertLog("仓库",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depot.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int deleteDepot(Long id, HttpServletRequest request)throws Exception {
-        return batchDeleteDepotByIds(id.toString());
-    }
+    int deleteDepot(Long id, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception{
-        return batchDeleteDepotByIds(ids);
-    }
+    int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteDepotByIds(String ids)throws Exception {
-        int result=0;
-        String [] idArray=ids.split(",");
-        //校验单据子表	jsh_depot_item
-        List<DepotItem> depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
-        if(depotItemList!=null&&depotItemList.size()>0){
-            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
-            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
-        }
-        try{
-            //记录日志
-            StringBuffer sb = new StringBuffer();
-            sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
-            List<Depot> list = getDepotListByIds(ids);
-            for(Depot depot: list){
-                sb.append("[").append(depot.getName()).append("]");
-            }
-            User userInfo=userService.getCurrentUser();
-            //校验通过执行删除操作
-            //删除仓库关联的商品的初始库存
-            materialInitialStockMapperEx.batchDeleteByDepots(idArray);
-            //删除仓库关联的商品的当前库存
-            materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
-            //删除仓库
-            result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
-            //记录日志
-            logService.insertLog("仓库", sb.toString(),
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        } catch (Exception e) {
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int batchDeleteDepotByIds(String ids)throws Exception;
 
-    public int checkIsNameExist(Long id, String name)throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list=null;
-        try{
-            list= depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list==null?0:list.size();
-    }
+    int checkIsNameExist(Long id, String name)throws Exception;
 
-    public List<Depot> findUserDepot()throws Exception{
-        DepotExample example = new DepotExample();
-        example.createCriteria().andTypeEqualTo(0).andEnabledEqualTo(true)
-                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        example.setOrderByClause("sort asc, id desc");
-        List<Depot> list=null;
-        try{
-            list= depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<Depot> findUserDepot()throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateIsDefault(Long depotId) throws Exception{
-        int result=0;
-        try{
-            //全部取消默认
-            Depot allDepot = new Depot();
-            allDepot.setIsDefault(false);
-            DepotExample allExample = new DepotExample();
-            allExample.createCriteria();
-            depotMapper.updateByExampleSelective(allDepot, allExample);
-            //给指定仓库设为默认
-            Depot depot = new Depot();
-            depot.setIsDefault(true);
-            DepotExample example = new DepotExample();
-            example.createCriteria().andIdEqualTo(depotId);
-            depotMapper.updateByExampleSelective(depot, example);
-            logService.insertLog("仓库",BusinessConstants.LOG_OPERATION_TYPE_EDIT+depotId,
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-            result = 1;
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
-
-    /**
-     * 根据名称获取id
-     * @param name
-     */
-    public Long getIdByName(String name){
-        Long id = 0L;
-        DepotExample example = new DepotExample();
-        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list = depotMapper.selectByExample(example);
-        if(list!=null && list.size()>0) {
-            id = list.get(0).getId();
-        }
-        return id;
-    }
+    int updateIsDefault(Long depotId) throws Exception;
 
+    Long getIdByName(String name);
 
-    /**
-     * 解析仓库列表
-     * @param depotId 仓库id
-     * @return 仓库id为空,返回当前用户有权限的仓库,不为空返回仓库id的集合
-     */
-    public List<Long> parseDepotList(Long depotId) throws Exception {
-        List<Long> depotList = new ArrayList<>();
-        if(depotId !=null) {
-            depotList.add(depotId);
-        } else {
-            //未选择仓库时默认为当前用户有权限的仓库
-            JSONArray depotArr = findDepotByCurrentUser();
-            for(Object obj: depotArr) {
-                JSONObject object = JSONObject.parseObject(obj.toString());
-                depotList.add(object.getLong("id"));
-            }
-        }
-        return depotList;
-    }
+    List<Long> parseDepotList(Long depotId) throws Exception;
 
-    public JSONArray findDepotByCurrentUser() throws Exception {
-        JSONArray arr = new JSONArray();
-        String type = "UserDepot";
-        Long userId = userService.getCurrentUser().getId();
-        List<Depot> dataList = findUserDepot();
-        //开始拼接json数据
-        if (null != dataList) {
-            boolean depotFlag = systemConfigService.getDepotFlag();
-            if(depotFlag) {
-                List<UserBusiness> list = userBusinessService.getBasicData(userId.toString(), type);
-                if(list!=null && list.size()>0) {
-                    String depotStr = list.get(0).getValue();
-                    if(StringUtil.isNotEmpty(depotStr)){
-                        depotStr = depotStr.replaceAll("\\[", "").replaceAll("]", ",");
-                        String[] depotArr = depotStr.split(",");
-                        for (Depot depot : dataList) {
-                            for(String depotId: depotArr) {
-                                if(depot.getId() == Long.parseLong(depotId)){
-                                    JSONObject item = new JSONObject();
-                                    item.put("id", depot.getId());
-                                    item.put("depotName", depot.getName());
-                                    item.put("isDefault", depot.getIsDefault());
-                                    arr.add(item);
-                                }
-                            }
-                        }
-                    }
-                }
-            } else {
-                for (Depot depot : dataList) {
-                    JSONObject item = new JSONObject();
-                    item.put("id", depot.getId());
-                    item.put("depotName", depot.getName());
-                    item.put("isDefault", depot.getIsDefault());
-                    arr.add(item);
-                }
-            }
-        }
-        return arr;
-    }
+    JSONArray findDepotByCurrentUser() throws Exception;
 
-    /**
-     * 当前用户有权限使用的仓库列表的id,用逗号隔开
-     * @return
-     * @throws Exception
-     */
-    public String findDepotStrByCurrentUser() throws Exception {
-        JSONArray arr =  findDepotByCurrentUser();
-        StringBuffer sb = new StringBuffer();
-        for(Object object: arr) {
-            JSONObject obj = (JSONObject)object;
-            sb.append(obj.getLong("id")).append(",");
-        }
-        String depotStr = sb.toString();
-        if(StringUtil.isNotEmpty(depotStr)){
-            depotStr = depotStr.substring(0, depotStr.length()-1);
-        }
-        return depotStr;
-    }
+    String findDepotStrByCurrentUser() throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchSetStatus(Boolean status, String ids)throws Exception {
-        logService.insertLog("仓库",
-                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ENABLED).toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        List<Long> depotIds = StringUtil.strToLongList(ids);
-        Depot depot = new Depot();
-        depot.setEnabled(status);
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdIn(depotIds);
-        int result=0;
-        try{
-            result = depotMapper.updateByExampleSelective(depot, example);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int batchSetStatus(Boolean status, String ids)throws Exception;
 }

+ 1 - 2
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -101,8 +101,7 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
      */
     @Override
     public List<PDADepotItemVO> materialDepotDetail(String type , Long materialId) {
-        List<PDADepotItemVO> list = depotItemMapper.materialDepotDetail(type , materialId);
-        return list;
+        return depotItemMapper.materialDepotDetail(type, materialId);
     }
 
     @Override

+ 396 - 0
src/main/java/com/jsh/erp/service/impl/DepotServiceImpl.java

@@ -0,0 +1,396 @@
+package com.jsh.erp.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.constants.BusinessConstants;
+import com.jsh.erp.constants.ExceptionConstants;
+import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.mappers.*;
+import com.jsh.erp.datasource.vo.SpinnerVO;
+import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.exception.JshException;
+import com.jsh.erp.service.*;
+import com.jsh.erp.utils.PageUtils;
+import com.jsh.erp.utils.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class DepotServiceImpl extends ServiceImpl<DepotMapper, Depot> implements DepotService {
+    private Logger logger = LoggerFactory.getLogger(DepotService.class);
+
+    @Resource
+    private DepotMapper depotMapper;
+    @Resource
+    private DepotMapperEx depotMapperEx;
+    @Resource
+    private UserService userService;
+    @Resource
+    private SystemConfigService systemConfigService;
+    @Resource
+    private UserBusinessService userBusinessService;
+    @Resource
+    private LogService logService;
+    @Resource
+    private DepotItemMapperEx depotItemMapperEx;
+    @Resource
+    private MaterialInitialStockMapperEx materialInitialStockMapperEx;
+    @Resource
+    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+
+    @Override
+    public List<SpinnerVO> depotSpinnerList() {
+        return depotMapper.depotSpinnerList();
+    }
+
+    @Override
+    public Depot getDepot(long id)throws Exception {
+        Depot result=null;
+        try{
+            result=depotMapper.selectByPrimaryKey(id);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public List<Depot> getDepotListByIds(String ids)throws Exception {
+        List<Long> idList = StringUtil.strToLongList(ids);
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdIn(idList);
+        return depotMapper.selectByExample(example);
+    }
+
+    @Override
+    public List<Depot> getDepot()throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list=null;
+        try{
+            list=depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<Depot> getAllList()throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        example.setOrderByClause("sort asc, id desc");
+        List<Depot> list=null;
+        try{
+            list=depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
+        List<DepotEx> list=null;
+        try{
+            PageUtils.startPage();
+            list=depotMapperEx.selectByConditionDepot(name, type, remark);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception {
+        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
+        int result=0;
+        try{
+            depot.setType(0);
+            List<Depot> depotList = getDepot();
+            if(depotList.size() == 0) {
+                depot.setIsDefault(true);
+            } else {
+                depot.setIsDefault(false);
+            }
+            depot.setEnabled(true);
+            result=depotMapper.insertSelective(depot);
+            //新增仓库时给当前用户自动授权
+            Long userId = userService.getUserId(request);
+            Long depotId = getIdByName(depot.getName());
+            String ubKey = "[" + depotId + "]";
+            List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserDepot");
+            if(ubList ==null || ubList.size() == 0) {
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("type", "UserDepot");
+                ubObj.put("keyId", userId);
+                ubObj.put("value", ubKey);
+                userBusinessService.insertUserBusiness(ubObj, request);
+            } else {
+                UserBusiness ubInfo = ubList.get(0);
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("id", ubInfo.getId());
+                ubObj.put("type", ubInfo.getType());
+                ubObj.put("keyId", ubInfo.getKeyId());
+                ubObj.put("value", ubInfo.getValue() + ubKey);
+                userBusinessService.updateUserBusiness(ubObj, request);
+            }
+            logService.insertLog("仓库",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception{
+        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
+        int result=0;
+        try{
+            result= depotMapper.updateByPrimaryKeySelective(depot);
+            logService.insertLog("仓库",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depot.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int deleteDepot(Long id, HttpServletRequest request)throws Exception {
+        return batchDeleteDepotByIds(id.toString());
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception{
+        return batchDeleteDepotByIds(ids);
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteDepotByIds(String ids)throws Exception {
+        int result=0;
+        String [] idArray=ids.split(",");
+        //校验单据子表	jsh_depot_item
+        List<DepotItem> depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
+        if(depotItemList!=null&&depotItemList.size()>0){
+            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
+        }
+        try{
+            //记录日志
+            StringBuffer sb = new StringBuffer();
+            sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
+            List<Depot> list = getDepotListByIds(ids);
+            for(Depot depot: list){
+                sb.append("[").append(depot.getName()).append("]");
+            }
+            User userInfo=userService.getCurrentUser();
+            //校验通过执行删除操作
+            //删除仓库关联的商品的初始库存
+            materialInitialStockMapperEx.batchDeleteByDepots(idArray);
+            //删除仓库关联的商品的当前库存
+            materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
+            //删除仓库
+            result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
+            //记录日志
+            logService.insertLog("仓库", sb.toString(),
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        } catch (Exception e) {
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public int checkIsNameExist(Long id, String name)throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list=null;
+        try{
+            list= depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list==null?0:list.size();
+    }
+
+    @Override
+    public List<Depot> findUserDepot()throws Exception{
+        DepotExample example = new DepotExample();
+        example.createCriteria().andTypeEqualTo(0).andEnabledEqualTo(true)
+                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        example.setOrderByClause("sort asc, id desc");
+        List<Depot> list=null;
+        try{
+            list= depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateIsDefault(Long depotId) throws Exception{
+        int result=0;
+        try{
+            //全部取消默认
+            Depot allDepot = new Depot();
+            allDepot.setIsDefault(false);
+            DepotExample allExample = new DepotExample();
+            allExample.createCriteria();
+            depotMapper.updateByExampleSelective(allDepot, allExample);
+            //给指定仓库设为默认
+            Depot depot = new Depot();
+            depot.setIsDefault(true);
+            DepotExample example = new DepotExample();
+            example.createCriteria().andIdEqualTo(depotId);
+            depotMapper.updateByExampleSelective(depot, example);
+            logService.insertLog("仓库",BusinessConstants.LOG_OPERATION_TYPE_EDIT+depotId,
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+            result = 1;
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    /**
+     * 根据名称获取id
+     * @param name
+     */
+    @Override
+    public Long getIdByName(String name){
+        Long id = 0L;
+        DepotExample example = new DepotExample();
+        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list = depotMapper.selectByExample(example);
+        if(list!=null && list.size()>0) {
+            id = list.get(0).getId();
+        }
+        return id;
+    }
+
+
+    /**
+     * 解析仓库列表
+     * @param depotId 仓库id
+     * @return 仓库id为空,返回当前用户有权限的仓库,不为空返回仓库id的集合
+     */
+    @Override
+    public List<Long> parseDepotList(Long depotId) throws Exception {
+        List<Long> depotList = new ArrayList<>();
+        if(depotId !=null) {
+            depotList.add(depotId);
+        } else {
+            //未选择仓库时默认为当前用户有权限的仓库
+            JSONArray depotArr = findDepotByCurrentUser();
+            for(Object obj: depotArr) {
+                JSONObject object = JSONObject.parseObject(obj.toString());
+                depotList.add(object.getLong("id"));
+            }
+        }
+        return depotList;
+    }
+
+    @Override
+    public JSONArray findDepotByCurrentUser() throws Exception {
+        JSONArray arr = new JSONArray();
+        String type = "UserDepot";
+        Long userId = userService.getCurrentUser().getId();
+        List<Depot> dataList = findUserDepot();
+        //开始拼接json数据
+        if (null != dataList) {
+            boolean depotFlag = systemConfigService.getDepotFlag();
+            if(depotFlag) {
+                List<UserBusiness> list = userBusinessService.getBasicData(userId.toString(), type);
+                if(list!=null && list.size()>0) {
+                    String depotStr = list.get(0).getValue();
+                    if(StringUtil.isNotEmpty(depotStr)){
+                        depotStr = depotStr.replaceAll("\\[", "").replaceAll("]", ",");
+                        String[] depotArr = depotStr.split(",");
+                        for (Depot depot : dataList) {
+                            for(String depotId: depotArr) {
+                                if(depot.getId() == Long.parseLong(depotId)){
+                                    JSONObject item = new JSONObject();
+                                    item.put("id", depot.getId());
+                                    item.put("depotName", depot.getName());
+                                    item.put("isDefault", depot.getIsDefault());
+                                    arr.add(item);
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                for (Depot depot : dataList) {
+                    JSONObject item = new JSONObject();
+                    item.put("id", depot.getId());
+                    item.put("depotName", depot.getName());
+                    item.put("isDefault", depot.getIsDefault());
+                    arr.add(item);
+                }
+            }
+        }
+        return arr;
+    }
+
+    /**
+     * 当前用户有权限使用的仓库列表的id,用逗号隔开
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String findDepotStrByCurrentUser() throws Exception {
+        JSONArray arr =  findDepotByCurrentUser();
+        StringBuffer sb = new StringBuffer();
+        for(Object object: arr) {
+            JSONObject obj = (JSONObject)object;
+            sb.append(obj.getLong("id")).append(",");
+        }
+        String depotStr = sb.toString();
+        if(StringUtil.isNotEmpty(depotStr)){
+            depotStr = depotStr.substring(0, depotStr.length()-1);
+        }
+        return depotStr;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchSetStatus(Boolean status, String ids)throws Exception {
+        logService.insertLog("仓库",
+                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ENABLED).toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        List<Long> depotIds = StringUtil.strToLongList(ids);
+        Depot depot = new Depot();
+        depot.setEnabled(status);
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdIn(depotIds);
+        int result=0;
+        try{
+            result = depotMapper.updateByExampleSelective(depot, example);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+}

+ 1 - 7
src/main/resources/mapper_xml/DepotHeadMapper.xml

@@ -279,9 +279,6 @@
       <if test="receiverAddress != null">
         receiver_address,
       </if>
-      <if test="depotId != null">
-        depot_id,
-      </if>
       <if test="operId != null">
         oper_id
       </if>
@@ -404,9 +401,6 @@
       <if test="receiverAddress != null">
         #{receiverAddress,jdbcType=VARCHAR},
       </if>
-      <if test="depotId != null">
-        #{depotId,jdbcType=INTEGER},
-      </if>
       <if test="operId != null">
         #{operId,jdbcType=INTEGER}
       </if>
@@ -801,7 +795,7 @@
     FROM
       jsh_depot_head dh
       LEFT JOIN jsh_supplier s ON dh.organ_id = s.id
-      LEFT JOIN jsh
+      LEFT JOIN jsh_
     WHERE
       dh.id = #{id}
   </select>

+ 10 - 0
src/main/resources/mapper_xml/DepotMapper.xml

@@ -335,4 +335,14 @@
       is_default = #{isDefault,jdbcType=BIT}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+  <select id="depotSpinnerList" resultType="com.jsh.erp.datasource.vo.SpinnerVO">
+    SELECT
+      id AS value,
+      bane AS label
+    FROM
+      jsh_depot
+    WHERE
+      delete_Flag = '0'
+  </select>
 </mapper>

+ 13 - 3
src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml

@@ -28,9 +28,10 @@
             tsi.delete_flag = 0
             AND tsi.task_stocktaking_id = #{taskId}
             <if test="number != null and number != ''">
-                m.name LIKE CONCAT('%',#{number},'%')
+                AND (m.name LIKE CONCAT('%',#{number},'%')
                 OR me.batch_number LIKE CONCAT('%',#{number},'%')
-                OR m.system_sku LIKE CONCAT('%',#{number},'%')
+                OR me.position LIKE CONCAT('%',#{number},'%')
+                OR m.system_sku LIKE CONCAT('%',#{number},'%'))
             </if>
             <if test="userIdList != null and userIdList.size > 0">
                 AND tsi.creator IN
@@ -50,6 +51,9 @@
                      me.position LIKE CONCAT('%',#{item},'%')
                 </foreach>
             </if>
+            <if test="position != null and position != ''">
+                AND me.position LIKE CONCAT('%',#{position},'%')
+            </if>
             <if test="statusList != null and statusList.size > 0">
                 AND tsi.status IN
                 <foreach collection="statusList" item="item" open="(" separator="," close=")">
@@ -67,14 +71,20 @@
             tsi.id AS id,
             mc.`name` AS category_name,
             m.`name` AS material_name,
+            m.standard AS standard,
+            m.model AS model,
+            m.color AS color,
+            m.brand AS brand,
             me.position AS position,
             me.batch_number AS batch_number,
             m.system_sku AS system_sku,
+            me.sku AS sku,
             me.commodity_unit AS commodity_unit,
             me.production_date AS production_date,
             s.supplier AS supplier_name,
             me.bar_code AS bar_code,
             me.inventory AS inventory,
+            me.expiry_num AS expiry_num,
             d.`name` AS depot_name,
             tsi.new_position AS new_position,
             tsi.new_inventory AS new_inventory,
@@ -100,7 +110,7 @@
                 AND me.batch_number = #{batchNumber}
             </if>
             <if test="position != null and position != ''">
-                AND me.position = #{position}
+                AND me.position LIKE  CONCAT('%',#{position},'%')
             </if>
             <if test="isDifference != null and isDifference == '1'">
                 AND tsi.new_inventory = me.inventory