|
|
@@ -108,10 +108,11 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DocSavedDTO saveFormData(VerificationFormDTO formdata) {
|
|
|
+ public DocBaseDTO saveFormData(VerificationFormDTO formdata) {
|
|
|
if (null == formdata || null == formdata.getMain()){
|
|
|
throw new BizException(BizExceptionCode.EMPTY_DATA);
|
|
|
}
|
|
|
+
|
|
|
//公司ID
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
//人员Id
|
|
|
@@ -122,100 +123,71 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
List<VerificationdetDTO> items1 = formdata.getItems1();
|
|
|
//获取从表2
|
|
|
List<VerificationdetailDTO> items2 = formdata.getItems2();
|
|
|
- //插入从表数据
|
|
|
- List<Verificationdet> insertDetails1 = new ArrayList<>();
|
|
|
- List<Verificationdetail> insertDetails2 = new ArrayList<>();
|
|
|
- //更新从表数据
|
|
|
- List<Verificationdet> updateDetails1 = new ArrayList<>();
|
|
|
- List<Verificationdetail> updateDetails2 = new ArrayList<>();
|
|
|
- DocSavedDTO saveDTO = new DocSavedDTO();
|
|
|
+
|
|
|
+ DocBaseDTO baseDTO = null;
|
|
|
Long id = main.getId();
|
|
|
String code = main.getVc_code();
|
|
|
- Verification verification = BeanMapper.map(main,Verification.class);
|
|
|
- verification.setCompanyId(companyId);
|
|
|
- verification.setCreatorId(userId);
|
|
|
- verification.setCreateTime(new Date());
|
|
|
- String kind = verification.getVc_kind();
|
|
|
- verification.setVc_kind(transferKind(kind));
|
|
|
+ //编号校验
|
|
|
+ code = pushMaxnubmer(code, id);
|
|
|
+ main.setVc_code(code);
|
|
|
|
|
|
- //编号获取
|
|
|
- code = pushMaxnubmer(code,id);
|
|
|
- verification.setVc_code(code);
|
|
|
- saveDTO.setCode(code);
|
|
|
+ Verification verification = BeanMapper.map(main,Verification.class);
|
|
|
+ if(id.longValue() > 0 ){
|
|
|
+ String kind = verification.getVc_kind();
|
|
|
+ verification.setVc_kind(transferKind(kind));
|
|
|
+ verificationMapper.updateByPrimaryKey(verification);
|
|
|
+ baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
|
|
|
+ if (!("AUDITED".equals(verification.getVc_statuscode()))) {
|
|
|
+ //日志记录
|
|
|
+ messageLogService.update(baseDTO);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ verification.setCompanyId(companyId);
|
|
|
+ verification.setVc_recorder(BaseContextHolder.getUserName());
|
|
|
+ verification.setCreateTime(new Date());
|
|
|
+ verification.setCreatorId(userId);
|
|
|
+ verification.setCreatorName(BaseContextHolder.getUserName());
|
|
|
+ String kind = verification.getVc_kind();
|
|
|
+ verification.setVc_kind(transferKind(kind));
|
|
|
+ verificationMapper.insertSelective(verification);
|
|
|
+ id = verification.getId();
|
|
|
+ baseDTO = new DocBaseDTO(id, code, BillCodeSeq.VERIFICATION.getCaller());
|
|
|
+ if (!("AUDITED".equals(verification.getVc_statuscode()))) {
|
|
|
+ //日志记录
|
|
|
+ messageLogService.save(baseDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYYMM");
|
|
|
String dateYM = simpleDateFormat.format(verification.getVc_date());
|
|
|
Integer numberYM = Integer.valueOf(dateYM);
|
|
|
//判断更新与保存动作
|
|
|
- if (StringUtils.isEmpty(id) || "0".equals(id.toString())){
|
|
|
- //插入操作
|
|
|
- getMapper().insertSelective(verification);
|
|
|
- id = verification.getId();
|
|
|
-
|
|
|
- //添加从表传输对象
|
|
|
- for (VerificationdetDTO item : items1) {
|
|
|
- Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
|
|
|
- detail.setVd_vcid(id);
|
|
|
- detail.setCompanyId(companyId);
|
|
|
- detail.setVd_ym(numberYM);
|
|
|
- insertDetails1.add(detail);
|
|
|
- }
|
|
|
- for (VerificationdetailDTO item : items2) {
|
|
|
- Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
|
|
|
- detail.setVcd_vcid(id);
|
|
|
- detail.setVcd_ym(numberYM);
|
|
|
- detail.setCompanyId(companyId);
|
|
|
- insertDetails2.add(detail);
|
|
|
- }
|
|
|
- //插入从表
|
|
|
- if (insertDetails1.size()>0) {
|
|
|
- verificationdetMapper.batchInsert(insertDetails1);
|
|
|
- }
|
|
|
- if (insertDetails2.size()>0) {
|
|
|
- verificationdetailMapper.batchInsert(insertDetails2);
|
|
|
- }
|
|
|
- }
|
|
|
- //更新操作
|
|
|
- getMapper().updateByPrimaryKeySelective(verification);
|
|
|
//添加从表传输对象
|
|
|
for (VerificationdetDTO item : items1) {
|
|
|
- Verificationdet detail = BeanMapper.map(item, Verificationdet.class);
|
|
|
+ Verificationdet detail = BeanMapper.map(item,Verificationdet.class);
|
|
|
+ Long vd_id = detail.getId();
|
|
|
detail.setVd_vcid(id);
|
|
|
- detail.setVd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
- if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
|
|
|
- insertDetails1.add(detail);
|
|
|
- } else {
|
|
|
- updateDetails1.add(detail);
|
|
|
+ detail.setVd_ym(numberYM);
|
|
|
+ if (vd_id>0){
|
|
|
+ verificationdetMapper.updateByPrimaryKey(detail);
|
|
|
+ }else{
|
|
|
+ verificationdetMapper.insertSelective(detail);
|
|
|
}
|
|
|
}
|
|
|
for (VerificationdetailDTO item : items2) {
|
|
|
- Verificationdetail detail = BeanMapper.map(item, Verificationdetail.class);
|
|
|
+ Verificationdetail detail = BeanMapper.map(item,Verificationdetail.class);
|
|
|
detail.setVcd_vcid(id);
|
|
|
detail.setVcd_ym(numberYM);
|
|
|
detail.setCompanyId(companyId);
|
|
|
- if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
|
|
|
- insertDetails2.add(detail);
|
|
|
- } else {
|
|
|
- updateDetails2.add(detail);
|
|
|
+ Long vcd_id = detail.getId();
|
|
|
+ if(vcd_id>0){
|
|
|
+ verificationdetailMapper.updateByPrimaryKey(detail);
|
|
|
+ }else{
|
|
|
+ verificationdetailMapper.insertSelective(detail);
|
|
|
}
|
|
|
}
|
|
|
- //插入从表
|
|
|
- if (insertDetails1.size()>0) {
|
|
|
- verificationdetMapper.batchInsert(insertDetails1);
|
|
|
- }
|
|
|
- if (insertDetails2.size()>0) {
|
|
|
- verificationdetailMapper.batchInsert(insertDetails2);
|
|
|
- }
|
|
|
- //更新从表
|
|
|
- if (updateDetails1.size()>0) {
|
|
|
- verificationdetMapper.batchUpdate(updateDetails1);
|
|
|
- }
|
|
|
- if (updateDetails2.size()>0) {
|
|
|
- verificationdetailMapper.batchUpdate(updateDetails2);
|
|
|
- }
|
|
|
updateCorrespondingData(formdata);
|
|
|
- saveDTO.setId(id);
|
|
|
- return saveDTO;
|
|
|
+ return baseDTO;
|
|
|
}
|
|
|
|
|
|
private void updateCorrespondingData(VerificationFormDTO formdata) {
|
|
|
@@ -301,17 +273,18 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
subledger.setSl_custid(verification.getVc_custid());
|
|
|
subledger.setSl_vendid(0);
|
|
|
}
|
|
|
-
|
|
|
+ Double amount1 = verification.getVc_amount1()==null?new Double(0):verification.getVc_amount1();
|
|
|
+ Double amount2 = verification.getVc_amount2()==null?new Double(0):verification.getVc_amount2();
|
|
|
subledger.setSl_date(verification.getVc_date());
|
|
|
- subledger.setSl_amount(-verification.getVc_amount2());
|
|
|
+ subledger.setSl_amount(-amount2);
|
|
|
subledger.setSl_orderamount(new Double(0));
|
|
|
subledger.setSl_yamount(new Double(0));
|
|
|
subledger.setSl_remark(verification.getVc_remark());
|
|
|
subledger.setSl_discount(new Double(0));
|
|
|
if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable")){
|
|
|
- subledger.setSl_preamount(-verification.getVc_amount1());
|
|
|
+ subledger.setSl_preamount(-amount1);
|
|
|
}else{
|
|
|
- subledger.setSl_preamount(new Double(0));
|
|
|
+ subledger.setSl_preamount(amount1);
|
|
|
}
|
|
|
return subledger;
|
|
|
}
|
|
|
@@ -320,10 +293,10 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
* @param id
|
|
|
* @param nowBalance
|
|
|
*/
|
|
|
- private void updateAuditSubledeger(int id , Double nowBalance){
|
|
|
- Subledger subledger = subledgerMapper.selectByPrimaryKey(id);
|
|
|
+ private void updateAuditSubledeger(Long id , Double nowBalance){
|
|
|
+ Subledger subledger = subledgerMapper.selectByPrimaryKey(Math.toIntExact(id));
|
|
|
Subledger newSubledeger = new Subledger();
|
|
|
- newSubledeger.setId(Long.valueOf(String.valueOf(id)));
|
|
|
+ newSubledeger.setSl_id(id);
|
|
|
Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()-nowBalance;
|
|
|
Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()+nowBalance;
|
|
|
newSubledeger.setSl_yamount(newYamout);
|
|
|
@@ -370,7 +343,17 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
return "应收转应收";
|
|
|
case "payable_to_payable":
|
|
|
return "应付转应付";
|
|
|
- default:return "";
|
|
|
+ case "预收冲应收":
|
|
|
+ return "receipts_offset_receivable";
|
|
|
+ case "预付冲应付":
|
|
|
+ return "prepaid_offset_payable";
|
|
|
+ case "应收冲应付":
|
|
|
+ return "receivable_offset_payable";
|
|
|
+ case "应收转应收":
|
|
|
+ return "receivable_to_receivable";
|
|
|
+ case "应付转应付":
|
|
|
+ return "payable_to_payable";
|
|
|
+ default: return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -418,13 +401,13 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
@Override
|
|
|
public void deleteDetail1(Long id) {
|
|
|
if (null != id) {
|
|
|
- verificationdetMapper.deleteByParentPrimaryKey(Long.valueOf(String.valueOf(id)));
|
|
|
Verificationdet verificationdet = verificationdetMapper.selectByPrimaryKey(Integer.valueOf(String.valueOf(id)));
|
|
|
Verification verification = verificationMapper.selectByPrimaryKey(verificationdet.getVd_vcid());
|
|
|
DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
baseDTO.setId(id);
|
|
|
baseDTO.setCode(verification.getVc_code());
|
|
|
baseDTO.setName(BillCodeSeq.VERIFICATION.getName());
|
|
|
+ verificationdetMapper.deleteByParentPrimaryKey(Long.valueOf(String.valueOf(id)));
|
|
|
//日志
|
|
|
messageLogService.deleteDetail(baseDTO);
|
|
|
}
|
|
|
@@ -446,14 +429,14 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DocSavedDTO audit(VerificationFormDTO formData) {
|
|
|
+ public DocBaseDTO audit(VerificationFormDTO formData) {
|
|
|
Long id = null;
|
|
|
- DocSavedDTO savedDTO = new DocSavedDTO();
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
if (null != formData) {
|
|
|
- id = Long.valueOf(String.valueOf(formData.getMain().getVc_id()));
|
|
|
+ id = formData.getMain().getId();
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
- DocSavedDTO saveDTO = saveFormData(formData);
|
|
|
- id = saveDTO.getId();
|
|
|
+ baseDTO = saveFormData(formData);
|
|
|
+ id = baseDTO.getId();
|
|
|
}
|
|
|
Verification verification = new Verification();
|
|
|
verification.setVc_status(Status.AUDITED.getDisplay());
|
|
|
@@ -484,8 +467,8 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
|
|
|
}
|
|
|
}
|
|
|
- savedDTO.setId(id);
|
|
|
- return savedDTO;
|
|
|
+ baseDTO.setId(id);
|
|
|
+ return baseDTO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -669,7 +652,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
|
|
|
}
|
|
|
|
|
|
//更新客户或者供应商的金额
|
|
|
- Verification nowverification = verificationMapper.selectByPrimaryKey(id);
|
|
|
+ Verification nowverification = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
|
|
|
VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
|
|
|
updateResAuditCustomer(verificationDTO);
|
|
|
updateResAuditVendor(verificationDTO);
|