| | |
| | | |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoIr.IrProjectGroupMapper; |
| | | import com.dy.pipIrrGlobal.daoIr.IrProjectMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrProject; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrProjectGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoProject; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectDetail; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectOne; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectSimple; |
| | | import com.dy.pipIrrIrrigate.project.dto.IrrigateProject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.aop.framework.AopContext; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Autowired |
| | | private IrProjectMapper irProjectMapper; |
| | | |
| | | @Autowired |
| | | private IrProjectGroupMapper irProjectGroupMapper; |
| | | |
| | | /** |
| | | * 添加项目 |
| | | * |
| | | * 添加项目,旧版本,原则上废弃 |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除项目 |
| | | * |
| | | * 添加项目,目前使用 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map addIrrigateProject(IrrigateProject po) { |
| | | String projectName = po.getProjectName(); |
| | | String irrigateGroups = po.getIrrigateGroups(); |
| | | Long operatorId = po.getOperator(); |
| | | |
| | | IrProject irProject = new IrProject(); |
| | | irProject.setProjectName(projectName); |
| | | irProject.setProjectState((byte)1); |
| | | irProject.setOperator(operatorId); |
| | | irProject.setOperateTime(new Date()); |
| | | irProject.setDeleted((byte)0); |
| | | irProjectMapper.insert(irProject); |
| | | Long projectId = irProject.getId(); |
| | | if(projectId == null) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "创建灌溉项目失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | String[] irrigateGroupArr = irrigateGroups.split(","); |
| | | Integer sort = 1; |
| | | for(String irrigateGroupId : irrigateGroupArr) { |
| | | String trimmed = irrigateGroupId.trim(); |
| | | if(trimmed.isEmpty()) { |
| | | continue; |
| | | } |
| | | try { |
| | | Long irrigateGroupIdLong = Long.parseLong(trimmed); |
| | | IrProjectGroup irProjectGroup = new IrProjectGroup(); |
| | | irProjectGroup.setProjectId(projectId); |
| | | irProjectGroup.setGroupId(irrigateGroupIdLong); |
| | | irProjectGroup.setSort(sort++); |
| | | irProjectGroupMapper.insert(irProjectGroup); |
| | | } catch (NumberFormatException e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "灌溉组ID格式错误"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "添加灌溉项目成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 删除灌溉项目,目前使用 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map deleteIrrigateProject(Long projectId) { |
| | | try { |
| | | irProjectGroupMapper.unbindGroup(projectId); |
| | | irProjectMapper.deleteByPrimaryKey(projectId); |
| | | |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "灌溉项目删除成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } catch (Exception e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "灌溉项目删除失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改灌溉项目,目前使用 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map updateIrrigateProject(IrrigateProject po) { |
| | | Long projectId = po.getProjectId(); |
| | | Map map_deleteProject = ((ProjectSv) AopContext.currentProxy()).deleteIrrigateProject(projectId); |
| | | if(map_deleteProject.get("success").equals(false)) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", map_deleteProject.get("msg").toString()); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | Map map_addProject = ((ProjectSv) AopContext.currentProxy()).addIrrigateProject(po); |
| | | if(map_addProject.get("success").equals(false)) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", map_addProject.get("msg").toString()); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "修改灌溉项目成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 删除项目,旧版本,原则上废弃 |
| | | * @param id |
| | | */ |
| | | public Integer deleteProject(Long id) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 分页查询项目 |
| | | * 分页查询项目,旧版本,原则上废弃 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | |
| | | rsVo.obj = irProjectMapper.getProjects(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 分页查询项目,新版本,目前使用 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoProjectSimple>> getSimpleProjects(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | Long itemTotal = irProjectMapper.getSimpleProjectsCount(params); |
| | | |
| | | QueryResultVo<List<VoProjectSimple>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = irProjectMapper.getSimpleProjects(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 根据项目Id获取项目详情,编辑项目信息使用 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | public Map getProjectDetail(Long projectId) { |
| | | try { |
| | | VoProjectDetail voProjectDetail = irProjectMapper.getProjectDetail(projectId); |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "获取项目详情成功"); |
| | | map.put("content", voProjectDetail); |
| | | return map; |
| | | } catch (Exception e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "获取项目详情失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | } |