|
@@ -6,13 +6,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zjugis.business.bean.dto.AmountDto;
|
|
|
import com.zjugis.business.bean.dto.ContractDto;
|
|
|
import com.zjugis.business.bean.entity.Contract;
|
|
|
+import com.zjugis.business.bean.entity.ContractAreaManager;
|
|
|
+import com.zjugis.business.bean.entity.Project;
|
|
|
import com.zjugis.business.bean.request.ContractRequest;
|
|
|
import com.zjugis.business.bean.response.ContractChildResponse;
|
|
|
import com.zjugis.business.bean.response.ContractResponse;
|
|
|
import com.zjugis.business.constants.ContractConstants;
|
|
|
import com.zjugis.business.constants.FlowStatusConstants;
|
|
|
+import com.zjugis.business.mapper.ContractAreaManagerMapper;
|
|
|
import com.zjugis.business.mapper.ContractMapper;
|
|
|
+import com.zjugis.business.mapper.ProjectMapper;
|
|
|
import com.zjugis.business.service.ContractService;
|
|
|
+import com.zjugis.business.service.ProjectService;
|
|
|
import com.zjugis.framework.common.exception.ServiceException;
|
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
import com.zjugis.framework.security.core.util.SecurityFrameworkUtils;
|
|
@@ -51,6 +56,15 @@ public class ContractServiceImpl implements ContractService{
|
|
|
@Autowired
|
|
|
private WorkflowClient workflowClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ContractAreaManagerMapper contractAreaManagerMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProjectService projectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProjectMapper projectMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public String insert(Contract contract) {
|
|
|
contractMapper.insert(contract);
|
|
@@ -68,9 +82,54 @@ public class ContractServiceImpl implements ContractService{
|
|
|
public int updateById(ContractRequest record) {
|
|
|
Contract contract = new Contract();
|
|
|
BeanUtils.copyProperties(record,contract);
|
|
|
+ updateProjectXsry(record);
|
|
|
return contractMapper.updateById(contract);
|
|
|
}
|
|
|
|
|
|
+ private void updateProjectXsry(ContractRequest record) {
|
|
|
+ Contract dbContract = contractMapper.selectById(record.getId());
|
|
|
+ Project project = projectMapper.selectById(dbContract.getProjectId());
|
|
|
+ project.setXsryId(record.getAreaManagerId());
|
|
|
+ project.setXsry(record.getAreaManager());
|
|
|
+ projectMapper.updateById(project);
|
|
|
+ updateAreaManager(dbContract);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateAreaManager(Contract contract){
|
|
|
+ String areaManagerId = contract.getAreaManagerId();
|
|
|
+ String areaManagerName = contract.getAreaManager();
|
|
|
+ QueryWrapper<ContractAreaManager> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("CONTRACT_ID",contract.getId());
|
|
|
+ contractAreaManagerMapper.delete(queryWrapper);
|
|
|
+ List<ContractAreaManager> insertList = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(areaManagerId)){
|
|
|
+ String[] ids = areaManagerId.split(",");
|
|
|
+ String[] names = areaManagerName.split(",");
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ ContractAreaManager contractAreaManager = new ContractAreaManager();
|
|
|
+ contractAreaManager.setContractId(contract.getId());
|
|
|
+ contractAreaManager.setAreaManagerId(ids[i]);
|
|
|
+ contractAreaManager.setAreaManagerName(names[i]);
|
|
|
+ insertList.add(contractAreaManager);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ contractAreaManagerMapper.insertBatch(insertList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param contract
|
|
|
+ * @param projectId
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateVirtualContract(Contract contract, String projectId) {
|
|
|
+ List<String> ids = projectMapper.selectChildrenIds(projectId);
|
|
|
+ if(!ids.isEmpty()){
|
|
|
+ contractMapper.updateVirtualContractByProjectId(contract,ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Page<Contract> page(Page<Contract> page, ContractDto contractDto) {
|
|
|
return contractMapper.page(page, contractDto);
|
|
@@ -249,6 +308,12 @@ public class ContractServiceImpl implements ContractService{
|
|
|
contract.setContractType(ContractConstants.TYPE_MAIN_CONTRACT);
|
|
|
contract.setFlowStatus(FlowStatusConstants.FLOW_NOT_START);
|
|
|
insert(contract);
|
|
|
+ ContractAreaManager contractAreaManager = new ContractAreaManager();
|
|
|
+ contractAreaManager.setContractId(contract.getId());
|
|
|
+ Project project = projectService.selectById(projectId);
|
|
|
+ contractAreaManager.setAreaManagerId(project.getXsryId());
|
|
|
+ contractAreaManager.setAreaManagerName(project.getXsry());
|
|
|
+ contractAreaManagerMapper.insert(contractAreaManager);
|
|
|
return returnUrl;
|
|
|
}
|
|
|
}
|