|
@@ -16,10 +16,15 @@
|
|
|
*/
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
+import org.springblade.common.utils.BaiduApiUtil;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.manager.dto.FindAllUserByConditionDTO;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.entity.ProjectContractArea;
|
|
|
+import org.springblade.manager.mapper.ProjectContractAreaMapper;
|
|
|
import org.springblade.manager.vo.CRolePostVO;
|
|
|
import org.springblade.manager.vo.ContractInfoVO;
|
|
|
import org.springblade.manager.mapper.ContractInfoMapper;
|
|
@@ -30,9 +35,12 @@ import org.springblade.manager.vo.WbsTreeVO;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 合同段信息表 服务实现类
|
|
@@ -41,12 +49,13 @@ import java.util.List;
|
|
|
* @since 2022-04-14
|
|
|
*/
|
|
|
@Service
|
|
|
+@AllArgsConstructor
|
|
|
public class ContractInfoServiceImpl
|
|
|
extends BaseServiceImpl<ContractInfoMapper, ContractInfo>
|
|
|
implements IContractInfoService {
|
|
|
|
|
|
- @Resource
|
|
|
- private ContractInfoMapper contractInfoMapper;
|
|
|
+ private final ContractInfoMapper contractInfoMapper;
|
|
|
+ private final ProjectContractAreaMapper projectContractAreaMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<ContractInfoVO> selectContractInfoPage(IPage<ContractInfoVO> page, ContractInfoVO contractInfo) {
|
|
@@ -113,4 +122,48 @@ public class ContractInfoServiceImpl
|
|
|
public List<WbsTreeContractTreeVO> tree(String wbsId, String projectId, String contractId) {
|
|
|
return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, contractId));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean saveAndUpdateContract(ContractInfoVO contractInfo) {
|
|
|
+ //新增合同段
|
|
|
+ boolean row = saveOrUpdate(contractInfo);
|
|
|
+ if (row) {
|
|
|
+ //获取合同段位置信息
|
|
|
+ String projectPlace = contractInfo.getProjectPlace();
|
|
|
+ try {
|
|
|
+ Map<String, Object> addressInfo = BaiduApiUtil.geocoding(projectPlace);
|
|
|
+ Map<String, String> position = BaiduApiUtil.getPosition(addressInfo.get("lat").toString()
|
|
|
+ + "," + addressInfo.get("lng").toString());
|
|
|
+ ProjectContractArea projectContractArea = new ProjectContractArea();
|
|
|
+ projectContractArea.setProvince(position.get("province"));
|
|
|
+ projectContractArea.setCity(position.get("city"));
|
|
|
+ projectContractArea.setCounty(position.get("district"));
|
|
|
+ projectContractArea.setCity_code(position.get("adcode"));
|
|
|
+ projectContractArea.setProjectId(contractInfo.getPId());
|
|
|
+ projectContractArea.setIsDeleted(0);
|
|
|
+ projectContractArea.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
+ //判重
|
|
|
+ QueryWrapper<ProjectContractArea> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("project_id", contractInfo.getPId());
|
|
|
+ queryWrapper.eq("contract_id", contractInfo.getId());
|
|
|
+ queryWrapper.eq("province", position.get("province"));
|
|
|
+ queryWrapper.eq("city", position.get("city"));
|
|
|
+ queryWrapper.eq("county", position.get("district"));
|
|
|
+ queryWrapper.eq("city_code", position.get("adcode"));
|
|
|
+ queryWrapper.eq("is_deleted", contractInfo.getIsDeleted());
|
|
|
+ ProjectContractArea projectContractArea1 = projectContractAreaMapper.selectOne(queryWrapper);
|
|
|
+ if (projectContractArea1 == null) {
|
|
|
+ int insert = projectContractAreaMapper.insert(projectContractArea);
|
|
|
+ if (insert > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|