com.jskj.assets.server.servcie.Yimiaodengji.YimiaodengjiService.java Source code

Java tutorial

Introduction

Here is the source code for com.jskj.assets.server.servcie.Yimiaodengji.YimiaodengjiService.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jskj.assets.server.servcie.Yimiaodengji;

import com.jskj.assets.server.entity.Backsale_detail_tb;
import com.jskj.assets.server.entity.Backsale_detail_tbExample;
import com.jskj.assets.server.entity.Barcodepool;
import com.jskj.assets.server.entity.BarcodepoolExample;
import com.jskj.assets.server.entity.Shenqingdantb;
import com.jskj.assets.server.entity.Supplier;
import com.jskj.assets.server.entity.Usertb;
import com.jskj.assets.server.entity.YiMiaotb;
import com.jskj.assets.server.entity.Yimiaodengjitb;
import com.jskj.assets.server.entity.YimiaodengjitbExample;
import com.jskj.assets.server.entity.Yimiaoshenqingdantb;
import com.jskj.assets.server.entity.YimiaoshenqingdantbExample;
import com.jskj.assets.server.entity.child.DengjiyimiaoEntity;
import com.jskj.assets.server.entity.child.DengjiyimiaoFindEntity;
import com.jskj.assets.server.entity.child.DepotALL;
import com.jskj.assets.server.entity.child.UserSessionEntity;
import com.jskj.assets.server.entity.child.YimiaoAll;
import com.jskj.assets.server.entity.child.YimiaodengjitbFindEntity;
import com.jskj.assets.server.entity.child.YimiaoshenqingliebiaoEntity;
import com.jskj.assets.server.entity.common.AssetUserDetails;
import com.jskj.assets.server.entity.common.CommFindEntity;
import com.jskj.assets.server.mapper.Backsale_detail_tbMapper;
import com.jskj.assets.server.mapper.BarcodepoolMapper;
import com.jskj.assets.server.mapper.ShenqingdantbMapper;
import com.jskj.assets.server.mapper.SupplierMapper;
import com.jskj.assets.server.mapper.YiMiaotbMapper;
import com.jskj.assets.server.mapper.YimiaodengjitbMapper;
import com.jskj.assets.server.mapper.YimiaoshenqingdantbMapper;
import com.jskj.assets.server.mapper.Yimiaoyanshou_detail_tbMapper;
import com.jskj.assets.server.servcie.BarCode.BarCodeIF;
import com.jskj.assets.server.servcie.CommServiceIF;
import com.jskj.assets.server.servcie.supplier.SupplierServiceIF;
import com.jskj.assets.server.utils.Arith;
import com.jskj.assets.server.utils.Pager;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import net.sf.cglib.beans.BeanCopier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 *
 * @author 305027939
 */
@Service
public class YimiaodengjiService implements YimiaodengjiServiceIF {

    public static BeanCopier copier = BeanCopier.create(YiMiaotb.class, YimiaoAll.class, false);

    private static final Log log = LogFactory.getLog(YimiaodengjiService.class);
    @Resource
    private YimiaodengjitbMapper mapper;
    @Resource
    private Yimiaoyanshou_detail_tbMapper yanshoumapper;
    @Resource
    private YiMiaotbMapper yimiaoMapper;
    @Resource
    private SupplierMapper gongyingdanweiMapper;
    @Resource
    private YimiaoshenqingdantbMapper yimiaoshenqingdanMapper;
    @Resource
    private Backsale_detail_tbMapper Backsale_detail_tbMapper;
    @Resource
    private ShenqingdantbMapper shenqingdanMapper;
    @Resource
    private BarcodepoolMapper BarcodepoolMapper;
    @Autowired
    @Qualifier("cangkuService")
    private CommServiceIF<DepotALL, Integer> cangkuService;
    @Resource
    private SupplierServiceIF supplierService;

    @Resource
    private BarCodeIF barCodeService;

