|
@@ -7,6 +7,8 @@ import com.zjugis.business.bean.entity.*;
|
|
import com.zjugis.business.constants.DictConstants;
|
|
import com.zjugis.business.constants.DictConstants;
|
|
import com.zjugis.business.constants.FlowStatusConstants;
|
|
import com.zjugis.business.constants.FlowStatusConstants;
|
|
import com.zjugis.business.converter.common.SelectConvert;
|
|
import com.zjugis.business.converter.common.SelectConvert;
|
|
|
|
+import com.zjugis.business.converter.contract.ContractConvert;
|
|
|
|
+import com.zjugis.business.flow.contractinvoice.controller.vo.ContractInvoiceVO;
|
|
import com.zjugis.business.mapper.ContractInvoiceMapper;
|
|
import com.zjugis.business.mapper.ContractInvoiceMapper;
|
|
import com.zjugis.business.service.*;
|
|
import com.zjugis.business.service.*;
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
@@ -67,12 +69,12 @@ public class FlowContractInvoiceService {
|
|
@Autowired
|
|
@Autowired
|
|
AdminUserApi adminUserApi;
|
|
AdminUserApi adminUserApi;
|
|
|
|
|
|
- public Map<String, Object> getFormParams(String flowInstanceId,Integer isKp) {
|
|
|
|
|
|
+ public Map<String, Object> getFormParams(String flowInstanceId, Integer isKp) {
|
|
String userId = SecurityFrameworkUtils.getLoginUserId();
|
|
String userId = SecurityFrameworkUtils.getLoginUserId();
|
|
CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(flowInstanceId);
|
|
CommonResult<IFlowInstance> flowResult = workflowClient.flowInstance(flowInstanceId);
|
|
- if(flowResult.isSuccess()){
|
|
|
|
|
|
+ if (flowResult.isSuccess()) {
|
|
ContractInvoice entity = contractInvoiceService.selectByInstanceId(flowInstanceId);
|
|
ContractInvoice entity = contractInvoiceService.selectByInstanceId(flowInstanceId);
|
|
- if(Objects.isNull(entity)){
|
|
|
|
|
|
+ if (Objects.isNull(entity)) {
|
|
entity = new ContractInvoice();
|
|
entity = new ContractInvoice();
|
|
entity.setInstanceId(flowInstanceId);
|
|
entity.setInstanceId(flowInstanceId);
|
|
entity.setWorkerId(userId);
|
|
entity.setWorkerId(userId);
|
|
@@ -84,11 +86,11 @@ public class FlowContractInvoiceService {
|
|
entity.setApplyWorkerDeptId(result.getCheckedData().getDeptId());
|
|
entity.setApplyWorkerDeptId(result.getCheckedData().getDeptId());
|
|
contractInvoiceService.insert(entity);
|
|
contractInvoiceService.insert(entity);
|
|
}
|
|
}
|
|
- if(isKp != null && isKp == 1){
|
|
|
|
- if(entity.getInvoiceDate() == null){
|
|
|
|
|
|
+ if (isKp != null && isKp == 1) {
|
|
|
|
+ if (entity.getInvoiceDate() == null) {
|
|
entity.setInvoiceDate(LocalDate.now());
|
|
entity.setInvoiceDate(LocalDate.now());
|
|
}
|
|
}
|
|
- if(StringUtils.isNotBlank(userId) && StringUtils.isBlank(entity.getInvoicePersonId())){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(userId) && StringUtils.isBlank(entity.getInvoicePersonId())) {
|
|
CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(userId);
|
|
CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(userId);
|
|
entity.setInvoicePerson(user.getCheckedData().getNickname());
|
|
entity.setInvoicePerson(user.getCheckedData().getNickname());
|
|
entity.setInvoicePersonId(userId);
|
|
entity.setInvoicePersonId(userId);
|
|
@@ -105,31 +107,31 @@ public class FlowContractInvoiceService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
- private Map<String, Object> createMap(ContractInvoice entity) {
|
|
|
|
|
|
+ private Map<String, Object> createMap(ContractInvoice entity) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
|
|
List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
|
|
BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
- map.put("invoiceReceivable",entity.getInvoiceAmount() == null? BigDecimal.ZERO: entity.getInvoiceAmount().subtract(totalReturn));
|
|
|
|
|
|
+ map.put("invoiceReceivable", entity.getInvoiceAmount() == null ? BigDecimal.ZERO : entity.getInvoiceAmount().subtract(totalReturn));
|
|
List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
|
|
List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
|
|
- map.put("returnMoneyListJson",JSON.toJSONString(returnMoneyList));
|
|
|
|
- map.put("contractListJson",JSON.toJSONString(contractInvoiceRelations));
|
|
|
|
- if(StringUtils.isNotBlank(entity.getContractId())){
|
|
|
|
|
|
+ map.put("returnMoneyListJson", JSON.toJSONString(returnMoneyList));
|
|
|
|
+ map.put("contractListJson", JSON.toJSONString(contractInvoiceRelations));
|
|
|
|
+ if (StringUtils.isNotBlank(entity.getContractId())) {
|
|
Contract contract = contractService.selectByPrimaryKey(entity.getContractId());
|
|
Contract contract = contractService.selectByPrimaryKey(entity.getContractId());
|
|
- map.put("contract",contract);
|
|
|
|
- if(contract != null){
|
|
|
|
- if(StringUtils.isNotBlank(contract.getProjectId())){
|
|
|
|
|
|
+ map.put("contract", contract);
|
|
|
|
+ if (contract != null) {
|
|
|
|
+ if (StringUtils.isNotBlank(contract.getProjectId())) {
|
|
Project project = projectService.selectById(contract.getProjectId());
|
|
Project project = projectService.selectById(contract.getProjectId());
|
|
- map.put("project",project);
|
|
|
|
|
|
+ map.put("project", project);
|
|
ProjectAmount projectAmount = projectAmountService.selectById(contract.getProjectId());
|
|
ProjectAmount projectAmount = projectAmountService.selectById(contract.getProjectId());
|
|
- if(projectAmount != null){
|
|
|
|
- map.put("amount",projectAmount);
|
|
|
|
|
|
+ if (projectAmount != null) {
|
|
|
|
+ map.put("amount", projectAmount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(contract.getMainType() != null){
|
|
|
|
|
|
+ if (contract.getMainType() != null) {
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_MAIN_TYPE, String.valueOf(contract.getMainType()));
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_MAIN_TYPE, String.valueOf(contract.getMainType()));
|
|
map.put("mainType", result.getCheckedData().getLabel());
|
|
map.put("mainType", result.getCheckedData().getLabel());
|
|
}
|
|
}
|
|
- if(contract.getSecondType() != null){
|
|
|
|
|
|
+ if (contract.getSecondType() != null) {
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_SECOND_TYPE, String.valueOf(contract.getSecondType()));
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_CONTRACT_SECOND_TYPE, String.valueOf(contract.getSecondType()));
|
|
map.put("secondType", result.getCheckedData().getLabel());
|
|
map.put("secondType", result.getCheckedData().getLabel());
|
|
}
|
|
}
|
|
@@ -138,9 +140,9 @@ public class FlowContractInvoiceService {
|
|
map.put("formEntity", entity);
|
|
map.put("formEntity", entity);
|
|
List<Select> invoiceTypeList = SelectConvert.INSTANCE.convertList(dictDataApi.getDictDataList(DictConstants.TYPE_INVOICE).getCheckedData());
|
|
List<Select> invoiceTypeList = SelectConvert.INSTANCE.convertList(dictDataApi.getDictDataList(DictConstants.TYPE_INVOICE).getCheckedData());
|
|
map.put("invoiceTypeList", JSON.toJSONString(invoiceTypeList));
|
|
map.put("invoiceTypeList", JSON.toJSONString(invoiceTypeList));
|
|
- if(entity.getInvoiceType() != null){
|
|
|
|
|
|
+ if (entity.getInvoiceType() != null) {
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_INVOICE, String.valueOf(entity.getInvoiceType()));
|
|
CommonResult<DictDataRespDTO> result = dictDataApi.getDictData(DictConstants.TYPE_INVOICE, String.valueOf(entity.getInvoiceType()));
|
|
- if(result.isSuccess()){
|
|
|
|
|
|
+ if (result.isSuccess()) {
|
|
map.put("invoiceType", result.getData().getLabel());
|
|
map.put("invoiceType", result.getData().getLabel());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -151,11 +153,37 @@ public class FlowContractInvoiceService {
|
|
public int updateById(ContractInvoice entity) {
|
|
public int updateById(ContractInvoice entity) {
|
|
int res = contractInvoiceMapper.updateById(entity);
|
|
int res = contractInvoiceMapper.updateById(entity);
|
|
List<ContractInvoiceRelation> relations = contractInvoiceRelationService.selectDOByInvoiceId(entity.getId());
|
|
List<ContractInvoiceRelation> relations = contractInvoiceRelationService.selectDOByInvoiceId(entity.getId());
|
|
- if(relations.size() == 1){
|
|
|
|
|
|
+ if (relations.size() == 1) {
|
|
ContractInvoiceRelation relation = relations.get(0);
|
|
ContractInvoiceRelation relation = relations.get(0);
|
|
relation.setInvoiceAmount(entity.getInvoiceAmount());
|
|
relation.setInvoiceAmount(entity.getInvoiceAmount());
|
|
contractInvoiceRelationService.updateById(relation);
|
|
contractInvoiceRelationService.updateById(relation);
|
|
}
|
|
}
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public ContractInvoiceVO flowAdd(String flowInstanceId, String userId) {
|
|
|
|
+ ContractInvoice entity = contractInvoiceService.selectByInstanceId(flowInstanceId);
|
|
|
|
+ ContractInvoiceVO vo = ContractConvert.INSTANCE.convertInvoice(entity);
|
|
|
|
+ List<ContractReturnMoney> returnMoneyList = contractReturnMoneyService.selectByInoviceId(entity.getId());
|
|
|
|
+ BigDecimal totalReturn = returnMoneyList.stream().map(ContractReturnMoney::getReturnAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ vo.setInvoiceReceivable(entity.getInvoiceAmount() == null ? BigDecimal.ZERO : entity.getInvoiceAmount().subtract(totalReturn));
|
|
|
|
+ List<ContractInvoiceRelationDto> contractInvoiceRelations = contractInvoiceRelationService.selectByInvoiceId(entity.getId());
|
|
|
|
+ vo.setReturnMoneyList(returnMoneyList);
|
|
|
|
+ vo.setContractInvoiceRelations(contractInvoiceRelations);
|
|
|
|
+ if (StringUtils.isNotBlank(entity.getContractId())) {
|
|
|
|
+ Contract contract = contractService.selectByPrimaryKey(entity.getContractId());
|
|
|
|
+ vo.setContract(contract);
|
|
|
|
+ if (contract != null) {
|
|
|
|
+ if (StringUtils.isNotBlank(contract.getProjectId())) {
|
|
|
|
+ Project project = projectService.selectById(contract.getProjectId());
|
|
|
|
+ vo.setProject(project);
|
|
|
|
+ ProjectAmount projectAmount = projectAmountService.selectById(contract.getProjectId());
|
|
|
|
+ if (projectAmount != null) {
|
|
|
|
+ vo.setProjectAmount(projectAmount);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return vo;
|
|
|
|
+ }
|
|
}
|
|
}
|