Commit c70e86ad authored by wanglong's avatar wanglong

添加管材及设备接口,优化之前代码

parent 7cc58fdd
package com.yeejoin.amos.boot.module.ugp.api.service; package com.yeejoin.amos.boot.module.ugp.api.service;
import com.yeejoin.amos.boot.module.ugp.api.dto.WeldDto; import com.yeejoin.amos.boot.module.ugp.api.entity.Weld;
import java.util.List; import java.util.List;
...@@ -12,5 +12,5 @@ import java.util.List; ...@@ -12,5 +12,5 @@ import java.util.List;
* @date 2022-09-22 * @date 2022-09-22
*/ */
public interface IWeldService { public interface IWeldService {
void getCode(Long projectCode, int number) throws Exception; List<Weld> getCode(Long projectCode, int number) throws Exception;
} }
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List; import java.util.List;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.EquipmentServiceImpl; import com.yeejoin.amos.boot.module.ugp.biz.service.impl.EquipmentServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.dto.EquipmentDto; import com.yeejoin.amos.boot.module.ugp.api.dto.EquipmentDto;
...@@ -53,7 +58,7 @@ public class EquipmentController extends BaseController { ...@@ -53,7 +58,7 @@ public class EquipmentController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}") @PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新设备信息表", notes = "根据sequenceNbr更新设备信息表") @ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新设备信息表", notes = "根据sequenceNbr更新设备信息表")
public ResponseModel<EquipmentDto> updateBySequenceNbrEquipment(@RequestBody EquipmentDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<EquipmentDto> updateBySequenceNbrEquipment(@RequestBody EquipmentDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(equipmentServiceImpl.updateWithModel(model)); return ResponseHelper.buildResponse(equipmentServiceImpl.updateWithModel(model));
} }
...@@ -67,7 +72,7 @@ public class EquipmentController extends BaseController { ...@@ -67,7 +72,7 @@ public class EquipmentController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}") @DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除设备信息表", notes = "根据sequenceNbr删除设备信息表") @ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除设备信息表", notes = "根据sequenceNbr删除设备信息表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){ public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(equipmentServiceImpl.removeById(sequenceNbr)); return ResponseHelper.buildResponse(equipmentServiceImpl.removeById(sequenceNbr));
} }
...@@ -79,7 +84,7 @@ public class EquipmentController extends BaseController { ...@@ -79,7 +84,7 @@ public class EquipmentController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}") @GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个设备信息表", notes = "根据sequenceNbr查询单个设备信息表") @ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个设备信息表", notes = "根据sequenceNbr查询单个设备信息表")
public ResponseModel<EquipmentDto> selectOne(@PathVariable Long sequenceNbr) { public ResponseModel<EquipmentDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(equipmentServiceImpl.queryBySeq(sequenceNbr)); return ResponseHelper.buildResponse(equipmentServiceImpl.queryBySeq(sequenceNbr));
} }
...@@ -93,8 +98,8 @@ public class EquipmentController extends BaseController { ...@@ -93,8 +98,8 @@ public class EquipmentController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "设备信息表分页查询", notes = "设备信息表分页查询") @ApiOperation(httpMethod = "GET", value = "设备信息表分页查询", notes = "设备信息表分页查询")
public ResponseModel<Page<EquipmentDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam public ResponseModel<Page<EquipmentDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) { (value = "size") int size) {
Page<EquipmentDto> page = new Page<EquipmentDto>(); Page<EquipmentDto> page = new Page<EquipmentDto>();
page.setCurrent(current); page.setCurrent(current);
...@@ -108,9 +113,21 @@ public class EquipmentController extends BaseController { ...@@ -108,9 +113,21 @@ public class EquipmentController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "设备信息表列表全部数据查询", notes = "设备信息表列表全部数据查询") @ApiOperation(httpMethod = "GET", value = "设备信息表列表全部数据查询", notes = "设备信息表列表全部数据查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ResponseModel<List<EquipmentDto>> selectForList() { public ResponseModel<List<EquipmentDto>> selectForList() {
return ResponseHelper.buildResponse(equipmentServiceImpl.queryForEquipmentList()); return ResponseHelper.buildResponse(equipmentServiceImpl.queryForEquipmentList());
} }
/**
* 设备数据名称查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "设备数据名称查询", notes = "设备数据名称查询")
@GetMapping(value = "/selectName")
public ResponseModel<List<JSONObject>> selectName() {
return ResponseHelper.buildResponse(equipmentServiceImpl.selectName());
}
} }
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -113,4 +114,29 @@ public class MaterialController extends BaseController { ...@@ -113,4 +114,29 @@ public class MaterialController extends BaseController {
public ResponseModel<List<MaterialDto>> selectForList() { public ResponseModel<List<MaterialDto>> selectForList() {
return ResponseHelper.buildResponse(materialServiceImpl.queryForMaterialList()); return ResponseHelper.buildResponse(materialServiceImpl.queryForMaterialList());
} }
// /**
// * 根据项目id查询材料信息
// *
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
// @ApiOperation(httpMethod = "GET",value = "根据项目id查询材料信息", notes = "根据项目id查询材料信息")
// @GetMapping(value = "/selectMess")
// public ResponseModel<MaterialDto> selectMess(@RequestParam String companyId ) {
// return ResponseHelper.buildResponse(materialServiceImpl.selectMess(companyId));
// }
/**
* 材料信息表列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "材料信息表列表全部数据查询", notes = "材料信息表列表全部数据查询")
@GetMapping(value = "/selectName")
public ResponseModel<List<JSONObject>> selectName() {
return ResponseHelper.buildResponse(materialServiceImpl.selectName());
}
} }
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.entity.Project; import com.yeejoin.amos.boot.module.ugp.api.entity.Project;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.ProjectInitiationServiceImpl; import com.yeejoin.amos.boot.module.ugp.biz.service.impl.ProjectInitiationServiceImpl;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -126,4 +127,13 @@ public class ProjectController extends BaseController { ...@@ -126,4 +127,13 @@ public class ProjectController extends BaseController {
public ResponseModel<List<ProjectDto>> selectForList() { public ResponseModel<List<ProjectDto>> selectForList() {
return ResponseHelper.buildResponse(projectServiceImpl.queryForProjectList()); return ResponseHelper.buildResponse(projectServiceImpl.queryForProjectList());
} }
/**
* 查询项目名称
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "查询项目名称", notes = "查询项目名称")
@GetMapping(value = "/selectName")
public ResponseModel<List<JSONObject>> selectName() {
return ResponseHelper.buildResponse(projectServiceImpl.selectName());
}
} }
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -113,4 +115,16 @@ public class ProjectResourceController extends BaseController { ...@@ -113,4 +115,16 @@ public class ProjectResourceController extends BaseController {
public ResponseModel<List<ProjectResourceDto>> selectForList() { public ResponseModel<List<ProjectResourceDto>> selectForList() {
return ResponseHelper.buildResponse(projectResourceServiceImpl.queryForProjectResourceList()); return ResponseHelper.buildResponse(projectResourceServiceImpl.queryForProjectResourceList());
} }
/**
* 绑定设备跟项目
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "POST",value = "绑定设备跟项目", notes = "绑定设备跟项目")
@PostMapping(value = "/saveId")
public ResponseModel<ProjectResource> saveId(@RequestBody JSONObject jsonObject) {
return ResponseHelper.buildResponse(projectResourceServiceImpl.saveIds(jsonObject));
}
} }
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.entity.Weld;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -90,7 +91,7 @@ public class WeldController extends BaseController { ...@@ -90,7 +91,7 @@ public class WeldController extends BaseController {
} }
/** /**
* 列表分页查询 * 列表分页查询+条件查询
* *
* @param current 当前页 * @param current 当前页
* @param current 每页大小 * @param current 每页大小
...@@ -100,8 +101,9 @@ public class WeldController extends BaseController { ...@@ -100,8 +101,9 @@ public class WeldController extends BaseController {
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "焊口信息表分页查询", notes = "焊口信息表分页查询") @ApiOperation(httpMethod = "GET", value = "焊口信息表分页查询", notes = "焊口信息表分页查询")
public ResponseModel<Page<WeldDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam public ResponseModel<Page<WeldDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) { (value = "size") int size,String projectId) {
return ResponseHelper.buildResponse(weldServiceImpl.queryForWeldPage(current, size));
return ResponseHelper.buildResponse(weldServiceImpl.queryForWeldPage(current, size,projectId));
} }
/** /**
...@@ -122,11 +124,11 @@ public class WeldController extends BaseController { ...@@ -122,11 +124,11 @@ public class WeldController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "POST", value = "生成焊口编码", notes = "生成焊口编码") @ApiOperation(httpMethod = "GET", value = "生成焊口编码", notes = "生成焊口编码")
@PostMapping(value = "/getCode") @GetMapping(value = "/getCode")
public synchronized ResponseModel<String> getCode(Long sequenceNbr, int number) throws Exception { public ResponseModel<List<Weld>> getCode(Long sequenceNbr, int number) {
weldServiceImpl.getCode(sequenceNbr, number);
return ResponseHelper.buildResponse("ok"); return ResponseHelper.buildResponse(weldServiceImpl.getCode(sequenceNbr,number));
} }
} }
package com.yeejoin.amos.boot.module.ugp.biz.service.impl; package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.entity.Equipment; import com.yeejoin.amos.boot.module.ugp.api.entity.Equipment;
import com.yeejoin.amos.boot.module.ugp.api.mapper.EquipmentMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.EquipmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IEquipmentService; import com.yeejoin.amos.boot.module.ugp.api.service.IEquipmentService;
import com.yeejoin.amos.boot.module.ugp.api.dto.EquipmentDto; import com.yeejoin.amos.boot.module.ugp.api.dto.EquipmentDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -16,7 +20,10 @@ import java.util.List; ...@@ -16,7 +20,10 @@ import java.util.List;
* @date 2022-09-22 * @date 2022-09-22
*/ */
@Service @Service
public class EquipmentServiceImpl extends BaseService<EquipmentDto,Equipment,EquipmentMapper> implements IEquipmentService { public class EquipmentServiceImpl extends BaseService<EquipmentDto, Equipment, EquipmentMapper> implements IEquipmentService {
@Autowired
EquipmentMapper equipmentMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -28,6 +35,25 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto,Equipment,Equ ...@@ -28,6 +35,25 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto,Equipment,Equ
* 列表查询 示例 * 列表查询 示例
*/ */
public List<EquipmentDto> queryForEquipmentList() { public List<EquipmentDto> queryForEquipmentList() {
return this.queryForList("" , false); return this.queryForList("", false);
}
/**
* 设备数据名称查询
*
* @return
*/
public List<JSONObject> selectName() {
List<JSONObject> names = new ArrayList<>();
//查询所有设备数据
List<Equipment> equipment = equipmentMapper.selectList(null);
for (Equipment i : equipment) {
JSONObject name = new JSONObject();
name.put("name", i.getName());
name.put("company_id", i.getCompanyId());
names.add(name);
}
return names;
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.ugp.biz.service.impl; package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Material; import com.yeejoin.amos.boot.module.ugp.api.entity.Material;
import com.yeejoin.amos.boot.module.ugp.api.mapper.MaterialMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.MaterialMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IMaterialService; import com.yeejoin.amos.boot.module.ugp.api.service.IMaterialService;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -16,7 +19,7 @@ import java.util.List; ...@@ -16,7 +19,7 @@ import java.util.List;
* @date 2022-09-22 * @date 2022-09-22
*/ */
@Service @Service
public class MaterialServiceImpl extends BaseService<MaterialDto,Material,MaterialMapper> implements IMaterialService { public class MaterialServiceImpl extends BaseService<MaterialDto, Material, MaterialMapper> implements IMaterialService {
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -28,6 +31,24 @@ public class MaterialServiceImpl extends BaseService<MaterialDto,Material,Materi ...@@ -28,6 +31,24 @@ public class MaterialServiceImpl extends BaseService<MaterialDto,Material,Materi
* 列表查询 示例 * 列表查询 示例
*/ */
public List<MaterialDto> queryForMaterialList() { public List<MaterialDto> queryForMaterialList() {
return this.queryForList("" , false); return this.queryForList("", false);
}
/**
* 获取材料名称跟企业id
*/
public List<JSONObject> selectName() {
List<JSONObject> names = new ArrayList<>();
List<Material> materials = baseMapper.selectList(null);
for (Material i : materials) {
JSONObject name = new JSONObject();
name.put("name", i.getName());
name.put("company_id", i.getCompanyId());
names.add(name);
}
return names;
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.ugp.biz.service.impl; package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource; 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.api.mapper.ProjectResourceMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IProjectResourceService; 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.api.dto.ProjectResourceDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List; import java.util.List;
/** /**
...@@ -16,7 +22,13 @@ import java.util.List; ...@@ -16,7 +22,13 @@ import java.util.List;
* @date 2022-09-22 * @date 2022-09-22
*/ */
@Service @Service
public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto,ProjectResource,ProjectResourceMapper> implements IProjectResourceService { public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto, ProjectResource, ProjectResourceMapper> implements IProjectResourceService {
@Autowired
EquipmentMapper equipmentMapper;
@Autowired
ProjectResourceMapper projectResourceMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -28,6 +40,29 @@ public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto,P ...@@ -28,6 +40,29 @@ public class ProjectResourceServiceImpl extends BaseService<ProjectResourceDto,P
* 列表查询 示例 * 列表查询 示例
*/ */
public List<ProjectResourceDto> queryForProjectResourceList() { public List<ProjectResourceDto> queryForProjectResourceList() {
return this.queryForList("" , false); return this.queryForList("", false);
}
/**
* 存储项目设备关系
*/
public ProjectResource saveIds(JSONObject jsonObject) {
JSONArray subForm = jsonObject.getJSONArray("subForm");
ProjectResource projectResource = new ProjectResource();
for (Object json2 : subForm) {
String select = JSON.parseObject(JSON.toJSONString(json2)).getString("select");
String type = JSON.parseObject(JSON.toJSONString(json2)).getString("type");
String companyId = jsonObject.getString("company_id");
projectResource.setProjectId(Long.valueOf(companyId));
projectResource.setResourceId(Long.valueOf(select));
projectResource.setType(type);
this.save(projectResource);
}
return projectResource;
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.ugp.biz.service.impl; package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Project; import com.yeejoin.amos.boot.module.ugp.api.entity.Project;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IProjectService; import com.yeejoin.amos.boot.module.ugp.api.service.IProjectService;
import com.yeejoin.amos.boot.module.ugp.api.dto.ProjectDto; import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -16,7 +20,10 @@ import java.util.List; ...@@ -16,7 +20,10 @@ import java.util.List;
* @date 2022-09-22 * @date 2022-09-22
*/ */
@Service @Service
public class ProjectServiceImpl extends BaseService<ProjectDto,Project,ProjectMapper> implements IProjectService { public class ProjectServiceImpl extends BaseService<ProjectDto, Project, ProjectMapper> implements IProjectService {
@Autowired
ProjectMapper projectMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -28,6 +35,23 @@ public class ProjectServiceImpl extends BaseService<ProjectDto,Project,ProjectMa ...@@ -28,6 +35,23 @@ public class ProjectServiceImpl extends BaseService<ProjectDto,Project,ProjectMa
* 列表查询 示例 * 列表查询 示例
*/ */
public List<ProjectDto> queryForProjectList() { public List<ProjectDto> queryForProjectList() {
return this.queryForList("" , false); return this.queryForList("", false);
}
/**
* 查询项目名称
*/
public List<JSONObject> selectName() {
List<JSONObject> names = new ArrayList<>();
//查询所有项目
List<Project> projects = projectMapper.selectList(null);
for (Project i : projects) {
JSONObject name = new JSONObject();
name.put("name", i.getName());
name.put("company_id", i.getCompanyId());
names.add(name);
}
return names;
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.ugp.biz.service.impl; package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.Enum.WeldCodeEnum; import com.yeejoin.amos.boot.module.ugp.api.Enum.WeldCodeEnum;
import com.yeejoin.amos.boot.module.ugp.api.Enum.WeldMethodEnum; import com.yeejoin.amos.boot.module.ugp.api.Enum.WeldMethodEnum;
import com.yeejoin.amos.boot.module.ugp.api.dto.WeldDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Project; import com.yeejoin.amos.boot.module.ugp.api.entity.Project;
import com.yeejoin.amos.boot.module.ugp.api.entity.Weld; import com.yeejoin.amos.boot.module.ugp.api.entity.Weld;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.WeldMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.WeldMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IWeldService; import com.yeejoin.amos.boot.module.ugp.api.service.IWeldService;
import com.yeejoin.amos.boot.module.ugp.api.dto.WeldDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.ParseException; import java.util.ArrayList;
import java.text.SimpleDateFormat; import java.util.Date;
import java.util.*; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/** /**
* 焊口信息表服务实现类 * 焊口信息表服务实现类
...@@ -42,14 +36,13 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements ...@@ -42,14 +36,13 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements
ProjectMapper projectMapper; ProjectMapper projectMapper;
Logger logger = LoggerFactory.getLogger(WeldServiceImpl.class); // Logger logger = LoggerFactory.getLogger(WeldServiceImpl.class);
/** /**
* 分页查询 * 分页查询
*/ */
public Page<WeldDto> queryForWeldPage(int current, int size) { public Page<WeldDto> queryForWeldPage(int current, int size, String projectId) {
Page<WeldDto> page = new Page<>(); Page<WeldDto> page = new Page<>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
...@@ -57,20 +50,28 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements ...@@ -57,20 +50,28 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements
for (WeldDto weldDto : weldDtoPage.getRecords()) { for (WeldDto weldDto : weldDtoPage.getRecords()) {
QueryWrapper<Project> wrapper = new QueryWrapper<>(); QueryWrapper<Project> wrapper = new QueryWrapper<>();
wrapper.eq("code", weldDto.getProjectId()); wrapper.eq("sequence_nbr", weldDto.getProjectId());
Project project = projectMapper.selectOne(wrapper); Project project = projectMapper.selectOne(wrapper);
weldDto.setName(project.getName()); weldDto.setName(project.getName());
QueryWrapper<Project> wrapperUnit = new QueryWrapper<>(); QueryWrapper<Project> wrapperUnit = new QueryWrapper<>();
wrapperUnit.eq("installation_unit_id", weldDto.getInstallCompany()); wrapperUnit.eq("installation_unit_id", weldDto.getInstallCompany());
List<Project> projects = projectMapper.selectList(wrapperUnit); List<Project> projects = projectMapper.selectList(wrapperUnit);
for (Project project1 : projects) { for (Project project1 : projects) {
weldDto.setInstallationUnit(project1.getInstallationUnit()); weldDto.setInstallationUnit(project1.getInstallationUnit());
weldDto.setCodingStatus(WeldCodeEnum.map.get(weldDto.getCodingStatus())); weldDto.setCodingStatus(WeldCodeEnum.map.get(weldDto.getCodingStatus()));
weldDto.setCodingMethod(WeldMethodEnum.map.get(weldDto.getCodingMethod())); weldDto.setCodingMethod(WeldMethodEnum.map.get(weldDto.getCodingMethod()));
} }
} }
if (projectId == null) {
return weldDtoPage;
} else {
List<WeldDto> L = weldDtoPage.getRecords().stream().filter(b -> b.getProjectId().equals(projectId)).collect(Collectors.toList());
weldDtoPage.setRecords(L);
return weldDtoPage; return weldDtoPage;
}
} }
...@@ -88,53 +89,45 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements ...@@ -88,53 +89,45 @@ class WeldServiceImpl extends BaseService<WeldDto, Weld, WeldMapper> implements
private static final AtomicInteger atomicNum = new AtomicInteger(); private static final AtomicInteger atomicNum = new AtomicInteger();
// 初始化编号 // 初始化编号
private final int INIT_CODE_NUM = 0; private final int INIT_CODE_NUM = 0;
private final String FIRST_CHARACTER = "-HK";
public synchronized void getCode(Long sequenceNbr, int number) throws Exception { public synchronized List<Weld> getCode(Long sequenceNbr, int number) {
List<Weld> welds = new ArrayList<>(); List<Weld> welds = new ArrayList<>();
Project project = projectMapper.selectById(sequenceNbr); Project project = projectMapper.selectById(sequenceNbr);
QueryWrapper<Weld> wrapper = new QueryWrapper<>(); QueryWrapper<Weld> wrapper = new QueryWrapper<>();
//根据seq查询条件判断是否已经存在该项目的该焊口编码
wrapper.eq("project_id", project.getCode()).orderByDesc("code").last("limit 1"); wrapper.eq("project_id", sequenceNbr).orderByDesc("code").last("limit 1");
Weld weld1 = weldMapper.selectOne(wrapper); Weld weld1 = weldMapper.selectOne(wrapper);
if (weld1 != null) { if (weld1 != null) {
String substring = weld1.getCode().substring(13, 17); //存在时取后四位
String substring = weld1.getCode().substring(weld1.getCode().length() - 4, weld1.getCode().length());
atomicNum.set(Integer.parseInt(substring)); atomicNum.set(Integer.parseInt(substring));
for (int i = 0; i < number; i++) {
Weld weld = new Weld();
String i1 = String.format("%04d", atomicNum.incrementAndGet());
String code = "XM" + (project.getCode()) + "-HK" + i1;
weld.setRegion(project.getAddress());
weld.setProjectId(Long.valueOf(project.getCode()));
weld.setInstallCompany(project.getInstallationUnitId());
weld.setCode(code);
weld.setRegion(project.getAddress());
weld.setCodingMethod("0");
weld.setCodingStatus("1");
weld.setCodingDate(new Date());
welds.add(weld);
}
saveBatch(welds);
} else { } else {
atomicNum.set(0); //不存在时将atomicNum初始化
atomicNum.set(INIT_CODE_NUM);
}
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
Weld weld = new Weld(); Weld weld = new Weld();
//生成四位数
String i1 = String.format("%04d", atomicNum.incrementAndGet()); String i1 = String.format("%04d", atomicNum.incrementAndGet());
String code = "XM" + (project.getCode()) + "-HK" + i1; //生成编码
String code = (project.getCode()) + FIRST_CHARACTER + i1;
weld.setRegion(project.getAddress()); weld.setRegion(project.getAddress());
weld.setProjectId(Long.valueOf(project.getCode())); weld.setProjectId(Long.valueOf(project.getSequenceNbr()));
weld.setInstallCompany(project.getInstallationUnitId()); weld.setInstallCompany(project.getInstallationUnitId());
weld.setCode(code); weld.setCode(code);
weld.setRegion(project.getAddress()); weld.setRegion(project.getAddress());
weld.setCodingMethod("0"); weld.setCodingMethod(WeldMethodEnum.赋码方式1.getState());
weld.setCodingStatus("1"); weld.setCodingStatus(WeldCodeEnum.赋值状态2.getState());
weld.setCodingDate(new Date()); weld.setCodingDate(new Date());
welds.add(weld); welds.add(weld);
} }
saveBatch(welds); saveBatch(welds);
return welds;
} }
}
} }
\ No newline at end of file
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