|
|
@@ -84,89 +84,93 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
|
|
|
@Transactional
|
|
|
public Map<String,Object> stock() {
|
|
|
Map<String,Object> resultMap = new HashMap();
|
|
|
-
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
Long userId = BaseContextHolder.getUserId();
|
|
|
+ String userName = BaseContextHolder.getUserName();
|
|
|
//生成入库单
|
|
|
- ProdInOut prodIn = new ProdInOut();
|
|
|
- String piInno = getMaxnumber(BillCodeSeq.OTHERIN);
|
|
|
- prodIn.setPi_inoutno(piInno);
|
|
|
- prodIn.setPi_class(BillCodeSeq.OTHERIN.getName());
|
|
|
- prodIn.setPi_date(new Date());
|
|
|
- prodIn.setPi_status("未审核");
|
|
|
- prodIn.setPi_statuscode("UNAUDITED");
|
|
|
- prodIn.setCompanyId(companyId);
|
|
|
- prodIn.setCreateTime(new Date());
|
|
|
- prodIn.setCreatorId(userId);
|
|
|
- prodIn.setPi_remark("盘盈单");
|
|
|
- prodInOutMapper.insertSelective(prodIn);
|
|
|
- long inid = prodIn.getId();
|
|
|
-
|
|
|
- Double purcprice = null;
|
|
|
-
|
|
|
List<StockTaking> inlist = getMapper().selectStockTakingBycondition("st_num>0",companyId);
|
|
|
- for (int i=0;i<inlist.size();i++) {
|
|
|
- StockTaking st = inlist.get(i);
|
|
|
- ProdIODetail prodInDetail = new ProdIODetail();
|
|
|
- prodInDetail.setPd_piid(inid);
|
|
|
- prodInDetail.setPd_inoutno(piInno);
|
|
|
- prodInDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
|
|
|
- prodInDetail.setPd_pdno(i+1);
|
|
|
-
|
|
|
- purcprice = getMapper().getPurcpriceByProduct(st.getSt_prodid());
|
|
|
- prodInDetail.setPd_orderprice(purcprice==null?0:purcprice);
|
|
|
- prodInDetail.setPd_prodid(st.getSt_prodid());
|
|
|
- prodInDetail.setPd_prodcode(st.getSt_prodcode());
|
|
|
- prodInDetail.setPd_inqty(st.getSt_num());
|
|
|
- //仓库
|
|
|
- prodInDetail.setPd_whid(st.getSt_whid());
|
|
|
- prodInDetail.setPd_whcode(st.getSt_whcode());
|
|
|
- prodInDetail.setPd_whname(st.getSt_whname());
|
|
|
- prodInDetail.setCompanyId(companyId);
|
|
|
- prodInDetail.setCreateTime(new Date());
|
|
|
- prodInDetail.setCreatorId(userId);
|
|
|
- prodIODetailMapper.insertSelective(prodInDetail);
|
|
|
+ if (inlist.size()>0){
|
|
|
+ ProdInOut prodIn = new ProdInOut();
|
|
|
+ String piInno = getMaxnumber(BillCodeSeq.OTHERIN);
|
|
|
+ prodIn.setPi_inoutno(piInno);
|
|
|
+ prodIn.setPi_class(BillCodeSeq.OTHERIN.getName());
|
|
|
+ prodIn.setPi_date(new Date());
|
|
|
+ prodIn.setPi_status("未审核");
|
|
|
+ prodIn.setPi_statuscode("UNAUDITED");
|
|
|
+ prodIn.setCompanyId(companyId);
|
|
|
+ prodIn.setCreateTime(new Date());
|
|
|
+ prodIn.setCreatorId(userId);
|
|
|
+ prodIn.setPi_remark("盘盈单");
|
|
|
+ prodInOutMapper.insertSelective(prodIn);
|
|
|
+ long inid = prodIn.getId();
|
|
|
+ //更新录入人
|
|
|
+ prodInOutMapper.updateCreator(userId,userName,inid);
|
|
|
+ Double purcprice = null;
|
|
|
+ for (int i=0;i<inlist.size();i++) {
|
|
|
+ StockTaking st = inlist.get(i);
|
|
|
+ ProdIODetail prodInDetail = new ProdIODetail();
|
|
|
+ prodInDetail.setPd_piid(inid);
|
|
|
+ prodInDetail.setPd_inoutno(piInno);
|
|
|
+ prodInDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
|
|
|
+ prodInDetail.setPd_pdno(i+1);
|
|
|
+ purcprice = getMapper().getPurcpriceByProduct(st.getSt_prodid());
|
|
|
+ prodInDetail.setPd_orderprice(purcprice==null?0:purcprice);
|
|
|
+ prodInDetail.setPd_prodid(st.getSt_prodid());
|
|
|
+ prodInDetail.setPd_prodcode(st.getSt_prodcode());
|
|
|
+ prodInDetail.setPd_inqty(st.getSt_num());
|
|
|
+ //仓库
|
|
|
+ prodInDetail.setPd_whid(st.getSt_whid());
|
|
|
+ prodInDetail.setPd_whcode(st.getSt_whcode());
|
|
|
+ prodInDetail.setPd_whname(st.getSt_whname());
|
|
|
+ prodInDetail.setCompanyId(companyId);
|
|
|
+ prodInDetail.setCreateTime(new Date());
|
|
|
+ prodInDetail.setCreatorId(userId);
|
|
|
+ prodIODetailMapper.insertSelective(prodInDetail);
|
|
|
+ }
|
|
|
+ DocBaseDTO baseDTOIN = new DocBaseDTO(inid,piInno,"其它入库单");
|
|
|
+ resultMap.put("inData",baseDTOIN);
|
|
|
}
|
|
|
|
|
|
//生成出库单
|
|
|
- ProdInOut prodOut = new ProdInOut();
|
|
|
- String piOutno = getMaxnumber(BillCodeSeq.OTHEROUT);
|
|
|
- prodOut.setPi_inoutno(piOutno);
|
|
|
- prodOut.setPi_class(BillCodeSeq.OTHEROUT.getName());
|
|
|
- prodOut.setPi_date(new Date());
|
|
|
- prodOut.setPi_status("未审核");
|
|
|
- prodOut.setPi_statuscode("UNAUDITED");
|
|
|
- prodOut.setCompanyId(companyId);
|
|
|
- prodOut.setCreateTime(new Date());
|
|
|
- prodOut.setCreatorId(userId);
|
|
|
- prodOut.setPi_remark("盘亏单");
|
|
|
- prodInOutMapper.insertSelective(prodOut);
|
|
|
- long outid = prodOut.getId();
|
|
|
-
|
|
|
List<StockTaking> outlist = getMapper().selectStockTakingBycondition("st_num<0",companyId);
|
|
|
- for (int i=0;i<outlist.size();i++) {
|
|
|
- StockTaking st = outlist.get(i);
|
|
|
- ProdIODetail prodOutDetail = new ProdIODetail();
|
|
|
- prodOutDetail.setPd_piid(outid);
|
|
|
- prodOutDetail.setPd_inoutno(piOutno);
|
|
|
- prodOutDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
|
|
|
- prodOutDetail.setPd_pdno(i+1);
|
|
|
- prodOutDetail.setPd_prodid(st.getSt_prodid());
|
|
|
- prodOutDetail.setPd_prodcode(st.getSt_prodcode());
|
|
|
- prodOutDetail.setPd_outqty(-st.getSt_num());
|
|
|
- //仓库
|
|
|
- prodOutDetail.setPd_whid(st.getSt_whid());
|
|
|
- prodOutDetail.setPd_whcode(st.getSt_whcode());
|
|
|
- prodOutDetail.setPd_whname(st.getSt_whname());
|
|
|
- prodOutDetail.setCompanyId(companyId);
|
|
|
- prodOutDetail.setCreateTime(new Date());
|
|
|
- prodOutDetail.setCreatorId(userId);
|
|
|
- prodIODetailMapper.insertSelective(prodOutDetail);
|
|
|
+ if (outlist.size()>0){
|
|
|
+ ProdInOut prodOut = new ProdInOut();
|
|
|
+ String piOutno = getMaxnumber(BillCodeSeq.OTHEROUT);
|
|
|
+ prodOut.setPi_inoutno(piOutno);
|
|
|
+ prodOut.setPi_class(BillCodeSeq.OTHEROUT.getName());
|
|
|
+ prodOut.setPi_date(new Date());
|
|
|
+ prodOut.setPi_status("未审核");
|
|
|
+ prodOut.setPi_statuscode("UNAUDITED");
|
|
|
+ prodOut.setCompanyId(companyId);
|
|
|
+ prodOut.setCreateTime(new Date());
|
|
|
+ prodOut.setCreatorId(userId);
|
|
|
+ prodOut.setPi_remark("盘亏单");
|
|
|
+ prodInOutMapper.insertSelective(prodOut);
|
|
|
+ long outid = prodOut.getId();
|
|
|
+ //更新录入人
|
|
|
+ prodInOutMapper.updateCreator(userId,userName,outid);
|
|
|
+ for (int i=0;i<outlist.size();i++) {
|
|
|
+ StockTaking st = outlist.get(i);
|
|
|
+ ProdIODetail prodOutDetail = new ProdIODetail();
|
|
|
+ prodOutDetail.setPd_piid(outid);
|
|
|
+ prodOutDetail.setPd_inoutno(piOutno);
|
|
|
+ prodOutDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
|
|
|
+ prodOutDetail.setPd_pdno(i+1);
|
|
|
+ prodOutDetail.setPd_prodid(st.getSt_prodid());
|
|
|
+ prodOutDetail.setPd_prodcode(st.getSt_prodcode());
|
|
|
+ prodOutDetail.setPd_outqty(-st.getSt_num());
|
|
|
+ //仓库
|
|
|
+ prodOutDetail.setPd_whid(st.getSt_whid());
|
|
|
+ prodOutDetail.setPd_whcode(st.getSt_whcode());
|
|
|
+ prodOutDetail.setPd_whname(st.getSt_whname());
|
|
|
+ prodOutDetail.setCompanyId(companyId);
|
|
|
+ prodOutDetail.setCreateTime(new Date());
|
|
|
+ prodOutDetail.setCreatorId(userId);
|
|
|
+ prodIODetailMapper.insertSelective(prodOutDetail);
|
|
|
+ }
|
|
|
+ DocBaseDTO baseDTOOUT = new DocBaseDTO(outid,piOutno,"其它出库单");
|
|
|
+ resultMap.put("outData",baseDTOOUT);
|
|
|
}
|
|
|
- DocBaseDTO baseDTOIN = new DocBaseDTO(inid,piInno,"其它入库单");
|
|
|
- DocBaseDTO baseDTOOUT = new DocBaseDTO(outid,piOutno,"其它出库单");
|
|
|
- resultMap.put("inData",baseDTOIN);
|
|
|
- resultMap.put("outData",baseDTOOUT);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|