    @Override
    public Yimiaodengjitb findYimiaodengji(Integer id) {
        YimiaodengjitbExample yimiaodengjiExample = new YimiaodengjitbExample();
        yimiaodengjiExample.createCriteria().andYmdjIdEqualTo(id);
        List<Yimiaodengjitb> yimiaodengjis = mapper.selectByExample(yimiaodengjiExample);
        for (Yimiaodengjitb u : yimiaodengjis) {
            log.debug("found yimiaodengji:" + u.getYmdjId());
        }
        return yimiaodengjis.get(0);
    }

    @Override
    public YimiaodengjitbFindEntity findAllYimiaodengjis(Pager page) {
        YimiaodengjitbExample exam = new YimiaodengjitbExample();
        YimiaodengjitbFindEntity findEntity = new YimiaodengjitbFindEntity();

        //count?limtStart/limitEnd
        int count = mapper.countByExample(exam);
        page.setCount(count);
        exam.setLimitStart(page.getStartDataIndex());
        exam.setLimitEnd(page.getPageSize());

        //?
        exam.setOrderByClause("yimiaodengji_id DESC");

        //?
        List<Yimiaodengjitb> yimiaodengjis = mapper.selectByExample(exam);
        findEntity.setCount(count);
        findEntity.setYimiaodengjis(yimiaodengjis);
        for (Yimiaodengjitb u : yimiaodengjis) {
            log.debug("found yimiaodengji:" + u.getYmdjId());
        }
        return findEntity;
    }

    @Override
    public int saveYimiaodengji(Yimiaodengjitb yimiaodengji) {
        log.debug("insert yimiaodengji:" + yimiaodengji.getYmdjId());

        //??
        YimiaoshenqingdantbExample liebiaoexam = new YimiaoshenqingdantbExample();
        liebiaoexam.createCriteria().andXiangdanIdEqualTo(yimiaodengji.getXiangdanId());
        //??id??
        List<Yimiaoshenqingdantb> yimiaolist = yimiaoshenqingdanMapper.selectByExample(liebiaoexam);
        //??
        for (Yimiaoshenqingdantb ym : yimiaolist) {
            liebiaoexam = new YimiaoshenqingdantbExample();
            liebiaoexam.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
            int stuts = ym.getStatus();
            if (yimiaodengji.getQuantity().equals(ym.getQuantity())) {
                stuts = 1;
            } else if (ym.getXiangdanId() == ym.getXiangdanId() && ym.getStatus() == 0) {

                YiMiaotb yimiao = new YiMiaotb();
                yimiao = yimiaoMapper.selectByPrimaryKey(yimiaodengji.getYimiaoId());
                //??ID?
                YimiaodengjitbExample sqdexam = new YimiaodengjitbExample();
                sqdexam.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
                List<Yimiaodengjitb> sqdlist = mapper.selectByExample(sqdexam);
                Double chashu = 0d;
                Double shulian = chashu;

                //??            
                for (int i = 0; i < sqdlist.size(); i++) {
                    //??
                    chashu = Arith.decimal(chashu + sqdlist.get(i).getQuantity(), 5);
                }
                Double strQuantity = Arith.round(Arith.mul(Arith.decimal(yimiaodengji.getQuantity() + chashu, 5),
                        Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0)), 0);
                strQuantity = Arith.div(strQuantity, Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0), 5);
                Double shul = strQuantity;
                //                    shulian = Arith.decimal(chashu + shulian, 5);
                //                    Double shul = Arith.decimal(yimiaodengji.getQuantity() + shulian, 5);
                if (!shul.equals(ym.getQuantity())) {
                    stuts = 0;
                    ym.setStatus(stuts);
                    YimiaoshenqingdantbExample ymsqd = new YimiaoshenqingdantbExample();
                    ymsqd.createCriteria().andXiangdanIdEqualTo(ym.getXiangdanId());
                    yimiaoshenqingdanMapper.updateByExample(ym, ymsqd);
                } else {
                    stuts = 1;
                }

            }
            ym.setStatus(stuts);
            yimiaoshenqingdanMapper.updateByExample(ym, liebiaoexam);

            /*barcode pool*/
            double num = yimiaodengji.getQuantity();
            Barcodepool pool = new Barcodepool();
            pool.setBarcodegroup(yimiaodengji.getBarcode());
            pool.setLabelId(yimiaodengji.getYimiaoId());
            pool.setQuantity(num);
            pool.setShenqingdanId(ym.getShenqingdanId());
            pool.setXiangdanId(ym.getXiangdanId());
            pool.setStatus(0);
            barCodeService.saveBarCode(pool, true);
        }
        yimiaodengji.setStatus(0);
        return mapper.insertSelective(yimiaodengji);
    }

    @Override
    public int saveYimiaotuihuodengji(Yimiaodengjitb yimiaodengji) {
        log.debug("insert yimiaodengji:" + yimiaodengji.getYmdjId());

        //??
        Backsale_detail_tbExample liebiaoexam = new Backsale_detail_tbExample();
        liebiaoexam.createCriteria().andBackDetailIdEqualTo(yimiaodengji.getXiangdanId());
        //??id??
        List<Backsale_detail_tb> yimiaolist = Backsale_detail_tbMapper.selectByExample(liebiaoexam);
        //??
        for (Backsale_detail_tb ym : yimiaolist) {
            liebiaoexam = new Backsale_detail_tbExample();
            liebiaoexam.createCriteria().andBackDetailIdEqualTo(ym.getBackDetailId());
            int stuts = ym.getStatus();
            //??? Backsale_detail_tb??3
            if (yimiaodengji.getQuantity().equals(ym.getQuantity())) {
                stuts = 4;//??4()
            } else if (ym.getBackDetailId().equals(yimiaodengji.getXiangdanId()) && ym.getStatus() == 3) {
                YiMiaotb yimiao = new YiMiaotb();
                yimiao = yimiaoMapper.selectByPrimaryKey(yimiaodengji.getYimiaoId());
                //??ID?
                YimiaodengjitbExample sqdexam = new YimiaodengjitbExample();
                sqdexam.createCriteria().andXiangdanIdEqualTo(ym.getBackDetailId()).andStatusEqualTo(4);//?4
                List<Yimiaodengjitb> sqdlist = mapper.selectByExample(sqdexam);
                Double chashu = 0d;
                Double shulian = chashu;

                //??            
                for (int i = 0; i < sqdlist.size(); i++) {
                    //??
                    chashu = Arith.decimal(chashu + sqdlist.get(i).getQuantity(), 5);
                }
                shulian = Arith.decimal(chashu + shulian, 5);
                Double strQuantity = Arith.round(Arith.mul(Arith.decimal(yimiaodengji.getQuantity() + shulian, 5),
                        Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0)), 0);
                strQuantity = Arith.div(strQuantity, Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0), 5);
                Double shul = strQuantity;
                //                    Double shul = Arith.decimal(yimiaodengji.getQuantity() + shulian, 5);
                if (!shul.equals(ym.getQuantity())) {
                    stuts = 3;
                    ym.setStatus(stuts);
                    Backsale_detail_tbExample ymsqd = new Backsale_detail_tbExample();
                    ymsqd.createCriteria().andBackDetailIdEqualTo(ym.getBackDetailId());
                    Backsale_detail_tbMapper.updateByExample(ym, ymsqd);
                } else {
                    stuts = 4;
                }

            }
            ym.setYouxiaoqi(yimiaodengji.getYouxiaoqi());
            ym.setPihao(yimiaodengji.getPihao());
            ym.setStatus(stuts);
            Backsale_detail_tbMapper.updateByExample(ym, liebiaoexam);

            /*barcode pool*/
            double num = yimiaodengji.getQuantity();
            Barcodepool pool = new Barcodepool();
            pool.setBarcodegroup(yimiaodengji.getBarcode());
            pool.setLabelId(yimiaodengji.getYimiaoId());
            pool.setQuantity(num);
            pool.setShenqingdanId(ym.getBacksaleId());
            pool.setXiangdanId(ym.getBackDetailId());
            pool.setStatus(6);//?
            barCodeService.saveBarCode(pool, true);
        }
        yimiaodengji.setStatus(4);//
        return mapper.insertSelective(yimiaodengji);
    }

    @Override
    public int deleteYimiaodengji(Integer yimiaodengjiId) {
        log.debug("delete yimiaodengji:" + yimiaodengjiId);
        return mapper.deleteByPrimaryKey(yimiaodengjiId);
    }

    @Override
    public int updateYimiaodengji(Yimiaodengjitb yimiaodengji) {
        log.debug("update yimiaodengji:" + yimiaodengji.getYmdjId());
        return mapper.updateByPrimaryKeySelective(yimiaodengji);
    }

    @Override
    public DengjiyimiaoFindEntity findDengjiyimiaos(Pager pager) {
        YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample();
        DengjiyimiaoFindEntity findEntity = new DengjiyimiaoFindEntity();
        DengjiyimiaoEntity dengjiyimiaoEntity = new DengjiyimiaoEntity();
        //count?limtStart/limitEnd
        int count = yimiaoshenqingdanMapper.countByExample(yimiaoshenqingdanexample);
        log.debug("found shenbaoyimiao total:" + count);
        pager.setCount(count);
        yimiaoshenqingdanexample.setLimitStart(pager.getStartDataIndex());
        yimiaoshenqingdanexample.setLimitEnd(pager.getPageSize());
        //?
        yimiaoshenqingdanexample.setOrderByClause("yimiao_id DESC");

        findEntity.setCount(count);

        //?
        List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = yimiaoshenqingdanMapper
                .selectByExample(yimiaoshenqingdanexample);
        List<DengjiyimiaoEntity> resultAll = new ArrayList<DengjiyimiaoEntity>();
        for (Yimiaoshenqingdantb yimiaoshenqingdan : yimiaoshenqingdanlist) {
            YiMiaotb yimiao = yimiaoMapper.selectByPrimaryKey(yimiaoshenqingdan.getYimiaoId());
            YimiaoAll yimiaoAll = new YimiaoAll();
            log.debug("found Depot and bean copy:" + yimiao.getYimiaoName());
            copier.copy(yimiao, yimiaoAll, null);
            dengjiyimiaoEntity.setYimiaoAll(yimiaoAll);
            Shenqingdantb shenqingdantb = shenqingdanMapper
                    .selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId());
            YimiaodengjitbExample yimiaodengjiExample = new YimiaodengjitbExample();
            yimiaodengjiExample.createCriteria().andXiangdanIdEqualTo(yimiaoshenqingdan.getXiangdanId());
            List<Yimiaodengjitb> yimiaodengjiList = mapper.selectByExample(yimiaodengjiExample);
            for (Yimiaodengjitb yimiaodengjitb : yimiaodengjiList) {

                dengjiyimiaoEntity.setYimiaodengji(yimiaodengjitb);
            }
            dengjiyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan);

            dengjiyimiaoEntity.setShenqingdan(shenqingdantb);
            resultAll.add(dengjiyimiaoEntity);
        }

        findEntity.setResult(resultAll);
        return findEntity;
    }

    @Override
    public DengjiyimiaoFindEntity findDengjiyimiaos(Pager pager, String conditionSql) {
        YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample();
        DengjiyimiaoFindEntity findEntity = new DengjiyimiaoFindEntity();

        if (conditionSql != null && !conditionSql.trim().equals("")) {
            yimiaoshenqingdanexample.createCriteria().addConditionSql(conditionSql);
        }
        //count?limtStart/limitEnd
        int count = yimiaoshenqingdanMapper.countByExample(yimiaoshenqingdanexample);
        log.debug("found shenbaoyimiao total:" + count);
        pager.setCount(count);
        yimiaoshenqingdanexample.setLimitStart(pager.getStartDataIndex());
        yimiaoshenqingdanexample.setLimitEnd(pager.getPageSize());
        //?
        yimiaoshenqingdanexample.setOrderByClause("shenqingdan_id ASC");

        //?
        List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = yimiaoshenqingdanMapper
                .selectByExample(yimiaoshenqingdanexample);
        List<DengjiyimiaoEntity> resultAll = new ArrayList<DengjiyimiaoEntity>();
        //        for (Yimiaoshenqingdantb yimiaoshenqingdan : yimiaoshenqingdanlist) {
        for (int i = 0; i < yimiaoshenqingdanlist.size(); i++) {
            if (i > 0) {
                if (!yimiaoshenqingdanlist.get(i).getShenqingdanId()
                        .equals(yimiaoshenqingdanlist.get(i - 1).getShenqingdanId())) {
                    break;
                }
            }
            Yimiaoshenqingdantb yimiaoshenqingdan = yimiaoshenqingdanlist.get(i);
            DengjiyimiaoEntity dengjiyimiaoEntity = new DengjiyimiaoEntity();
            YiMiaotb yimiao = new YiMiaotb();
            yimiao = yimiaoMapper.selectByPrimaryKey(yimiaoshenqingdan.getYimiaoId());
            YimiaoAll yimiaoAll = new YimiaoAll();
            log.debug("found Depot and bean copy:" + yimiao.getYimiaoName());
            copier.copy(yimiao, yimiaoAll, null);
            dengjiyimiaoEntity.setYimiaoAll(yimiaoAll);

            Shenqingdantb shenqingdantb = new Shenqingdantb();
            shenqingdantb = shenqingdanMapper.selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId());
            dengjiyimiaoEntity.setShenqingdan(shenqingdantb);

            System.out.println(dengjiyimiaoEntity.getShenqingdan().getShenqingdanId());
            System.out.println(dengjiyimiaoEntity.getShenqingdan().getSupplierId());
            YimiaodengjitbExample yimiaodengjiExample = new YimiaodengjitbExample();
            yimiaodengjiExample.createCriteria().andXiangdanIdEqualTo(yimiaoshenqingdan.getXiangdanId());
            List<Yimiaodengjitb> yimiaodengjiList = mapper.selectByExample(yimiaodengjiExample);
            Supplier gongyingdanwei = new Supplier();
            gongyingdanwei = gongyingdanweiMapper.selectByPrimaryKey(shenqingdantb.getSupplierId());
            dengjiyimiaoEntity.setGongyingdanwei(gongyingdanwei);
            for (Yimiaodengjitb yimiaodengjitb : yimiaodengjiList) {
                BarcodepoolExample barcodeExample = new BarcodepoolExample();
                barcodeExample.createCriteria().andBarcodegroupEqualTo(yimiaodengjitb.getBarcode());
                List<Barcodepool> barcode = BarcodepoolMapper.selectByExample(barcodeExample);
                if (barcode.get(0).getStatus() == 0) {
                    dengjiyimiaoEntity.setYimiaodengji(yimiaodengjitb);
                    System.out.println("?" + yimiaodengjitb.getPihao());
                }
            }
            dengjiyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan);
            dengjiyimiaoEntity.setShenqingdan(shenqingdantb);
            resultAll.add(dengjiyimiaoEntity);
        }

        findEntity.setResult(resultAll);
        findEntity.setCount(resultAll.size());
        return findEntity;
    }

    @Override
    public DengjiyimiaoFindEntity findDengjiyimiaosyanshou(Pager pager, String conditionSql) {
        YimiaodengjitbExample YimiaodengjiExample = new YimiaodengjitbExample();
        DengjiyimiaoFindEntity findEntity = new DengjiyimiaoFindEntity();

        if (conditionSql != null && !conditionSql.trim().equals("")) {
            YimiaodengjiExample.createCriteria().addConditionSql(conditionSql);
        }
        //count?limtStart/limitEnd
        int count = mapper.countByExample(YimiaodengjiExample);
        log.debug("found shenbaoyimiao total:" + count);
        pager.setCount(count);
        //        YimiaodengjiExample.setLimitStart(pager.getStartDataIndex());
        //        YimiaodengjiExample.setLimitEnd(pager.getPageSize());
        //?
        //        YimiaodengjiExample.setGroupby("xiangdan_id ASC");

        //? 
        List<Yimiaodengjitb> yimiaodengjilist = mapper.selectByExample(YimiaodengjiExample);
        List<DengjiyimiaoEntity> resultAll = new ArrayList<DengjiyimiaoEntity>();
        String shenqingdanId = "";
        for (Yimiaodengjitb ymdj : yimiaodengjilist) {

            YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample();
            yimiaoshenqingdanexample.createCriteria().andXiangdanIdEqualTo(ymdj.getXiangdanId());
            List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = yimiaoshenqingdanMapper
                    .selectByExample(yimiaoshenqingdanexample);

            //        for (int i = 0; i < yimiaoshenqingdanlist.size(); i++) {
            //            if (i > 0) {
            if ((!yimiaoshenqingdanlist.get(0).getShenqingdanId().equals(shenqingdanId))
                    && (!shenqingdanId.equals(""))) {
                break;
            }
            shenqingdanId = yimiaoshenqingdanlist.get(0).getShenqingdanId();
            //            }
            Yimiaoshenqingdantb yimiaoshenqingdan = yimiaoshenqingdanlist.get(0);
            DengjiyimiaoEntity dengjiyimiaoEntity = new DengjiyimiaoEntity();
            YiMiaotb yimiao = new YiMiaotb();
            yimiao = yimiaoMapper.selectByPrimaryKey(yimiaoshenqingdan.getYimiaoId());
            YimiaoAll yimiaoAll = new YimiaoAll();
            log.debug("found Depot and bean copy:" + yimiao.getYimiaoName());
            copier.copy(yimiao, yimiaoAll, null);
            dengjiyimiaoEntity.setYimiaoAll(yimiaoAll);

            Shenqingdantb shenqingdantb = new Shenqingdantb();
            shenqingdantb = shenqingdanMapper.selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId());
            dengjiyimiaoEntity.setShenqingdan(shenqingdantb);

            System.out.println(dengjiyimiaoEntity.getShenqingdan().getShenqingdanId());
            System.out.println(dengjiyimiaoEntity.getShenqingdan().getSupplierId());
            //            YimiaodengjitbExample yimiaodengjiExample = new YimiaodengjitbExample();
            //            yimiaodengjiExample.createCriteria().andXiangdanIdEqualTo(yimiaoshenqingdan.getXiangdanId()).andStatusEqualTo(0);
            //            List<Yimiaodengjitb> yimiaodengjiList = mapper.selectByExample(yimiaodengjiExample);
            Supplier gongyingdanwei = new Supplier();
            gongyingdanwei = gongyingdanweiMapper.selectByPrimaryKey(shenqingdantb.getSupplierId());
            dengjiyimiaoEntity.setGongyingdanwei(gongyingdanwei);
            //            for (Yimiaodengjitb yimiaodengjitb : yimiaodengjiList) {
            BarcodepoolExample barcodeExample = new BarcodepoolExample();
            barcodeExample.createCriteria().andBarcodegroupEqualTo(ymdj.getBarcode());
            List<Barcodepool> barcode = BarcodepoolMapper.selectByExample(barcodeExample);
            if (barcode.get(0).getStatus() == 0) {
                dengjiyimiaoEntity.setYimiaodengji(ymdj);
                System.out.println("?" + ymdj.getPihao());
            }
            //            }
            dengjiyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan);
            dengjiyimiaoEntity.setShenqingdan(shenqingdantb);
            resultAll.add(dengjiyimiaoEntity);
            //        }
        }

        findEntity.setResult(resultAll);
        findEntity.setCount(resultAll.size());
        return findEntity;
    }

    @Override
    public CommFindEntity<YimiaoshenqingliebiaoEntity> findWeidengjiyimiao(String type, String conditionSql) {
        CommFindEntity<YimiaoshenqingliebiaoEntity> findEntity = new CommFindEntity<>();
        List<YimiaoshenqingliebiaoEntity> liebiao = new ArrayList<>();
        YimiaoshenqingdantbExample lbexam = new YimiaoshenqingdantbExample();
        //        lbexam.createCriteria().andCgsqIdLike("GDZC").andStatusEqualTo(0).andIsCompletedEqualTo(1);
        lbexam.createCriteria().addConditionSql(conditionSql);
        List<Yimiaoshenqingdantb> list = yimiaoshenqingdanMapper.selectByExample(lbexam);
        Date d = new Date(); //?????
        String id = ""; //???id
        for (Yimiaoshenqingdantb lb : list) {
            log.debug("findSheniqingYimiao:" + lb.getShenqingdanId());

            //???????????????
            //conditionSql?status?
            String[] string = conditionSql.split("status = ");
            int status;
            if (conditionSql.contains("status = ")) {
                status = Integer.parseInt(string[1].substring(0, 1));
            } else {
                status = -1;
            }
            lbexam = new YimiaoshenqingdantbExample();
            lbexam.createCriteria().andShenqingdanIdEqualTo(lb.getShenqingdanId()).andStatusNotEqualTo(status)
                    .andStatusNotEqualTo(-1);
            int count = yimiaoshenqingdanMapper.countByExample(lbexam);
            //??????????
            if (count == 0) {
                continue;
            }
            //???dliebiaod
            Shenqingdantb sqd = shenqingdanMapper.selectByPrimaryKey(lb.getShenqingdanId());
            if (sqd.getShenqingdanDate().before(d)) {
                d = sqd.getShenqingdanDate();
                id = sqd.getShenqingdanId();
                liebiao.clear();
            }
            //?????
            if (sqd.getShenqingdanId().equals(id)) {

                YimiaoshenqingliebiaoEntity lball = new YimiaoshenqingliebiaoEntity();
                lball.setYimiaoshenqingdan(lb);
                YiMiaotb yimiao = new YiMiaotb();
                yimiao = yimiaoMapper.selectByPrimaryKey(lb.getYimiaoId());
                lball.setYimiao(yimiao);
                liebiao.add(lball);
            }

        }

        log.debug("Result.size():" + liebiao.size());
        findEntity.setCount(liebiao.size());
        findEntity.setResult(liebiao);
        return findEntity;
    }

    @Override
    public CommFindEntity<YimiaoshenqingliebiaoEntity> findchaifendengjiyimiao(String type, String conditionSql) {
        CommFindEntity<YimiaoshenqingliebiaoEntity> findEntity = new CommFindEntity<>();
        List<YimiaoshenqingliebiaoEntity> liebiao = new ArrayList<>();
        YimiaodengjitbExample lbexam = new YimiaodengjitbExample();
        //        lbexam.createCriteria().andCgsqIdLike("GDZC").andStatusEqualTo(0).andIsCompletedEqualTo(1);
        lbexam.createCriteria().addConditionSql(conditionSql);
        List<Yimiaodengjitb> list = mapper.selectByExample(lbexam);
        String id = ""; //???id
        for (Yimiaodengjitb lb : list) {
            log.debug("findchaifendengjiyimiao:" + lb.getYmdjId());

            //???????????????
            //conditionSql?status?
            //            String[] string = conditionSql.split("status = ");
            //            int status;
            //            if (conditionSql.contains("status = ")) {
            //                status = Integer.parseInt(string[1].substring(0, 1));
            //            } else {
            //                status = -1;
            //            }
            YimiaoshenqingdantbExample ymsqexam = new YimiaoshenqingdantbExample();
            ymsqexam.createCriteria().andXiangdanIdEqualTo(lb.getXiangdanId()).andStatusEqualTo(0);
            int count = yimiaoshenqingdanMapper.countByExample(ymsqexam);
            //??????????
            if (count == 0) {
                continue;
            }
            List<Yimiaoshenqingdantb> ymsqlist = yimiaoshenqingdanMapper.selectByExample(ymsqexam);
            for (Yimiaoshenqingdantb ymsq : ymsqlist) {
                YimiaoshenqingliebiaoEntity ymsqliebiaoEntity = new YimiaoshenqingliebiaoEntity();
                YiMiaotb yimiao = new YiMiaotb();
                yimiao = yimiaoMapper.selectByPrimaryKey(lb.getYimiaoId());
                ymsqliebiaoEntity.setYimiaoshenqingdan(ymsq);
                ymsqliebiaoEntity.setYimiao(yimiao);
                liebiao.add(ymsqliebiaoEntity);
            }
            //?????
            //            if (sqd.getShenqingdanId().equals(id)) {
            //
            //                YimiaoshenqingliebiaoEntity lball = new YimiaoshenqingliebiaoEntity();
            //                lball.setYimiaoshenqingdan(lb);
            //                lball.setYimiaodengjitb(lb);
            //                YiMiaotb yimiao = new YiMiaotb();
            //                yimiao = yimiaoMapper.selectByPrimaryKey(lb.getYimiaoId());
            //                lball.setYimiao(yimiao);
            //                liebiao.add(lball);
            //            }

        }

        log.debug("Result.size():" + liebiao.size());
        findEntity.setCount(liebiao.size());
        findEntity.setResult(liebiao);
        return findEntity;
    }

    @Override
    public int cancelYimiaoDengji(List<YimiaoshenqingliebiaoEntity> list) {
        log.debug("cancelDengji:");
        //???
        Usertb usertb;
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal != null) {
            if (principal instanceof AssetUserDetails) {
                AssetUserDetails user = (AssetUserDetails) principal;
                log.info("FukuanshenpiService.findAll,Got UserDetails object." + user.getUsername());
                UserSessionEntity session = user.getUserSessionEntity();
                usertb = session.getUsertb();
                if (usertb != null) {
                    log.info("FukuanshenpiService.findAll," + usertb.getUserName() + " fount.");
                } else {
                    log.error("FukuanshenpiService.findAll,user is not exist.");
                }
            } else {
                log.error("FukuanshenpiService.findAll,failed. principal is not a  UserDetails object!");
                return -1;
            }
        } else {
            log.error("FukuanshenpiService.findAll, failed. principal is null!");
            return -1;
        }

        int result = 0;
        for (YimiaoshenqingliebiaoEntity lball : list) {
            YimiaoshenqingdantbExample lbexam = new YimiaoshenqingdantbExample();
            lbexam.createCriteria().andXiangdanIdEqualTo(lball.getYimiaoshenqingdan().getXiangdanId());
            List<Yimiaoshenqingdantb> yimiaolblist = yimiaoshenqingdanMapper.selectByExample(lbexam);
            for (Yimiaoshenqingdantb yimiaolb : yimiaolblist) {
                yimiaolb.setStatus(-1);
                yimiaolb.setReason(lball.getYimiaoshenqingdan().getReason());
                if (usertb != null) {
                    yimiaolb.setOperator(usertb.getUserName());
                }
                result += yimiaoshenqingdanMapper.updateByExampleSelective(yimiaolb, lbexam);
            }
            if (lball.getYimiaodengjitb() != null && !lball.getYimiaodengjitb().getBarcode().equals("")) {
                YimiaodengjitbExample djexam = new YimiaodengjitbExample();
                djexam.createCriteria().andBarcodeEqualTo(lball.getYimiaodengjitb().getBarcode());
                List<Yimiaodengjitb> ymdjlist = mapper.selectByExample(djexam);
                for (Yimiaodengjitb yimiaodj : ymdjlist) {
                    yimiaodj.setStatus(-1);
                    result += mapper.updateByExampleSelective(yimiaodj, djexam);
                }
            }
        }
        return result;
    }

}