|
|
@@ -30,6 +30,7 @@ import com.usoftchina.saas.purchase.service.ProdInOutService;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -112,7 +113,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED)
|
|
|
public DocBaseDTO saveFormData(ProdInOutFormDTO formdata) {
|
|
|
if (null == formdata || null == formdata.getMain()){
|
|
|
throw new BizException(500, "数据为空,请填写后再保存");
|
|
|
@@ -120,8 +121,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
//公司ID
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
//人员Id
|
|
|
- Map<String,Object> emp= employeeApi.getEmployeeByAccount();
|
|
|
- Long userId = Long.valueOf(String.valueOf(emp.get("em_id")));
|
|
|
+ Long userId = BaseContextHolder.getUserId();
|
|
|
|
|
|
//获取主表信息
|
|
|
ProdInOutDTO main = formdata.getMain();
|
|
|
@@ -137,14 +137,17 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
|
|
|
prodInOut.setCompanyId(companyId);
|
|
|
prodInOut.setPi_recordmanid(userId.intValue());
|
|
|
- prodInOut.setPi_recordman(emp.get("em_name").toString());
|
|
|
+// prodInOut.setPi_recordman(emp.get("em_name").toString());
|
|
|
prodInOut.setCreatorId(userId);
|
|
|
prodInOut.setCreateTime(new Date());
|
|
|
prodInOut.setPi_date(new Date());
|
|
|
prodInOut.setPi_puid(main.getPi_puid());
|
|
|
prodInOut.setPi_pucode(main.getPi_pucode());
|
|
|
+ baseDTO.setCode(pi_inoutno);
|
|
|
+ baseDTO.setId(pi_id);
|
|
|
+ baseDTO.setName(pi_class);
|
|
|
//编号获取
|
|
|
- pi_inoutno = pushMaxnubmer(prodInOut);
|
|
|
+ pi_inoutno = pushMaxnubmer(baseDTO);
|
|
|
prodInOut.setPi_inoutno(pi_inoutno);
|
|
|
|
|
|
//判断更新与保存动作
|
|
|
@@ -225,6 +228,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
singleDelete(id);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED)
|
|
|
private void singleDelete(Long id) {
|
|
|
|
|
|
ProdInOut prodInOut = checkAndReturnOrder(id);;
|
|
|
@@ -241,13 +245,12 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
public DocBaseDTO audit(ProdInOutFormDTO formData) {
|
|
|
Long id = null;
|
|
|
DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
if (null != formData) {
|
|
|
id = formData.getMain().getId();
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
+ if (StringUtils.isEmpty(id) ||"0".equals(String.valueOf(id))) {
|
|
|
baseDTO = saveFormData(formData);
|
|
|
id = baseDTO.getId();
|
|
|
}
|
|
|
@@ -257,6 +260,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED)
|
|
|
private void singleAudit(ProdInOutDTO prodInOutDTO) {
|
|
|
String pi_class= prodInOutDTO.getPi_class();
|
|
|
String pi_inoutno = prodInOutDTO.getPi_inoutno();
|
|
|
@@ -428,7 +432,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
//插入验退单主表
|
|
|
ProdInOut targetPi = new ProdInOut();
|
|
|
//生成单号
|
|
|
- String piInoutno = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASEOUT.getCaller(),true).getData();
|
|
|
+ String piInoutno = getMaxnumber(BillCodeSeq.PURCHASEOUT);
|
|
|
targetPi.setPi_inoutno(piInoutno);
|
|
|
targetPi.setPi_class(BillCodeSeq.PURCHASEOUT.getName());
|
|
|
targetPi.setPi_date(new Date());
|
|
|
@@ -546,7 +550,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
return docBaseDTO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public DocBaseDTO open(long id) {
|
|
|
return singleOpen(id);
|
|
|
@@ -575,26 +578,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public String pushMaxnubmer(ProdInOut prodInOut) {
|
|
|
- String pi_inoutno = prodInOut.getPi_inoutno();
|
|
|
- String pi_class = prodInOut.getPi_class();
|
|
|
- Long id = prodInOut.getId();
|
|
|
- if (null == pi_inoutno) {
|
|
|
- throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
- }
|
|
|
- Long companyId = BaseContextHolder.getCompanyId();
|
|
|
- Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
|
|
|
- getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
|
|
|
- String caller ="";
|
|
|
- if("采购验收单".equals(pi_class)){
|
|
|
- caller = BillCodeSeq.PURCHASEIN.getCaller();
|
|
|
- }else if("采购验退单".equals(pi_class)) {
|
|
|
- caller = BillCodeSeq.PURCHASEOUT.getCaller();
|
|
|
- }
|
|
|
- return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void getDefaultWarehouseByProduct(Long pi_id) {
|
|
|
@@ -613,5 +596,29 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
|
|
|
return prodInOut;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getMaxnumber(BillCodeSeq bill) {
|
|
|
+ String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
|
|
|
+ DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
|
|
|
+ return pushMaxnubmer(base);
|
|
|
+ }
|
|
|
|
|
|
+ public synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
|
|
|
+ String pi_inoutno = baseDTO.getCode();
|
|
|
+ String pi_class = baseDTO.getName();
|
|
|
+ Long id = baseDTO.getId();
|
|
|
+ if (null == pi_inoutno) {
|
|
|
+ throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
+ }
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
|
|
|
+ getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
|
|
|
+ String caller ="";
|
|
|
+ if("采购验收单".equals(pi_class)){
|
|
|
+ caller = BillCodeSeq.PURCHASEIN.getCaller();
|
|
|
+ }else if("采购验退单".equals(pi_class)) {
|
|
|
+ caller = BillCodeSeq.PURCHASEOUT.getCaller();
|
|
|
+ }
|
|
|
+ return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
|
|
|
+ }
|
|
|
}
|