|
@@ -10,6 +10,7 @@ import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
|
|
import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocSavedDTO;
|
|
import com.usoftchina.saas.commons.dto.DocSavedDTO;
|
|
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.document.api.ProductApi;
|
|
import com.usoftchina.saas.document.api.ProductApi;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
import com.usoftchina.saas.exception.BizException;
|
|
@@ -43,8 +44,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
private PurchasedetailMapper purchasedetailMapper;
|
|
private PurchasedetailMapper purchasedetailMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PurchaseListMapper purchaseListMapper;
|
|
private PurchaseListMapper purchaseListMapper;
|
|
|
- @Autowired
|
|
|
|
|
- private ProductApi productApi;
|
|
|
|
|
|
|
+ /* @Autowired
|
|
|
|
|
+ private ProductApi productApi;*/
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MaxnumberService maxnumberService;
|
|
private MaxnumberService maxnumberService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -112,48 +113,48 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
purchase.setPu_code(pu_code);
|
|
purchase.setPu_code(pu_code);
|
|
|
saveDTO.setCode(pu_code);
|
|
saveDTO.setCode(pu_code);
|
|
|
//判断更新与保存动作
|
|
//判断更新与保存动作
|
|
|
- if (!StringUtils.isEmpty(pu_id)) {
|
|
|
|
|
- //更新主表
|
|
|
|
|
- purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(pu_id) || "0".equals(pu_id.toString())) {
|
|
|
|
|
+ //插入操作
|
|
|
|
|
+ purchaseMapper.insertSelective(purchase);
|
|
|
|
|
+ pu_id = purchase.getId();
|
|
|
//添加从表传输对象
|
|
//添加从表传输对象
|
|
|
for (PurchaseDetailDTO item : items) {
|
|
for (PurchaseDetailDTO item : items) {
|
|
|
PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
|
|
PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
|
|
|
detail.setPd_puid(pu_id);
|
|
detail.setPd_puid(pu_id);
|
|
|
detail.setPd_code(pu_code);
|
|
detail.setPd_code(pu_code);
|
|
|
- if (!StringUtils.isEmpty(detail.getId())) {
|
|
|
|
|
- updateDetails.add(detail);
|
|
|
|
|
- } else {
|
|
|
|
|
- insertDetails.add(detail);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ insertDetails.add(detail);
|
|
|
}
|
|
}
|
|
|
//插入从表
|
|
//插入从表
|
|
|
if (insertDetails.size() > 0) {
|
|
if (insertDetails.size() > 0) {
|
|
|
purchasedetailMapper.batchInsert(insertDetails);
|
|
purchasedetailMapper.batchInsert(insertDetails);
|
|
|
}
|
|
}
|
|
|
- //更新从表
|
|
|
|
|
- if (updateDetails.size() > 0) {
|
|
|
|
|
- purchasedetailMapper.batchUpdate(updateDetails);
|
|
|
|
|
- }
|
|
|
|
|
saveDTO.setId(pu_id);
|
|
saveDTO.setId(pu_id);
|
|
|
return saveDTO;
|
|
return saveDTO;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //插入操作
|
|
|
|
|
- purchaseMapper.insertSelective(purchase);
|
|
|
|
|
- pu_id = purchase.getId();
|
|
|
|
|
|
|
+ //更新操作
|
|
|
|
|
+ purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
|
//添加从表传输对象
|
|
//添加从表传输对象
|
|
|
for (PurchaseDetailDTO item : items) {
|
|
for (PurchaseDetailDTO item : items) {
|
|
|
PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
|
|
PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
|
|
|
detail.setPd_puid(pu_id);
|
|
detail.setPd_puid(pu_id);
|
|
|
detail.setPd_code(pu_code);
|
|
detail.setPd_code(pu_code);
|
|
|
- insertDetails.add(detail);
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
|
|
|
|
|
+ insertDetails.add(detail);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ updateDetails.add(detail);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//插入从表
|
|
//插入从表
|
|
|
if (insertDetails.size() > 0) {
|
|
if (insertDetails.size() > 0) {
|
|
|
purchasedetailMapper.batchInsert(insertDetails);
|
|
purchasedetailMapper.batchInsert(insertDetails);
|
|
|
}
|
|
}
|
|
|
|
|
+ //更新从表
|
|
|
|
|
+ if (updateDetails.size() > 0) {
|
|
|
|
|
+ purchasedetailMapper.batchUpdate(updateDetails);
|
|
|
|
|
+ }
|
|
|
saveDTO.setId(pu_id);
|
|
saveDTO.setId(pu_id);
|
|
|
return saveDTO;
|
|
return saveDTO;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -172,7 +173,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
DocSavedDTO savedDTO = new DocSavedDTO();
|
|
DocSavedDTO savedDTO = new DocSavedDTO();
|
|
|
if (null != formData) {
|
|
if (null != formData) {
|
|
|
id = formData.getMain().getId();
|
|
id = formData.getMain().getId();
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(id) || "0".equals(String.valueOf(id))) {
|
|
|
DocSavedDTO saveDTO = saveFormData(formData);
|
|
DocSavedDTO saveDTO = saveFormData(formData);
|
|
|
id = saveDTO.getId();
|
|
id = saveDTO.getId();
|
|
|
}
|
|
}
|
|
@@ -374,7 +375,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
//更新存在字段
|
|
//更新存在字段
|
|
|
purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
|
//更新最新采购单价
|
|
//更新最新采购单价
|
|
|
- productApi.updateLatestPurchasePrice(id);
|
|
|
|
|
|
|
+ //productApi.updateLatestPurchasePrice(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void singleUnAudit(Long id) {
|
|
private void singleUnAudit(Long id) {
|
|
@@ -416,8 +417,11 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
* @Date: 2018/10/19
|
|
* @Date: 2018/10/19
|
|
|
*/
|
|
*/
|
|
|
private String pushMaxnubmer(String code, Long id) {
|
|
private String pushMaxnubmer(String code, Long id) {
|
|
|
- Integer count = id != null ? purchaseMapper.validateCodeWhenUpdate(code, id) :
|
|
|
|
|
- purchaseMapper.validateCodeWhenInsert(code);
|
|
|
|
|
|
|
+ if (null == code) {
|
|
|
|
|
+ throw new BizException(BizExceptionCode.NULL_CODE);
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer count = "0".equals(String.valueOf(id)) ? purchaseMapper.validateCodeWhenInsert(code) :
|
|
|
|
|
+ purchaseMapper.validateCodeWhenUpdate(code, id);
|
|
|
return maxnumberService.pushMaxnubmer(count, code, "Purchase");
|
|
return maxnumberService.pushMaxnubmer(count, code, "Purchase");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|