Commit be4daecb authored by wanglong's avatar wanglong

添加基础信息删除判断 添加基础项目设备的状态更改

parent 080b68b5
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource;
import com.yeejoin.amos.boot.module.ugp.api.mapper.AttachmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectResourceMapper;
......@@ -86,16 +87,17 @@ public class MaterialController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除材料信息表", notes = "根据sequenceNbr删除材料信息表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") List<Long> sequenceNbr) throws Exception {
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") List<Long> sequenceNbr) throws Exception {
LambdaQueryWrapper<ProjectResource> wrapper = new LambdaQueryWrapper<>();
for (Long i:sequenceNbr){
wrapper.eq(ProjectResource::getResourceId,i);
if (!projectResourceMapper.selectList(wrapper).isEmpty()){
throw new Exception("无法删除,已绑定项目");
for (Long i : sequenceNbr) {
wrapper.eq(ProjectResource::getResourceId, i);
if (!projectResourceMapper.selectList(wrapper).isEmpty()) {
return CommonResponseUtil.failure("无法删除,管材:" + materialServiceImpl.getById(i).getName() + "已绑定项目");
}
}
return ResponseHelper.buildResponse(materialServiceImpl.removeByIds(sequenceNbr));
return ResponseHelper.buildResponse(materialServiceImpl.removeByIds(sequenceNbr));
}
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectMaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderEquipmentDto;
import com.alibaba.fastjson.JSONObject;
......@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource;
import com.yeejoin.amos.boot.module.ugp.api.mapper.EquipmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectResourceMapper;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.MaterialServiceImpl;
import org.aspectj.bridge.Message;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -203,8 +205,10 @@ public class ProjectResourceController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "POST",value = "绑定项目所用到的设备管材", notes = "绑定项目所用到的设备管材")
@PostMapping(value = "/saveId")
public ResponseModel<ProjectResource> saveId(@RequestBody JSONObject jsonObject) throws Exception {
return ResponseHelper.buildResponse(projectResourceServiceImpl.saveIds(jsonObject));
public ResponseModel<ResponseModel> saveId(@RequestBody JSONObject jsonObject) throws Exception {
return ResponseHelper.buildResponse(projectResourceServiceImpl.saveIds(jsonObject));
}
......
......@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrDto;
import com.yeejoin.amos.boot.module.common.api.dto.UserDto;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.ugp.api.Enum.OrgEnum;
import com.yeejoin.amos.boot.module.ugp.api.dto.InstallNoticeDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderEquipmentDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Project;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectResourceMapper;
import com.yeejoin.amos.boot.module.ugp.biz.framework.BusinessIdentify;
......@@ -176,9 +178,18 @@ public class WelderController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@DeleteMapping(value = "/deleteOneById/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr删除人员信息表", notes = "根据sequenceNbr删除人员信息表")
public ResponseModel<String> deleteOneById(@PathVariable String sequenceNbr) throws Exception {
public ResponseModel<String> deleteOneById(@PathVariable List<Long> sequenceNbr) throws Exception {
// Privilege.agencyUserClient.multDeleteUser(orgServiceImpl.getOrgUsrById(sequenceNbr).getAmosOrgId());
orgServiceImpl.delectInfo(sequenceNbr);
LambdaQueryWrapper<ProjectResource> wrapper = new LambdaQueryWrapper<>();
for (Long i : sequenceNbr) {
wrapper.eq(ProjectResource::getResourceId, i);
if (!projectResourceMapper.selectList(wrapper).isEmpty()) {
return CommonResponseUtil.failure("无法删除,管材:" + orgServiceImpl.getdetialInfo(String.valueOf(i)).get("name") + "已绑定项目");
}
orgServiceImpl.delectInfo(String.valueOf(i));
}
return ResponseHelper.buildResponse("ok");
}
......
package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.ugp.api.Enum.OrgEnum;
import com.yeejoin.amos.boot.module.ugp.api.Enum.ProjectResourceEnum;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectMaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderEquipmentDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.*;
import com.alibaba.fastjson.JSON;
......@@ -16,9 +18,11 @@ import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.mapper.EquipmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.MaterialMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectResourceMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.WeldMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IProjectResourceService;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectResourceDto;
import com.yeejoin.amos.boot.module.ugp.biz.framework.BusinessIdentify;
import org.apache.ibatis.annotations.Case;
import org.aspectj.weaver.ast.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,6 +32,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
......@@ -136,7 +141,7 @@ public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto,P
/**
* 绑定项目所用到的设备管材
*/
public ProjectResource saveIds(JSONObject jsonObject) throws Exception {
public ResponseModel saveIds(JSONObject jsonObject) throws Exception {
JSONArray subForm = jsonObject.getJSONArray("subForm");
ProjectResource Resource = new ProjectResource();
......@@ -148,36 +153,45 @@ public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto,P
Long SequenceNbr = Long.valueOf(jsonObject.getString("sequenceNbr"));
String type = jsonObject.getString("type");
LambdaQueryWrapper<ProjectResource> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectResource::getResourceId,select);
wrapper.eq(ProjectResource::getProjectId,SequenceNbr);
wrapper.eq(ProjectResource::getResourceId, select);
wrapper.eq(ProjectResource::getProjectId, SequenceNbr);
ProjectResource projectResourceVerify = projectResourceMapper.selectOne(wrapper);
if (ValidationUtil.isEmpty(projectResourceVerify)){
//判断资源类型并插入
if (type.equals(设备资源.getName())) {
projectResource.setType(设备资源.getCode());
Equipment equipment = equipmentMapper.selectById(select);
projectResource.setName(equipment.getName());
}
if (type.equals(焊工资源.getName())) {
projectResource.setType(焊工资源.getCode());
OrgUsr orgUsrById = orgService.getOrgUsrById(select);
projectResource.setName(orgUsrById.getBizOrgName());
}
if (type.equals(管材资源.getName())) {
projectResource.setType(管材资源.getCode());
Material material = materialMapper.selectById(select);
projectResource.setName(material.getName());
}
projectResource.setProjectId(SequenceNbr);
projectResource.setResourceId(Long.valueOf(select));
BeanUtils.copyProperties(projectResource,Resource);
this.save(projectResource);
}else {
throw new Exception("该资源已存在");
if (ValidationUtil.isEmpty(projectResourceVerify)) {
//判断资源类型并插入
if (type.equals(设备资源.getName())) {
projectResource.setType(设备资源.getCode());
Equipment equipment = equipmentMapper.selectById(select);
projectResource.setName(equipment.getName());
}
if (type.equals(焊工资源.getName())) {
projectResource.setType(焊工资源.getCode());
OrgUsr orgUsrById = orgService.getOrgUsrById(select);
projectResource.setName(orgUsrById.getBizOrgName());
}
if (type.equals(管材资源.getName())) {
projectResource.setType(管材资源.getCode());
Material material = materialMapper.selectById(select);
projectResource.setName(material.getName());
}
projectResource.setProjectId(SequenceNbr);
projectResource.setResourceId(Long.valueOf(select));
BeanUtils.copyProperties(projectResource, Resource);
boolean save = this.save(projectResource);
if (save || type.equals(设备资源.getName())) {
LambdaQueryWrapper<Equipment> wrapperEquipment = new LambdaQueryWrapper<>();
wrapperEquipment.eq(BaseEntity::getSequenceNbr, select);
Equipment equipment = new Equipment();
equipment.setUseStatus("已使用");
equipmentMapper.update(equipment, wrapperEquipment);
}
} else {
// throw new Exception("该资源已存在");
return CommonResponseUtil.failure("该资源已存在");
}
}
return Resource;
return CommonResponseUtil.success();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment