Java tutorial
/* * 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.Yimiaoshenqingdan; import com.jskj.assets.server.entity.Departmenttb; import com.jskj.assets.server.entity.DepartmenttbExample; import com.jskj.assets.server.entity.Backsaletb; import com.jskj.assets.server.entity.Backsale_detail_tb; import com.jskj.assets.server.entity.Backsale_detail_tbExample; import com.jskj.assets.server.entity.BacksaletbExample; import com.jskj.assets.server.entity.Kehudanweitb; import com.jskj.assets.server.entity.KehudanweitbExample; import com.jskj.assets.server.entity.Shenqingdantb; import com.jskj.assets.server.entity.Supplier; import com.jskj.assets.server.entity.SupplierExample; import com.jskj.assets.server.entity.Usertb; import com.jskj.assets.server.entity.UsertbExample; import com.jskj.assets.server.entity.YiMiaotb; import com.jskj.assets.server.entity.YiMiaotbExample; import com.jskj.assets.server.entity.Yimiaodengjitb; import com.jskj.assets.server.entity.YimiaodengjitbExample; import com.jskj.assets.server.entity.Yimiaoshenpiliucheng; import com.jskj.assets.server.entity.Yimiaoshenqingdantb; import com.jskj.assets.server.entity.YimiaoshenqingdantbExample; import com.jskj.assets.server.entity.child.DepotALL; import com.jskj.assets.server.entity.child.JingbanrenEntity; import com.jskj.assets.server.entity.child.JingbanrenFindEntity; import com.jskj.assets.server.entity.child.ShenbaoyimiaoEntity; import com.jskj.assets.server.entity.child.ShenbaoyimiaoFindEntity; import com.jskj.assets.server.entity.child.YimiaoAll; import com.jskj.assets.server.entity.child.YimiaoshenqingdantbFindEntity; import com.jskj.assets.server.entity.child.YimiaotuihuoEntity; import com.jskj.assets.server.entity.child.YimiaotuihuoshenqingFindEntity; import com.jskj.assets.server.mapper.Backsale_detail_tbMapper; import com.jskj.assets.server.mapper.BacksaletbMapper; import com.jskj.assets.server.mapper.DanjuleixingtbMapper; import com.jskj.assets.server.mapper.DepartmenttbMapper; import com.jskj.assets.server.mapper.KehudanweitbMapper; import com.jskj.assets.server.mapper.ShenqingdantbMapper; import com.jskj.assets.server.mapper.SupplierMapper; import com.jskj.assets.server.mapper.UsertbMapper; import com.jskj.assets.server.mapper.YiMiaotbMapper; import com.jskj.assets.server.mapper.YimiaodengjitbMapper; import com.jskj.assets.server.mapper.YimiaoshenpiliuchengMapper; import com.jskj.assets.server.mapper.YimiaoshenqingdantbMapper; import com.jskj.assets.server.process.ProcessHandeler; 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.Arrays; import java.util.Iterator; 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.stereotype.Service; /** * * @author 305027939 */ @Service public class YimiaoshenqingdanService implements YimiaoshenqingdanServiceIF { public static BeanCopier copier = BeanCopier.create(YiMiaotb.class, YimiaoAll.class, false); private static final Log log = LogFactory.getLog(YimiaoshenqingdanService.class); @Resource private BacksaletbMapper backsalemapper; @Resource private YimiaodengjitbMapper YimiaodengjitbMapper; @Resource private Backsale_detail_tbMapper backsaledetailmapper; @Resource private YimiaoshenpiliuchengMapper shenpiliuchengMapper; @Resource private YimiaoshenqingdantbMapper mapper; @Resource private ShenqingdantbMapper shenqingdantbMapper; @Resource private DanjuleixingtbMapper danjuleixingmapper; @Resource private UsertbMapper usermapper; @Resource private DepartmenttbMapper departmentmapper; @Resource private ShenqingdantbMapper shenqingdanmapper; @Resource private YimiaoshenqingdantbMapper yimiaoshenqingdanmapper; @Resource private YiMiaotbMapper yimiaomapper; @Resource private SupplierMapper suppliermapper; @Resource private KehudanweitbMapper kehudanweimapper; @Autowired @Qualifier("cangkuService") private CommServiceIF<DepotALL, Integer> cangkuService; @Resource private SupplierServiceIF supplierService; @Override public Yimiaoshenqingdantb findYimiaoshenqingdan(String id) { YimiaoshenqingdantbExample yimiaoshenqingdanExample = new YimiaoshenqingdantbExample(); yimiaoshenqingdanExample.createCriteria().andShenqingdanIdEqualTo(id); List<Yimiaoshenqingdantb> yimiaoshenqingdans = mapper.selectByExample(yimiaoshenqingdanExample); for (Yimiaoshenqingdantb u : yimiaoshenqingdans) { log.debug("found yimiaoshenqingdan:" + u.getShenqingdanId()); } return yimiaoshenqingdans.get(0); } @Override public YimiaoshenqingdantbFindEntity findAllYimiaoshenqingdans(Pager page) { YimiaoshenqingdantbExample exam = new YimiaoshenqingdantbExample(); YimiaoshenqingdantbFindEntity findEntity = new YimiaoshenqingdantbFindEntity(); //count?limtStart/limitEnd int count = mapper.countByExample(exam); page.setCount(count); exam.setLimitStart(page.getStartDataIndex()); exam.setLimitEnd(page.getPageSize()); //? exam.setOrderByClause("yimiaoshenqingdan_id DESC"); //? List<Yimiaoshenqingdantb> yimiaoshenqingdans = mapper.selectByExample(exam); findEntity.setCount(count); findEntity.setYimiaoshenqingdans(yimiaoshenqingdans); for (Yimiaoshenqingdantb u : yimiaoshenqingdans) { log.debug("found yimiaoshenqingdan:" + u.getShenqingdanId()); } return findEntity; } @Override public YimiaoshenqingdantbFindEntity saveYimiaoshenqingdan(YimiaoshenqingdantbFindEntity yimiaoshenqingdan) { //? log.debug("saveYimiaoshenqingdan for " + yimiaoshenqingdan.getShenqingdan().getShenqingdanId()); String process_Id = ProcessHandeler.startProcess("yimiaoshenqing"); log.debug("start \"yimiaoshenqing\" JBPM task for " + process_Id); //YimiaoshenqingdantbFindEntity?? Shenqingdantb shenqingdan = yimiaoshenqingdan.getShenqingdan(); List<Yimiaoshenqingdantb> list = yimiaoshenqingdan.getYimiaoshenqingdans(); // Object xiaoshouliucheng = System.getProperty("xiaoshouliucheng"); String shenqingdanid = shenqingdan.getShenqingdanId(); String xiaoshouliucheng = shenqingdanid.substring(0, 4); if (!("YMSG".equals(xiaoshouliucheng)) && !("YMLQ".equals(xiaoshouliucheng))) { //??? //? Yimiaoshenpiliucheng yimiaoshenpilicheng = new Yimiaoshenpiliucheng(); yimiaoshenpilicheng.setDanjuId(shenqingdan.getShenqingdanId()); yimiaoshenpilicheng.setProcessId(process_Id); shenpiliuchengMapper.insertSelective(yimiaoshenpilicheng); } else { log.warn("???vm? -Dxiaoshouliucheng"); } // Iterator iterator = list.iterator(); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { Yimiaoshenqingdantb yimiaoshenqingdanIterator = list.get(i); yimiaoshenqingdanmapper.insertSelective(yimiaoshenqingdanIterator); if (yimiaoshenqingdanIterator.getYuandanId() != null) { Yimiaoshenqingdantb yuandan = yimiaoshenqingdanmapper .selectByPrimaryKey(yimiaoshenqingdanIterator.getYuandanId()); YimiaoshenqingdantbExample example = new YimiaoshenqingdantbExample(); example.createCriteria().andXiangdanIdEqualTo(yuandan.getXiangdanId()); if ("YMSG".equals(xiaoshouliucheng) || "YMLQ".equals(xiaoshouliucheng)) { yuandan.setStatus(0); yuandan.setIsCompleted(1); } yimiaoshenqingdanmapper.updateByExample(yuandan, example); } } } if ("YMSG".equals(xiaoshouliucheng) || "YMLQ".equals(xiaoshouliucheng)) { //? shenqingdan.setIsCompleted(1); shenqingdan.setIsPaid(0); } shenqingdanmapper.insertSelective(shenqingdan); return yimiaoshenqingdan; } // // // Iterator iterator = list.iterator(); // while (iterator.hasNext()) { // Sale_detail_tb sale_detail_tb = (Sale_detail_tb) iterator.next(); // if (xiaoshouliucheng == null) { // sale_detail_tb.setStatus(0); // sale_detail_tb.setIsCompleted(1); // } // // saledetailMapper.insertSelective(sale_detail_tb); // // } // // //? // if (xiaoshouliucheng == null) { // sale.setProcessId(1); // } // saleMapper.insertSelective(sale); // // return yimiaoxiaoshou; // } @Override public int saveYimiaoshenqingdan(Yimiaoshenqingdantb yimiaoshenqingdan) { log.debug("insert yimiaoshenqingdan:" + yimiaoshenqingdan.getShenqingdanId()); return mapper.insertSelective(yimiaoshenqingdan); } @Override public int deleteYimiaoshenqingdan(Integer yimiaoshenqingdanId) { log.debug("delete yimiaoshenqingdan:" + yimiaoshenqingdanId); return mapper.deleteByPrimaryKey(yimiaoshenqingdanId); } @Override public int updateYimiaoshenqingdan(Yimiaoshenqingdantb yimiaoshenqingdan) { log.debug("update yimiaoshenqingdan:" + yimiaoshenqingdan.getShenqingdanId()); return mapper.updateByPrimaryKeySelective(yimiaoshenqingdan); } //?? @Override public void CancelYimiaoshenqingdan(YimiaoshenqingdantbFindEntity yimiaoshenqingdan) { for (Yimiaoshenqingdantb shenqingdan : yimiaoshenqingdan.getYimiaoshenqingdans()) { log.debug("Cancel yimiaoshenqingdan:" + shenqingdan.getXiangdanId()); Yimiaoshenqingdantb ymshenqingdan = mapper.selectByPrimaryKey(shenqingdan.getXiangdanId()); ymshenqingdan.setStatus(-1); ymshenqingdan.setReason(shenqingdan.getReason()); mapper.updateByPrimaryKey(ymshenqingdan); } // Shenqingdantb shenqingdan = shenqingdantbMapper.selectByPrimaryKey(yimiaoshenqingdan.getShenqingdan().getShenqingdanId()); // shenqingdan.setShenqingdanRemark(yimiaoshenqingdan.getShenqingdan().getShenqingdanRemark()); // return shenqingdantbMapper.updateByPrimaryKey(shenqingdan); } @Override public JingbanrenFindEntity findJingbanren(Pager page) { UsertbExample userExample = new UsertbExample(); DepartmenttbExample departmentExample = new DepartmenttbExample(); JingbanrenFindEntity findEntity = new JingbanrenFindEntity(); List<JingbanrenEntity> result = new ArrayList<JingbanrenEntity>(); int count = usermapper.countByExample(userExample); page.setCount(count); userExample.setLimitStart(page.getStartDataIndex()); userExample.setLimitEnd(page.getPageSize()); userExample.setOrderByClause("user_id DESC"); List<Usertb> list = usermapper.selectByExample(userExample); if (list != null) { for (int i = 0; i < list.size(); i++) { int departmentid = list.get(i).getDepartmentId(); departmentExample = new DepartmenttbExample(); departmentExample.createCriteria().andDepartmentIdEqualTo(departmentid); List<Departmenttb> departmentlist = departmentmapper.selectByExample(departmentExample); if (departmentlist.size() > 0) { Departmenttb department = departmentlist.get(0); JingbanrenEntity entity = new JingbanrenEntity(); entity.setUserId(list.get(i).getUserId()); entity.setUserName(list.get(i).getUserName()); entity.setUserPassword(list.get(i).getUserPassword()); entity.setUserRoles(list.get(i).getUserRoles()); entity.setUserIdentitycard(list.get(i).getUserIdentitycard()); entity.setUserBirthday(list.get(i).getUserBirthday()); entity.setUserSex(list.get(i).getUserSex()); entity.setUserEntrydate(list.get(i).getUserEntrydate()); entity.setUserPhone(list.get(i).getUserPhone()); entity.setDepartmentId(list.get(i).getDepartmentId()); entity.setUserEmail(list.get(i).getUserEmail()); entity.setUserPosition(list.get(i).getUserPosition()); entity.setUserRemark(list.get(i).getUserRemark()); entity.setDepartmentName(department.getDepartmentName()); entity.setDepartmentRemark(department.getDepartmentRemark()); entity.setFax(department.getFax()); entity.setTel(department.getTel()); result.add(entity); } } } findEntity.setCount(count); findEntity.setResult(result); for (JingbanrenEntity u : result) { log.debug("found user:" + u.getUserName()); } return findEntity; } @Override public JingbanrenFindEntity findJingbanren(Pager page, String conditionSql) { UsertbExample userExample = new UsertbExample(); DepartmenttbExample departmentExample = new DepartmenttbExample(); JingbanrenFindEntity findEntity = new JingbanrenFindEntity(); List<JingbanrenEntity> result = new ArrayList<JingbanrenEntity>(); userExample.createCriteria().addConditionSql(conditionSql); int count = usermapper.countByExample(userExample); page.setCount(count); userExample.setLimitStart(page.getStartDataIndex()); userExample.setLimitEnd(page.getPageSize()); userExample.setOrderByClause("user_id DESC"); List<Usertb> list = usermapper.selectByExample(userExample); if (list != null) { for (int i = 0; i < list.size(); i++) { int departmentid = list.get(i).getDepartmentId(); departmentExample = new DepartmenttbExample(); departmentExample.createCriteria().andDepartmentIdEqualTo(departmentid); List<Departmenttb> departmentlist = departmentmapper.selectByExample(departmentExample); if (departmentlist.size() > 0) { Departmenttb department = departmentlist.get(0); JingbanrenEntity entity = new JingbanrenEntity(); entity.setUserId(list.get(i).getUserId()); entity.setUserName(list.get(i).getUserName()); entity.setUserPassword(list.get(i).getUserPassword()); entity.setUserRoles(list.get(i).getUserRoles()); entity.setUserIdentitycard(list.get(i).getUserIdentitycard()); entity.setUserBirthday(list.get(i).getUserBirthday()); entity.setUserSex(list.get(i).getUserSex()); entity.setUserEntrydate(list.get(i).getUserEntrydate()); entity.setUserPhone(list.get(i).getUserPhone()); entity.setDepartmentId(list.get(i).getDepartmentId()); entity.setUserEmail(list.get(i).getUserEmail()); entity.setUserPosition(list.get(i).getUserPosition()); entity.setUserRemark(list.get(i).getUserRemark()); entity.setDepartmentName(department.getDepartmentName()); entity.setDepartmentRemark(department.getDepartmentRemark()); entity.setFax(department.getFax()); entity.setTel(department.getTel()); result.add(entity); } } } findEntity.setCount(count); findEntity.setResult(result); for (JingbanrenEntity u : result) { log.debug("found user:" + u.getUserName()); } return findEntity; } @Override public ShenbaoyimiaoFindEntity findShenbaoyimiao(Pager pager) { YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample(); ShenbaoyimiaoFindEntity findEntity = new ShenbaoyimiaoFindEntity(); ShenbaoyimiaoEntity shenbaoyimiaoEntity = new ShenbaoyimiaoEntity(); //count?limtStart/limitEnd int count = mapper.countByExample(yimiaoshenqingdanexample); log.debug("found shenbaoyimiao total:" + count); pager.setCount(count); yimiaoshenqingdanexample.setLimitStart(pager.getStartDataIndex()); yimiaoshenqingdanexample.setLimitEnd(pager.getPageSize()); //? yimiaoshenqingdanexample.setOrderByClause("xiangdan_id ASC"); findEntity.setCount(count); //? List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = mapper.selectByExample(yimiaoshenqingdanexample); List<ShenbaoyimiaoEntity> resultAll = new ArrayList<ShenbaoyimiaoEntity>(); 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); shenbaoyimiaoEntity.setYimiaoAll(yimiaoAll); Shenqingdantb shenqingdantb = shenqingdantbMapper .selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId()); shenbaoyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan); shenbaoyimiaoEntity.setShenqingdan(shenqingdantb); resultAll.add(shenbaoyimiaoEntity); } findEntity.setResult(resultAll); return findEntity; } @Override public ShenbaoyimiaoFindEntity findShenbaoyimiao(Pager pager, String conditionSql) { YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample(); ShenbaoyimiaoFindEntity findEntity = new ShenbaoyimiaoFindEntity(); if (conditionSql != null && !conditionSql.trim().equals("")) { yimiaoshenqingdanexample.createCriteria().addConditionSql(conditionSql); } //count?limtStart/limitEnd int count = mapper.countByExample(yimiaoshenqingdanexample); log.debug("found shenbaoyimiao total:" + count); pager.setCount(count); yimiaoshenqingdanexample.setLimitStart(pager.getStartDataIndex()); yimiaoshenqingdanexample.setLimitEnd(pager.getPageSize()); //? yimiaoshenqingdanexample.setOrderByClause("xiangdan_id ASC"); findEntity.setCount(count); //? List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = mapper.selectByExample(yimiaoshenqingdanexample); List<ShenbaoyimiaoEntity> resultAll = new ArrayList<ShenbaoyimiaoEntity>(); for (Yimiaoshenqingdantb yimiaoshenqingdan : yimiaoshenqingdanlist) { ShenbaoyimiaoEntity shenbaoyimiaoEntity = new ShenbaoyimiaoEntity(); 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); shenbaoyimiaoEntity.setYimiaoAll(yimiaoAll); Shenqingdantb shenqingdantb = new Shenqingdantb(); shenqingdantb = shenqingdantbMapper.selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId()); shenbaoyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan); shenbaoyimiaoEntity.setShenqingdan(shenqingdantb); resultAll.add(shenbaoyimiaoEntity); } findEntity.setResult(resultAll); return findEntity; } @Override public ShenbaoyimiaoFindEntity findShenbaoyimiaodj(Pager pager, String conditionSql) { YimiaoshenqingdantbExample yimiaoshenqingdanexample = new YimiaoshenqingdantbExample(); ShenbaoyimiaoFindEntity findEntity = new ShenbaoyimiaoFindEntity(); if (conditionSql != null && !conditionSql.trim().equals("")) { yimiaoshenqingdanexample.createCriteria().addConditionSql(conditionSql); } //count?limtStart/limitEnd int count = mapper.countByExample(yimiaoshenqingdanexample); log.debug("found shenbaoyimiao total:" + count); pager.setCount(count); yimiaoshenqingdanexample.setLimitStart(pager.getStartDataIndex()); yimiaoshenqingdanexample.setLimitEnd(pager.getPageSize()); //? yimiaoshenqingdanexample.setOrderByClause("xiangdan_id ASC"); findEntity.setCount(count); //? List<Yimiaoshenqingdantb> yimiaoshenqingdanlist = mapper.selectByExample(yimiaoshenqingdanexample); List<ShenbaoyimiaoEntity> resultAll = new ArrayList<ShenbaoyimiaoEntity>(); for (Yimiaoshenqingdantb yimiaoshenqingdan : yimiaoshenqingdanlist) { ShenbaoyimiaoEntity shenbaoyimiaoEntity = new ShenbaoyimiaoEntity(); 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); shenbaoyimiaoEntity.setYimiaoAll(yimiaoAll); Shenqingdantb shenqingdantb = new Shenqingdantb(); shenqingdantb = shenqingdantbMapper.selectByPrimaryKey(yimiaoshenqingdan.getShenqingdanId()); shenbaoyimiaoEntity.setYimiaoshenqingtb(yimiaoshenqingdan); shenbaoyimiaoEntity.setShenqingdan(shenqingdantb); if (yimiaoshenqingdan.getXiangdanId() == yimiaoshenqingdan.getXiangdanId() && yimiaoshenqingdan.getStatus() == 0) { //??ID? YimiaodengjitbExample sqdexam = new YimiaodengjitbExample(); sqdexam.createCriteria().andXiangdanIdEqualTo(yimiaoshenqingdan.getXiangdanId()); List<Yimiaodengjitb> sqdlist = YimiaodengjitbMapper.selectByExample(sqdexam); Double chashu = 0d; Double shulian = chashu; shenbaoyimiaoEntity.setDengjishuliang(Arith.decimal(yimiaoshenqingdan.getQuantity(), 5)); // yimiaoshenqingdan.setQuantity(yimiaoshenqingdan.getQuantity()); //?? for (int i = 0; i < sqdlist.size(); i++) { //?? chashu = Arith.decimal(sqdlist.get(i).getQuantity(), 5); shulian = Arith.decimal(chashu + shulian, 5); Double strQuantity = Arith .round(Arith.mul(Arith.decimal(yimiaoshenqingdan.getQuantity() - shulian, 5), Arith.div(1, yimiaoAll.getYimiaoHuansuanlv(), 0)), 0); strQuantity = Arith.div(strQuantity, Arith.div(1, yimiaoAll.getYimiaoHuansuanlv(), 0), 5); if (strQuantity <= 0) { continue; } // shenbaoyimiaoEntity.setDengjishuliang(Arith.decimal(yimiaoshenqingdan.getQuantity() - shulian, 5)); shenbaoyimiaoEntity.setDengjishuliang(strQuantity); if (shulian.equals(yimiaoshenqingdan.getQuantity())) { yimiaoshenqingdan.setStatus(1); YimiaoshenqingdantbExample ymsqd = new YimiaoshenqingdantbExample(); ymsqd.createCriteria().andXiangdanIdEqualTo(yimiaoshenqingdan.getXiangdanId()); mapper.updateByExample(yimiaoshenqingdan, ymsqd); } } } if (shenbaoyimiaoEntity.getYimiaoshenqingtb().getStatus() == 0) { resultAll.add(shenbaoyimiaoEntity); } } findEntity.setResult(resultAll); return findEntity; } /** * (???) * * @param pager * @return */ @Override public YimiaotuihuoshenqingFindEntity findYimiaotuihuoshenqinglist(Pager pager) { YimiaotuihuoshenqingFindEntity findEntitys = new YimiaotuihuoshenqingFindEntity(); List<YimiaotuihuoEntity> yimiaotuihuolist = new ArrayList<YimiaotuihuoEntity>(); //Backsale_detail_tb Backsale_detail_tbExample backsaledetailexam = new Backsale_detail_tbExample(); //count?limtStart/limitEnd int count = backsaledetailmapper.countByExample(backsaledetailexam); log.debug("found yimiaoxiaoshoutuihuoshenqing total:" + count); pager.setCount(count); backsaledetailexam.setLimitStart(pager.getStartDataIndex()); backsaledetailexam.setLimitEnd(pager.getPageSize()); //? backsaledetailexam.setOrderByClause("backsale_date DESC"); findEntitys.setCount(count); List<Backsale_detail_tb> backsale_detail_list = backsaledetailmapper.selectByExample(backsaledetailexam); if (backsale_detail_list.size() > 0) { for (Backsale_detail_tb bsd : backsale_detail_list) { log.debug(YimiaoshenqingdanService.class.getName() + "?" + bsd.getBacksaleId()); YimiaotuihuoEntity ymth = new YimiaotuihuoEntity(); ymth.setBacksaledetails(bsd); BacksaletbExample backsaleexam = new BacksaletbExample(); backsaleexam.createCriteria().andBacksaleIdEqualTo(bsd.getBacksaleId()); List<Backsaletb> backsale_list = backsalemapper.selectByExample(backsaleexam); if (backsale_list.size() > 0) { for (Backsaletb bs : backsale_list) { log.debug(YimiaoshenqingdanService.class.getName() + "?" + bs.getBacksaleId()); ymth.setBacksale(bs); if (bs.getSupplierId() != null && !bs.getSupplierId().equals("")) { SupplierExample supplierexam = new SupplierExample(); supplierexam.createCriteria().andSupplierIdEqualTo(bs.getSupplierId()); List<Supplier> spl = suppliermapper.selectByExample(supplierexam); ymth.setSupplier(spl.get(0)); log.debug(YimiaoshenqingdanService.class.getName() + "??" + spl.get(0).getSupplierName()); } if (bs.getCustomerId() != null && !bs.getCustomerId().equals("")) { KehudanweitbExample kehudanweiExample = new KehudanweitbExample(); kehudanweiExample.createCriteria().andKehudanweiIdEqualTo(bs.getCustomerId()); List<Kehudanweitb> khdwl = kehudanweimapper.selectByExample(kehudanweiExample); ymth.setKehudanwei(khdwl.get(0)); log.debug(YimiaoshenqingdanService.class.getName() + "?" + khdwl.get(0).getKehudanweiName()); } } } YiMiaotbExample yimiaoexam = new YiMiaotbExample(); yimiaoexam.createCriteria().andYimiaoIdEqualTo(bsd.getYimiaoId()); List<YiMiaotb> yimiaolist = yimiaomapper.selectByExample(yimiaoexam); if (yimiaolist.size() > 0) { for (YiMiaotb ym : yimiaolist) { ymth.setYimiao(ym); } } yimiaotuihuolist.add(ymth); } } findEntitys.setResult(yimiaotuihuolist); return findEntitys; } /** * (???) * * @param pager * @param conditionSql * @return */ @Override public YimiaotuihuoshenqingFindEntity findYimiaotuihuoshenqinglist(Pager pager, String conditionSql) { YimiaotuihuoshenqingFindEntity findEntitys = new YimiaotuihuoshenqingFindEntity(); List<YimiaotuihuoEntity> yimiaotuihuolist = new ArrayList<YimiaotuihuoEntity>(); //Backsale_detail_tb Backsale_detail_tbExample backsaledetailexam = new Backsale_detail_tbExample(); backsaledetailexam.createCriteria().addConditionSql(conditionSql); //count?limtStart/limitEnd int count = backsaledetailmapper.countByExample(backsaledetailexam); log.debug("found yimiaoxiaoshoutuihuoshenqing total:" + count); pager.setCount(count); backsaledetailexam.setLimitStart(pager.getStartDataIndex()); backsaledetailexam.setLimitEnd(pager.getPageSize()); //? backsaledetailexam.setOrderByClause("backsale_date DESC"); findEntitys.setCount(count); List<Backsale_detail_tb> backsale_detail_list = backsaledetailmapper.selectByExample(backsaledetailexam); if (backsale_detail_list.size() > 0) { for (Backsale_detail_tb bsd : backsale_detail_list) { log.debug(YimiaoshenqingdanService.class.getName() + "?" + bsd.getBacksaleId()); YiMiaotb yimiao = new YiMiaotb(); yimiao = yimiaomapper.selectByPrimaryKey(bsd.getYimiaoId()); YimiaotuihuoEntity ymth = new YimiaotuihuoEntity(); if (bsd.getBacksaleId() == bsd.getBacksaleId() && bsd.getStatus() == 3) { //??ID? YimiaodengjitbExample sqdexam = new YimiaodengjitbExample(); sqdexam.createCriteria().andXiangdanIdEqualTo(bsd.getBackDetailId()) .andStatusIn(new ArrayList<Integer>(Arrays.asList(3, 4))); List<Yimiaodengjitb> sqdlist = YimiaodengjitbMapper.selectByExample(sqdexam); Double chashu = 0d; Double shulian = chashu; ymth.setDengjishuliang(Arith.decimal(bsd.getQuantity(), 5)); // yimiaoshenqingdan.setQuantity(yimiaoshenqingdan.getQuantity()); //?? for (int i = 0; i < sqdlist.size(); i++) { //?? chashu = Arith.decimal(sqdlist.get(i).getQuantity(), 5); shulian = Arith.decimal(chashu + shulian, 5); Double strQuantity = Arith.round(Arith.mul(Arith.decimal(bsd.getQuantity() - shulian, 5), Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0)), 0); strQuantity = Arith.div(strQuantity, Arith.div(1, yimiao.getYimiaoHuansuanlv(), 0), 5); // ymth.setDengjishuliang(Arith.decimal(bsd.getQuantity() - shulian, 5)); // bsd.setQuantity(ymth.getDengjishuliang()); if (shulian.equals(bsd.getQuantity())) { bsd.setStatus(4); Backsale_detail_tbExample ymsqd = new Backsale_detail_tbExample(); ymsqd.createCriteria().andBackDetailIdEqualTo(bsd.getBackDetailId()); backsaledetailmapper.updateByExample(bsd, ymsqd); } if (strQuantity <= 0) { continue; } ymth.setDengjishuliang(strQuantity); } } ymth.setBacksaledetails(bsd); BacksaletbExample backsaleexam = new BacksaletbExample(); backsaleexam.createCriteria().andBacksaleIdEqualTo(bsd.getBacksaleId()); List<Backsaletb> backsale_list = backsalemapper.selectByExample(backsaleexam); if (backsale_list.size() > 0) { for (Backsaletb bs : backsale_list) { log.debug(YimiaoshenqingdanService.class.getName() + "?" + bs.getBacksaleId()); ymth.setBacksale(bs); if (bs.getSupplierId() != null && !bs.getSupplierId().equals("")) { SupplierExample supplierexam = new SupplierExample(); supplierexam.createCriteria().andSupplierIdEqualTo(bs.getSupplierId()); List<Supplier> spl = suppliermapper.selectByExample(supplierexam); ymth.setSupplier(spl.get(0)); log.debug(YimiaoshenqingdanService.class.getName() + "??" + spl.get(0).getSupplierName()); } if (bs.getCustomerId() != null && !bs.getCustomerId().equals("")) { KehudanweitbExample kehudanweiExample = new KehudanweitbExample(); kehudanweiExample.createCriteria().andKehudanweiIdEqualTo(bs.getCustomerId()); List<Kehudanweitb> khdwl = kehudanweimapper.selectByExample(kehudanweiExample); ymth.setKehudanwei(khdwl.get(0)); log.debug(YimiaoshenqingdanService.class.getName() + "?" + khdwl.get(0).getKehudanweiName()); } } } YiMiaotbExample yimiaoexam = new YiMiaotbExample(); yimiaoexam.createCriteria().andYimiaoIdEqualTo(bsd.getYimiaoId()); List<YiMiaotb> yimiaolist = yimiaomapper.selectByExample(yimiaoexam); if (yimiaolist.size() > 0) { for (YiMiaotb ym : yimiaolist) { ymth.setYimiao(ym); } } if (ymth.getBacksaledetails().getStatus() == 3) { yimiaotuihuolist.add(ymth); } } } findEntitys.setResult(yimiaotuihuolist); return findEntitys; } }