|
|
@@ -5,12 +5,15 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
+import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocSavedDTO;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
+import com.usoftchina.saas.commons.po.BillCodeSeq;
|
|
|
import com.usoftchina.saas.commons.po.Maxnumbers;
|
|
|
+import com.usoftchina.saas.commons.po.Status;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.document.api.WarehouseApi;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
|
@@ -28,26 +31,26 @@ import com.usoftchina.saas.storage.po.ProdInOutList;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
@Service
|
|
|
public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper, ProdInOut> implements ProdInOutService{
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private SaledetailMapper saledetailMapper;
|
|
|
@Autowired
|
|
|
private MaxnumberService maxnumberService;
|
|
|
- @Autowired
|
|
|
- private SaleMapper saleMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ProdInOutListMapper prodInOutListMapper;
|
|
|
@Autowired
|
|
|
private ProdInOutMapper prodInOutMapper;
|
|
|
@Autowired
|
|
|
private ProdIODetailMapper prodIODetailMapper;
|
|
|
-// @Autowired
|
|
|
-// private WarehouseApi warehouseApi;
|
|
|
+ @Autowired
|
|
|
+ private MessageLogService messageLogService;
|
|
|
+ @Autowired
|
|
|
+ private WarehouseApi warehouseApi;
|
|
|
|
|
|
@Override
|
|
|
public ProdInOutFormDTO getFormData(Long id) {
|
|
|
@@ -66,7 +69,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DocSavedDTO saveFormData(ProdInOutFormDTO formdata, Boolean isbfaudit) {
|
|
|
+ @Transactional
|
|
|
+ public DocBaseDTO saveFormData(ProdInOutFormDTO formdata) {
|
|
|
|
|
|
if (null == formdata || null == formdata.getMain()){
|
|
|
throw new BizException(500, "数据为空,请填写后再保存");
|
|
|
@@ -82,29 +86,29 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
List<ProdIODetail> insertDetails = new ArrayList<>();
|
|
|
//更新从表数据
|
|
|
List<ProdIODetail> updateDetails = new ArrayList<>();
|
|
|
- DocSavedDTO saveDTO = new DocSavedDTO();
|
|
|
+ //返回对象
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
Long pi_id = main.getId();
|
|
|
String pi_inoutno = main.getPi_inoutno();
|
|
|
String pi_class = main.getPi_class();
|
|
|
-
|
|
|
ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
|
|
|
prodInOut.setCompanyId(companyId);
|
|
|
prodInOut.setCreatorId(userId);
|
|
|
prodInOut.setCreateTime(new Date());
|
|
|
prodInOut.setPi_date(new Date());
|
|
|
|
|
|
+ //编号获取
|
|
|
+ pi_inoutno = pushMaxnubmer(pi_inoutno, pi_id,pi_class);
|
|
|
+ prodInOut.setPi_inoutno(pi_inoutno);
|
|
|
+
|
|
|
prodInOut.setPi_class(main.getPi_class());
|
|
|
prodInOut.setPi_said(main.getPi_said());
|
|
|
prodInOut.setPi_sacode(main.getPi_sacode());
|
|
|
|
|
|
- //编号获取
|
|
|
- pi_inoutno = pushMaxnubmer(pi_inoutno, pi_id,pi_class);
|
|
|
- prodInOut.setPi_inoutno(pi_inoutno);
|
|
|
- saveDTO.setCode(pi_inoutno);
|
|
|
//判断更新与保存动作
|
|
|
if (StringUtils.isEmpty(pi_id) || "0".equals(pi_id.toString())){
|
|
|
//插入操作
|
|
|
- getMapper().insertSelective(prodInOut);
|
|
|
+ prodInOutMapper.insertSelective(prodInOut);
|
|
|
pi_id = prodInOut.getId();
|
|
|
//添加从表传输对象
|
|
|
for (ProdIODetailDTO item : items) {
|
|
|
@@ -115,15 +119,20 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
detail.setPd_yqty(0.0);
|
|
|
insertDetails.add(detail);
|
|
|
}
|
|
|
+
|
|
|
//插入从表
|
|
|
if (insertDetails.size()>0) {
|
|
|
prodIODetailMapper.batchInsert(insertDetails);
|
|
|
}
|
|
|
- saveDTO.setId(pi_id);
|
|
|
- return saveDTO;
|
|
|
+ baseDTO = getBaseDTOById(pi_id,pi_class);
|
|
|
+ //更新明细金额
|
|
|
+ getTotal(pi_id,pi_class);
|
|
|
+ //日志记录
|
|
|
+ messageLogService.save(baseDTO);
|
|
|
+ return baseDTO;
|
|
|
}
|
|
|
//更新操作
|
|
|
- getMapper().updateByPrimaryKeySelective(prodInOut);
|
|
|
+ prodInOutMapper.updateByPrimaryKeySelective(prodInOut);
|
|
|
//添加从表传输对象
|
|
|
for (ProdIODetailDTO item : items) {
|
|
|
ProdIODetail detail = BeanMapper.map(item, ProdIODetail.class);
|
|
|
@@ -144,94 +153,173 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
if (updateDetails.size()>0) {
|
|
|
prodIODetailMapper.batchUpdate(updateDetails);
|
|
|
}
|
|
|
- saveDTO.setId(pi_id);
|
|
|
+ baseDTO = getBaseDTOById(pi_id,pi_class);
|
|
|
//更新已转数
|
|
|
- if (!isbfaudit)
|
|
|
- updateYqty(prodInOut);
|
|
|
- return saveDTO;
|
|
|
+ updateYqty(prodInOut);
|
|
|
+ return baseDTO;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void delete(Long id) {
|
|
|
singleDelete(id);
|
|
|
}
|
|
|
private void singleDelete(Long id) {
|
|
|
- if (null != id) {
|
|
|
- ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
|
|
|
- //从表删除
|
|
|
- prodIODetailMapper.deleteByForeignKey(id);
|
|
|
- //主表删除
|
|
|
- prodInOutMapper.deleteByPrimaryKey(id);
|
|
|
- //更新已转数
|
|
|
- updateYqty(prodInOut);
|
|
|
- }
|
|
|
+ ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
|
|
|
+ //从表删除
|
|
|
+ prodIODetailMapper.deleteByForeignKey(id);
|
|
|
+ //主表删除
|
|
|
+ prodInOutMapper.deleteByPrimaryKey(id);
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
|
|
|
+ //更新已转数
|
|
|
+ updateYqty(prodInOut);
|
|
|
+ //日志
|
|
|
+ messageLogService.deleteDetail(docBaseDTO);
|
|
|
}
|
|
|
@Override
|
|
|
- public DocSavedDTO audit(ProdInOutFormDTO formData) {
|
|
|
+ @Transactional
|
|
|
+ public DocBaseDTO audit(ProdInOutFormDTO formData) {
|
|
|
Long id = null;
|
|
|
- DocSavedDTO savedDTO = new DocSavedDTO();
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
if (null != formData) {
|
|
|
id = formData.getMain().getId();
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
- DocSavedDTO saveDTO = saveFormData(formData,true);
|
|
|
- id = saveDTO.getId();
|
|
|
+ baseDTO = saveFormData(formData);
|
|
|
+ id = baseDTO.getId();
|
|
|
+ }
|
|
|
+ String res = singleAudit(formData.getMain());
|
|
|
+ if(res!=null){
|
|
|
+ new BizException(501,res);
|
|
|
}
|
|
|
- singleAudit(formData.getMain());
|
|
|
}
|
|
|
- savedDTO.setId(id);
|
|
|
- return savedDTO;
|
|
|
+ baseDTO.setId(id);
|
|
|
+ return baseDTO;
|
|
|
}
|
|
|
- private void singleAudit(ProdInOutDTO prodInOutDTO) {
|
|
|
+ private String singleAudit(ProdInOutDTO prodInOutDTO) {
|
|
|
+ String pi_class= prodInOutDTO.getPi_class();
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
map.put("inoutNo",prodInOutDTO.getPi_inoutno() );
|
|
|
- map.put("class",prodInOutDTO.getPi_class() );
|
|
|
- map.put("commitid",prodInOutDTO.getPi_recordmanid());
|
|
|
- map.put("companyid",prodInOutDTO.getCompanyId());
|
|
|
+ map.put("class", pi_class);
|
|
|
+ map.put("commitid",BaseContextHolder.getUserId());
|
|
|
+ map.put("companyid",BaseContextHolder.getCompanyId());
|
|
|
map.put("result","");
|
|
|
- //warehouseApi.post(map);
|
|
|
+ warehouseApi.post(map);
|
|
|
Object result = map.get("result");
|
|
|
- System.out.println("result");
|
|
|
- //记录日志
|
|
|
- if (!StringUtils.isEmpty(result))
|
|
|
- throw new BizException(500, "存在已审核单据,单据编号:" + result);
|
|
|
+ if(result!=null){
|
|
|
+ return result.toString();
|
|
|
+ }else{
|
|
|
+ //记录日志
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(prodInOutDTO.getId(),pi_class);
|
|
|
+ //日志
|
|
|
+ messageLogService.audit(docBaseDTO);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|
|
|
@Override
|
|
|
- public void unAudit(Long id) {
|
|
|
- ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
|
|
|
+ public Result unAudit(Long id) {
|
|
|
+ if (null == id) {
|
|
|
+ return Result.error(BizExceptionCode.SALE_NULL_BILL);
|
|
|
+ }
|
|
|
+ String code = prodInOutMapper.validateUnAudit(id);
|
|
|
+ if (null != code) {
|
|
|
+ throw new BizException(BizExceptionCode.SALE_NULL_BILL);
|
|
|
+ }
|
|
|
+ ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
|
|
|
ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut, ProdInOutDTO.class);
|
|
|
- singleAudit(prodInOutDTO);
|
|
|
+ String res = singleUnAudit(prodInOutDTO);
|
|
|
+ if(res!=null){
|
|
|
+ return Result.error(res);
|
|
|
+ }else{
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private String singleUnAudit(ProdInOutDTO prodInOutDTO) {
|
|
|
+ String pi_class= prodInOutDTO.getPi_class();
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("inoutNo",prodInOutDTO.getPi_inoutno() );
|
|
|
+ map.put("class", pi_class);
|
|
|
+ map.put("commitid",BaseContextHolder.getUserId());
|
|
|
+ map.put("companyid",BaseContextHolder.getCompanyId());
|
|
|
+ map.put("result","");
|
|
|
+ warehouseApi.unPost(map);
|
|
|
+ Object result = map.get("result");
|
|
|
+ if(result!=null){
|
|
|
+ return result.toString();
|
|
|
+ }else{
|
|
|
+ //记录日志
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(prodInOutDTO.getId(),pi_class);
|
|
|
+ //日志
|
|
|
+ messageLogService.unAudit(docBaseDTO);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
@Override
|
|
|
public void batchAudit(BatchDealBaseDTO baseDTOs) {
|
|
|
+ if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
|
|
|
+ baseDTOs.getBaseDTOs().size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String validate = prodInOutMapper.validateAudit(baseDTOs.getBaseDTOs());
|
|
|
+ if (!StringUtils.isEmpty(validate)) {
|
|
|
+ throw new BizException(500, "存在已审核单据,单据编号:" + validate);
|
|
|
+ }
|
|
|
+ String error = null;
|
|
|
+ for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
|
|
|
+ Long id = base.getId();
|
|
|
+ ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
|
|
|
+ ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut,ProdInOutDTO.class);
|
|
|
+ error+=singleAudit(prodInOutDTO);
|
|
|
+ }
|
|
|
+ if(error!=null&&!error.equals("")){
|
|
|
+ new BizException(501,error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void batchUnAudit(BatchDealBaseDTO baseDTOs) {
|
|
|
+ if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
|
|
|
+ baseDTOs.getBaseDTOs().size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String msg = prodInOutMapper.validateBatchUnAudit(baseDTOs.getBaseDTOs());
|
|
|
+ if (null != msg) {
|
|
|
+ throw new BizException(500, "存在未审核单据,单据编号:" + msg);
|
|
|
+ }
|
|
|
+ String error = null;
|
|
|
for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
|
|
|
Long id = base.getId();
|
|
|
- ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
|
|
|
+ ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
|
|
|
ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut,ProdInOutDTO.class);
|
|
|
- singleAudit(prodInOutDTO);
|
|
|
+ error+=singleUnAudit(prodInOutDTO);
|
|
|
+ }
|
|
|
+ if(error!=null&&!error.equals("")){
|
|
|
+ new BizException(501,error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Integer deleteItem(Long id) {
|
|
|
ProdIODetail prodIODetail = prodIODetailMapper.selectByPrimaryKey(id);
|
|
|
- ProdInOut prodInOut = getMapper().selectByPrimaryKey(prodIODetail.getPd_piid());
|
|
|
+ ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(prodIODetail.getPd_piid());
|
|
|
Integer num = prodIODetailMapper.deleteByPrimaryKey(id);
|
|
|
//更新已转数
|
|
|
updateYqty(prodInOut);
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
|
|
|
+ //日志
|
|
|
+ messageLogService.deleteDetail(docBaseDTO);
|
|
|
return num;
|
|
|
}
|
|
|
@Override
|
|
|
public void batchDelete(BatchDealBaseDTO baseDTOs) {
|
|
|
if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
|
|
|
- baseDTOs.getBaseDTOs().size() == 0)
|
|
|
+ baseDTOs.getBaseDTOs().size() == 0) {
|
|
|
return;
|
|
|
+ }
|
|
|
for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
|
|
|
singleDelete(base.getId());
|
|
|
}
|
|
|
-// Integer num = saledetailMapper.deleteByPrimaryKey(id);
|
|
|
-// DocBaseDTO docBaseDTO = getBaseDTOById(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -273,6 +361,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
if (null == sourcePi || StringUtils.isEmpty(sourcePi.getPi_inoutno()) || sourceDetails.size() == 0) {
|
|
|
throw new BizException(BizExceptionCode.SALE_NULL_BILL);
|
|
|
}
|
|
|
+
|
|
|
+ //检查转单状态
|
|
|
+ String statuscode = sourcePi.getPi_statuscode();
|
|
|
+ if(!Status.UNAUDITED.name().equals(statuscode)){
|
|
|
+ throw new BizException(BizExceptionCode.SALEOUT_POSTSTATUS_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
//检查从表
|
|
|
for (ProdIODetail prodIODetail : sourceDetails) {
|
|
|
pdOutqty = prodIODetail.getPd_outqty()==null?0.0:prodIODetail.getPd_outqty();
|
|
|
@@ -288,19 +383,20 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
//插入销售退货单主表
|
|
|
ProdInOut targetPi = new ProdInOut();
|
|
|
//生成单号
|
|
|
- String piInoutno = maxnumberService.getMaxnumber("ProdInOut!Sale",true).getData();
|
|
|
+ String piInoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
|
|
|
targetPi.setPi_inoutno(piInoutno);
|
|
|
- targetPi.setPi_class("销售退货单");
|
|
|
+ targetPi.setPi_class(BillCodeSeq.SALEIN.getName());
|
|
|
targetPi.setPi_date(new Date());
|
|
|
targetPi.setPi_recorddate(new Date());
|
|
|
+ targetPi.setPi_status(Status.UNAUDITED.getDisplay());
|
|
|
+ targetPi.setPi_statuscode(Status.UNAUDITED.name());
|
|
|
//客户信息
|
|
|
targetPi.setPi_custid(sourcePi.getPi_custid());
|
|
|
targetPi.setPi_custcode(sourcePi.getPi_custcode());
|
|
|
targetPi.setPi_custname(sourcePi.getPi_custname());
|
|
|
- targetPi.setPi_status("未审核");
|
|
|
- targetPi.setPi_statuscode("UNAUDITED");
|
|
|
- targetPi.setPi_sacode(sourcePi.getPi_sacode());
|
|
|
targetPi.setPi_said(sourcePi.getPi_said());
|
|
|
+ targetPi.setPi_sacode(sourcePi.getPi_sacode());
|
|
|
+
|
|
|
//设置公司id
|
|
|
targetPi.setCompanyId(sourcePi.getCompanyId());
|
|
|
//保存数据
|
|
|
@@ -315,15 +411,15 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
if(pdOutqty-pdYqty>0){
|
|
|
targetPid.setPd_piid(pi_id);
|
|
|
targetPid.setPd_inoutno(piInoutno);
|
|
|
- targetPid.setPd_piclass("销售退货单");
|
|
|
+ targetPid.setPd_piclass(BillCodeSeq.SALEIN.getName());
|
|
|
targetPid.setPd_pdno(i);
|
|
|
targetPid.setPd_orderid(sourcePid.getPd_orderid());
|
|
|
targetPid.setPd_ordercode(sourcePid.getPd_ordercode());
|
|
|
targetPid.setPd_orderdetno(sourcePid.getPd_orderdetno());
|
|
|
|
|
|
+ targetPid.setPd_sdid(sourcePid.getPd_sdid());
|
|
|
targetPid.setPd_sendprice(sourcePid.getPd_sendprice());
|
|
|
|
|
|
- targetPid.setPd_sdid(sourcePid.getPd_sdid());
|
|
|
|
|
|
targetPid.setPd_prodid(sourcePid.getPd_prodid());
|
|
|
targetPid.setPd_prodcode(sourcePid.getPd_prodcode());
|
|
|
@@ -343,6 +439,77 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
return Result.success();
|
|
|
|
|
|
}
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void close(long id) {
|
|
|
+ ProdInOut prodInOut = new ProdInOut();
|
|
|
+ prodInOut.setId(id);
|
|
|
+ prodInOut.setPi_status(Status.CLOSE.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.CLOSE.name());
|
|
|
+
|
|
|
+ prodInOutMapper.updateByPrimaryKeySelective(prodInOut);
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
|
|
|
+ //日志
|
|
|
+ messageLogService.close(docBaseDTO);
|
|
|
+ }
|
|
|
+ public void batchClose(BatchDealBaseDTO baseDTOs){
|
|
|
+ if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
|
|
|
+ baseDTOs.getBaseDTOs().size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void open(Long id){
|
|
|
+ ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
|
|
|
+ List<ProdIODetail> prodIODetailList = prodIODetailMapper.selectByFK(id);
|
|
|
+ //部分入库、全部入库
|
|
|
+ int partTurnCount = 0,turnCount = 0;
|
|
|
+ Double yqty=0.0,qty=0.0;
|
|
|
+ Boolean isIn = false;
|
|
|
+ if(BillCodeSeq.SALEIN.getName().equals(prodInOut.getPi_class())){
|
|
|
+ isIn=true;
|
|
|
+ }
|
|
|
+ if(prodIODetailList!=null&&prodIODetailList.size()>0){
|
|
|
+ for (ProdIODetail prodiodetail :prodIODetailList){
|
|
|
+ yqty = prodiodetail.getPd_yqty() ==null?0.0:prodiodetail.getPd_yqty();
|
|
|
+ if(isIn){
|
|
|
+ qty = prodiodetail.getPd_inqty() ==null?0.0:prodiodetail.getPd_yqty();
|
|
|
+ }else{
|
|
|
+ qty = prodiodetail.getPd_outqty() ==null?0.0:prodiodetail.getPd_outqty();
|
|
|
+ }
|
|
|
+ if(yqty >= qty){
|
|
|
+ turnCount++;
|
|
|
+ }else if(yqty>0&&yqty<qty){
|
|
|
+ partTurnCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(partTurnCount>0){
|
|
|
+ if(isIn){
|
|
|
+ prodInOut.setPi_status(Status.PART2IN.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.PART2IN.name());
|
|
|
+ }else {
|
|
|
+ prodInOut.setPi_status(Status.PARTOUT.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.PARTOUT.name());
|
|
|
+ }
|
|
|
+ }else if(turnCount == prodIODetailList.size()){
|
|
|
+ if(isIn){
|
|
|
+ prodInOut.setPi_status(Status.TURNIN.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.TURNIN.name());
|
|
|
+ }else {
|
|
|
+ prodInOut.setPi_status(Status.TURNOUT.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.TURNOUT.name());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ prodInOut.setPi_status(Status.AUDITED.getDisplay());
|
|
|
+ prodInOut.setPi_statuscode(Status.AUDITED.getDisplay());
|
|
|
+ }
|
|
|
+ prodInOutMapper.updateByPrimaryKeySelective(prodInOut);
|
|
|
+ DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
|
|
|
+ //记录日志
|
|
|
+ messageLogService.open(docBaseDTO);
|
|
|
+ }
|
|
|
/**
|
|
|
* @Description: 检验获取并更新单号
|
|
|
* @Param: [code, id]
|
|
|
@@ -354,13 +521,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
if (null == code) {
|
|
|
throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
}
|
|
|
- Integer count = "0".equals(String.valueOf(id)) ? saleMapper.validateCodeWhenInsert(code) :
|
|
|
- saleMapper.validateCodeWhenUpdate(code, id);
|
|
|
- String caller = "";
|
|
|
+ Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
|
|
|
+ prodInOutMapper.validateCodeWhenUpdate(code, id);
|
|
|
+ String caller ="";
|
|
|
if(pi_class.equals("销售出货单")){
|
|
|
- caller = "ProdInOut!Sale";
|
|
|
+ caller = BillCodeSeq.SALEOUT.getCaller();
|
|
|
}else {//销售退货单
|
|
|
- caller = "ProdInOut!SaleReturn";
|
|
|
+ caller = BillCodeSeq.SALEIN.getCaller();
|
|
|
}
|
|
|
return maxnumberService.pushMaxnubmer(count, code, caller).getData();
|
|
|
}
|
|
|
@@ -374,9 +541,37 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
private void updateYqty(ProdInOut prodInOut) {
|
|
|
//更新已转数
|
|
|
if ("销售出货单".equals(prodInOut.getPi_class())){
|
|
|
- //saledetailMapper.updateSaleOutYqty(prodInOut.getPi_puid());
|
|
|
+ prodIODetailMapper.updateSaleYqty(prodInOut.getPi_said());
|
|
|
}else if ("销售退货单".equals(prodInOut.getPi_class())){
|
|
|
prodIODetailMapper.updateSaleOutYqty(prodInOut.getPi_said());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description
|
|
|
+ * @Param: [id]
|
|
|
+ * @return: com.usoftchina.saas.commons.dto.DocBaseDTO
|
|
|
+ * @Author: wuyx
|
|
|
+ * @Date: 2018/10/25
|
|
|
+ */
|
|
|
+ private DocBaseDTO getBaseDTOById(Long id,String pi_class) {
|
|
|
+ if (null == id) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String caller = BillCodeSeq.SALEIN.getName().equals(pi_class)?BillCodeSeq.SALEIN.getCaller():BillCodeSeq.SALEOUT.getCaller();
|
|
|
+ String code = prodInOutMapper.selectCodeById(id);
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
+ baseDTO.setId(id);
|
|
|
+ baseDTO.setCode(code);
|
|
|
+ baseDTO.setName(caller);
|
|
|
+ return baseDTO;
|
|
|
+ }
|
|
|
+ //更新最新明细总额
|
|
|
+ private void getTotal(Long id,String pi_class) {
|
|
|
+ if(BillCodeSeq.SALEOUT.getName().equals(pi_class)){
|
|
|
+ prodIODetailMapper.updatePDSaleOut(id);
|
|
|
+ }else{
|
|
|
+ prodIODetailMapper.updatePDSaleIN(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|