物料管理测试修改2:按照日期降序查询、编写删除物料接口
This commit is contained in:
		@@ -12,6 +12,6 @@ import java.util.List;
 | 
			
		||||
public interface MaterialsOutgoingLogMapper extends Mapper<MaterialsOutgoingLog> {
 | 
			
		||||
    List<MaterialsOutgoingLogVo> findListByOneMaterial(MaterialsOutgoingLogParams params);
 | 
			
		||||
 | 
			
		||||
    void deleteByOutgoingIds(List<Integer> ids);
 | 
			
		||||
    void deleteByOutgoingIds(HashMap outgoingParam);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -78,7 +78,7 @@
 | 
			
		||||
            <if test="companyId != null">
 | 
			
		||||
                AND com.company_id = #{companyId}
 | 
			
		||||
            </if>
 | 
			
		||||
        </where> order by materials.create_time DESC
 | 
			
		||||
        </where> ORDER BY materials.create_time DESC
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="findDetailById" parameterType="com.deer.wms.produce.manage.model.MaterialsInfoParams"  resultMap="MatInfoDTOResultMap">
 | 
			
		||||
@@ -133,7 +133,7 @@
 | 
			
		||||
                OR  materialsInfo.specification LIKE CONCAT('%', #{keywords}, '%')
 | 
			
		||||
                OR  materialsInfo.unit_id LIKE CONCAT('%', #{keywords}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
        </where> ORDER BY materialsInfo.create_time  
 | 
			
		||||
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -50,11 +50,12 @@
 | 
			
		||||
        </where> ORDER BY outgoing.create_time DESC
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteByOutgoingIds"  parameterType = "java.util.List">
 | 
			
		||||
        DELETE FROM mt_alone_materials_outgoing_log WHERE id IN
 | 
			
		||||
        <foreach collection="list" item="ids" open="(" separator="," close=")">
 | 
			
		||||
          #{ids}
 | 
			
		||||
        </foreach>
 | 
			
		||||
    <delete id="deleteByOutgoingIds"  parameterType = "java.util.HashMap">
 | 
			
		||||
        DELETE FROM mt_alone_materials_outgoing_log
 | 
			
		||||
            where 1>2 OR company_id=#{companyId} AND id IN
 | 
			
		||||
                <foreach collection="ids" item="id" open="(" separator="," close=")">
 | 
			
		||||
                  #{id}
 | 
			
		||||
                </foreach>
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package com.deer.wms.produce.manage.service;
 | 
			
		||||
 | 
			
		||||
import com.deer.wms.intercept.common.data.CurrentUser;
 | 
			
		||||
import com.deer.wms.produce.manage.model.MaterialsInfo;
 | 
			
		||||
import com.deer.wms.produce.manage.model.MaterialsInfoDto;
 | 
			
		||||
import com.deer.wms.produce.manage.model.MaterialsInfoParams;
 | 
			
		||||
@@ -20,5 +21,5 @@ public interface MaterialsInfoService extends Service<MaterialsInfo, Integer> {
 | 
			
		||||
 | 
			
		||||
    List<MaterialsInfoVO> findMaterialsByKeyWords(MaterialsInfoParams params);
 | 
			
		||||
 | 
			
		||||
    void deleteRelevantById(Integer materialsId);
 | 
			
		||||
    void deleteRelevantById(Integer materialsId, CurrentUser currentUser);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,5 +21,5 @@ public interface MaterialsOutgoingLogService extends Service<MaterialsOutgoingLo
 | 
			
		||||
 | 
			
		||||
    void save(MaterialsOutgoingLog materialsOutgoingLog, CurrentUser currentUser);
 | 
			
		||||
 | 
			
		||||
    void deleteByOutgoingIds(List<Integer> ids);
 | 
			
		||||
    void deleteByOutgoingIds(HashMap outgoingParam);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package com.deer.wms.produce.manage.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.deer.wms.intercept.common.data.CurrentUser;
 | 
			
		||||
import com.deer.wms.produce.manage.dao.MaterialsInfoMapper;
 | 
			
		||||
import com.deer.wms.produce.manage.model.*;
 | 
			
		||||
import com.deer.wms.produce.manage.service.MaterialsInfoService;
 | 
			
		||||
@@ -52,7 +53,7 @@ public class MaterialsInfoServiceImpl extends AbstractService<MaterialsInfo, Int
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void deleteRelevantById(Integer materialsId) {
 | 
			
		||||
    public void deleteRelevantById(Integer materialsId, CurrentUser currentUser) {
 | 
			
		||||
        materialsInfoMapper.deleteByPrimaryKey(materialsId);
 | 
			
		||||
        MaterialsStockInfo stock = materialsStockInfoService.findBy("materialsId", materialsId);
 | 
			
		||||
        if(null!=stock)
 | 
			
		||||
@@ -61,16 +62,18 @@ public class MaterialsInfoServiceImpl extends AbstractService<MaterialsInfo, Int
 | 
			
		||||
        params.setMaterialsId(materialsId);
 | 
			
		||||
        params.setCompanyId(1);
 | 
			
		||||
        List<MaterialsOutgoingLogVo> materialsOutgoingLogList = materialsOutgoingLogService.findListByOneMaterial(params);
 | 
			
		||||
        System.out.println("=========="+materialsOutgoingLogList.size());
 | 
			
		||||
 | 
			
		||||
        if((null!=materialsOutgoingLogList) && (materialsOutgoingLogList.size()!=0)){
 | 
			
		||||
            List<Integer> ids = new ArrayList<Integer>();
 | 
			
		||||
            for (MaterialsOutgoingLogVo materialsOutgoingLogVo : materialsOutgoingLogList){
 | 
			
		||||
                ids.add(materialsOutgoingLogVo.getId());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            System.out.println("----------"+ids.size());
 | 
			
		||||
            if((null!=ids) && (ids.size()!=0)) {
 | 
			
		||||
                materialsOutgoingLogService.deleteByOutgoingIds(ids);
 | 
			
		||||
                HashMap outgoingParam = new HashMap();
 | 
			
		||||
                outgoingParam.put("companyId", 1);
 | 
			
		||||
                outgoingParam.put("ids", ids);
 | 
			
		||||
                materialsOutgoingLogService.deleteByOutgoingIds(outgoingParam);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,18 +39,22 @@ public class MaterialsOutgoingLogServiceImpl extends AbstractService<MaterialsOu
 | 
			
		||||
    public void save(MaterialsOutgoingLog materialsOutgoingLog, CurrentUser currentUser) {
 | 
			
		||||
        Date date = new Date();
 | 
			
		||||
 | 
			
		||||
        materialsOutgoingLog.setOperatorId(1);
 | 
			
		||||
        materialsOutgoingLog.setOperatorId(currentUser.getUserId());
 | 
			
		||||
        materialsOutgoingLog.setCreateTime(date);
 | 
			
		||||
        materialsOutgoingLog.setCompanyId(1);
 | 
			
		||||
        materialsOutgoingLog.setVersion("1.1");
 | 
			
		||||
        materialsOutgoingLog.setStatus(ProduceManageConstant.STATUS_AVAILABLE);
 | 
			
		||||
        materialsOutgoingLog.setCompanyId(currentUser.getCompanyId());
 | 
			
		||||
        materialsOutgoingLogMapper.insert(materialsOutgoingLog);
 | 
			
		||||
 | 
			
		||||
        MaterialsStockInfo stock = materialsStockInfoService.findBy("materialsId", materialsOutgoingLog.getMaterialsId());
 | 
			
		||||
        if(stock==null){//如果是新的物料,库存表中没有该物料信息,则新增一条库存记录
 | 
			
		||||
            stock = new MaterialsStockInfo();
 | 
			
		||||
            stock.setOperatorId(1);
 | 
			
		||||
            stock.setOperatorId(currentUser.getUserId());
 | 
			
		||||
            stock.setCreateTime(date);
 | 
			
		||||
            stock.setVersion("1.1");
 | 
			
		||||
            stock.setMaterialsId(materialsOutgoingLog.getMaterialsId());
 | 
			
		||||
            stock.setUnitId(materialsOutgoingLog.getUnitId());
 | 
			
		||||
            stock.setCreateTime(date);
 | 
			
		||||
 | 
			
		||||
            if(materialsOutgoingLog.getType() == ProduceManageConstant.TYPE_OUT) {
 | 
			
		||||
                stock.setQuantity(0-materialsOutgoingLog.getQuantity());//新建物料的出库仓储数量为负数
 | 
			
		||||
            }else if(materialsOutgoingLog.getType() == ProduceManageConstant.TYPE_IN) {
 | 
			
		||||
@@ -58,14 +62,13 @@ public class MaterialsOutgoingLogServiceImpl extends AbstractService<MaterialsOu
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            stock.setPositionName(materialsOutgoingLog.getPositionName());
 | 
			
		||||
            stock.setCompanyId(1);
 | 
			
		||||
            stock.setCompanyId(currentUser.getCompanyId());
 | 
			
		||||
 | 
			
		||||
            materialsStockInfoService.save(stock);
 | 
			
		||||
        }else{//如果库存表中有该物料信息,则更新对应的库存记录
 | 
			
		||||
            stock.setCreateTime(date);//日期取最新更新的日期
 | 
			
		||||
            MaterialsInfoParams params = new MaterialsInfoParams();//查询条件赋值
 | 
			
		||||
            params.setMaterialsId(materialsOutgoingLog.getMaterialsId());
 | 
			
		||||
            params.setCompanyId(1);
 | 
			
		||||
            params.setCompanyId(currentUser.getCompanyId());
 | 
			
		||||
 | 
			
		||||
            //设置库存数量:已有库存数量+入库数量(或已有库存数量-出库数量)
 | 
			
		||||
            Float totalQuantity = materialsStockInfoService.getStockQuantityByMaId(params);
 | 
			
		||||
@@ -79,7 +82,7 @@ public class MaterialsOutgoingLogServiceImpl extends AbstractService<MaterialsOu
 | 
			
		||||
            //设置库存位置:已有库存仓库,出入库记录对应仓库
 | 
			
		||||
            String inAndOutLogPosition = materialsOutgoingLog.getPositionName();
 | 
			
		||||
            String stockPosition = materialsStockInfoService.getStockPositionByMaId(params);
 | 
			
		||||
            if(stockPosition!=null && !stockPosition.trim().equals("")) {
 | 
			
		||||
            if((null!=stockPosition) && (!stockPosition.trim().equals(""))) {
 | 
			
		||||
                stock.setPositionName(stockPosition + "," +inAndOutLogPosition);
 | 
			
		||||
            }else{
 | 
			
		||||
                stock.setPositionName(inAndOutLogPosition);
 | 
			
		||||
@@ -90,7 +93,7 @@ public class MaterialsOutgoingLogServiceImpl extends AbstractService<MaterialsOu
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void deleteByOutgoingIds(List<Integer> ids) {
 | 
			
		||||
        materialsOutgoingLogMapper.deleteByOutgoingIds(ids);
 | 
			
		||||
    public void deleteByOutgoingIds(HashMap outgoingParam) {
 | 
			
		||||
        materialsOutgoingLogMapper.deleteByOutgoingIds(outgoingParam);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,12 +42,6 @@ public class MaterialsInfoController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MaterialsInfoService materialsInfoService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MaterialsStockInfoService materialsStockInfoService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MaterialsOutgoingLogService materialsOutgoingLogService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * hy正在用
 | 
			
		||||
     * 新增物料信息
 | 
			
		||||
@@ -94,7 +88,7 @@ public class MaterialsInfoController {
 | 
			
		||||
        //    return ResultGenerator.genFailResult(CommonCode.SERVICE_ERROR,"未登录错误",null );
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        materialsInfoService.deleteRelevantById(materialsId);
 | 
			
		||||
        materialsInfoService.deleteRelevantById(materialsId, currentUser);
 | 
			
		||||
        return ResultGenerator.genSuccessResult();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,10 +35,6 @@ public class MaterialsOutgoingLogController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MaterialsOutgoingLogService materialsOutgoingLogService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MaterialsStockInfoService materialsStockInfoService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * hy正在用
 | 
			
		||||
     * 出入库操作,添加一条出入库记录,同时更新对应的库存信息
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user