CheckService.java 2.45 KB
package cn.csbr.app.service;

import cn.csbr.app.exception.AuthException;
import cn.csbr.app.gui.GUIContext;
import cn.csbr.app.model.InboundItem;
import cn.csbr.springboot.dao.mapper.MfcubestockcoutMapper;
import cn.csbr.springboot.dao.mapper.MfcubestockdetailMapper;
import cn.csbr.springboot.dao.model.Mfcubestockcout;
import cn.csbr.springboot.dao.model.Mfcubestockdetail;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


@Service
public class CheckService {
    private static final Logger log = LoggerFactory.getLogger(CheckService.class);
    @Autowired
    private MfcubestockdetailMapper mfcubestockdetailMapper;
    @Autowired
    private BaseService baseService;
    @Autowired
    private MfcubestockcoutMapper mfcubestockcoutMapper;
    @Autowired
    private GUIContext guiContext;

    /**
     * 盘点确认报损后删除库存数据
     * @TODO
     */
    @Transactional
    public void checkDeleteCabinetInfo(InboundItem inboundItem) {
        log.info("checkDeleteCabinetInfo报损删除方法入参为:"+ JSON.toJSONString(inboundItem));
        if (inboundItem == null) {
            return;
        }
        Mfcubestockdetail cubedetail = mfcubestockdetailMapper.selectByPrimaryKey(inboundItem.getGuid());
        if (cubedetail == null) {
            throw new AuthException("未查询到该数据,请刷新重试");
        }
        //将查询到的货柜名和id放入InboundItem对象
        buildInboundItem(inboundItem,cubedetail);
        int deleteCount = mfcubestockdetailMapper.delete(cubedetail);
        if (deleteCount == 0) {
            throw new AuthException("删除失败,请刷新重试");
        }
        int logCount = baseService.writeLog(inboundItem, cubedetail, "4");
        if (logCount == 0) {
            throw new AuthException("删除失败,请刷新重试");
        }
//        int sumCount = baseService.sumNumber(inboundItem, cubedetail);
//        if (sumCount == 0) {
//            throw new AuthException("删除失败,请刷新重试");
//        }
    }
    public void  buildInboundItem(InboundItem inboundItem,Mfcubestockdetail cubedetail) {

        inboundItem.setAllocationGuid(cubedetail.getCubeGuid());
           inboundItem.setAllocation(cubedetail.getCubeName());
    }

    }