Commit 23f1d2cc authored by dqq's avatar dqq

材料管理页面筛选、新增、修改、详情、删除,项目管材管理页面筛选

parent cf748436
......@@ -3,7 +3,9 @@ package com.yeejoin.amos.boot.module.ugp.api.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.dto.InstallNoticeMsgPageDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderEquipmentDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Material;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
......@@ -28,4 +30,7 @@ public interface ProjectResourceMapper extends BaseMapper<ProjectResource> {
WelderEquipmentDto customSelectById(@Param("sequenceNbr") Long sequenceNbr);
//管材页面分页,根据名称、编号筛选
Page<MaterialDto> MaterialPage(IPage<MaterialDto> page ,@Param("name") String name, @Param("code") String code);
}
package com.yeejoin.amos.boot.module.ugp.api.service;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
/**
* 材料信息表接口类
*
......@@ -8,5 +11,7 @@ package com.yeejoin.amos.boot.module.ugp.api.service;
* @date 2022-09-22
*/
public interface IMaterialService {
//增加材料
MaterialDto saveMaterial(JSONObject jsonObject);
}
......@@ -99,4 +99,13 @@
where tz_ugp_equipment.sequence_nbr = #{sequenceNbr}
</select>
<!-- //管材页面分页,根据名称、编号筛选-->
<!-- Page<MaterialDto> MaterialPage(IPage<MaterialDto> page ,@Param("name") String name, @Param("code") String code);-->
<select id="MaterialPage" resultType="com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto">
SELECT tz_ugp_material.* FROM tz_ugp_material,tz_ugp_project_resource ,tz_ugp_project
WHERE tz_ugp_project_resource.project_id=tz_ugp_project.sequence_nbr
AND tz_ugp_project_resource.resource_id=tz_ugp_material.sequence_nbr
AND tz_ugp_project_resource.type="material"
AND tz_ugp_material.name LIKE '%${name}%' AND tz_ugp_material.code LIKE '%${code}%'
</select>
</mapper>
package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.mapper.AttachmentMapper;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.AttachmentServiceImpl;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.EquipmentServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -31,13 +35,18 @@ public class MaterialController extends BaseController {
@Autowired
MaterialServiceImpl materialServiceImpl;
@Autowired
AttachmentServiceImpl attachmentServiceImpl;
@Autowired
AttachmentMapper attachmentMapper;
/**
* 新增材料信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增材料信息表", notes = "新增材料信息表")
public ResponseModel<MaterialDto> save(@RequestBody MaterialDto model) {
......@@ -51,7 +60,7 @@ public class MaterialController extends BaseController {
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新材料信息表", notes = "根据sequenceNbr更新材料信息表")
public ResponseModel<MaterialDto> updateBySequenceNbrMaterial(@RequestBody MaterialDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
......@@ -65,7 +74,7 @@ public class MaterialController extends BaseController {
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@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") Long sequenceNbr){
......@@ -78,7 +87,7 @@ public class MaterialController extends BaseController {
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个材料信息表", notes = "根据sequenceNbr查询单个材料信息表")
public ResponseModel<MaterialDto> selectOne(@PathVariable Long sequenceNbr) {
......@@ -92,15 +101,17 @@ public class MaterialController extends BaseController {
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "材料信息表分页查询", notes = "材料信息表分页查询")
public ResponseModel<Page<MaterialDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
(value = "size") int size,
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "code",required = false) String code) {
Page<MaterialDto> page = new Page<MaterialDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(materialServiceImpl.queryForMaterialPage(page));
return ResponseHelper.buildResponse(materialServiceImpl.queryForMaterialPage(page,name,code));
}
/**
......@@ -108,7 +119,7 @@ public class MaterialController extends BaseController {
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "材料信息表列表全部数据查询", notes = "材料信息表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<MaterialDto>> selectForList() {
......@@ -139,4 +150,61 @@ public class MaterialController extends BaseController {
public ResponseModel<List<JSONObject>> selectName(@RequestParam(value = "unitId")String installationUnitId) {
return ResponseHelper.buildResponse(materialServiceImpl.selectName(installationUnitId));
}
/**
* 新增材料+附件
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping (value = "/saveIM")
@ApiOperation(httpMethod = "POST", value = "新增材料+附件", notes = "新增材料+附件")
public ResponseModel<MaterialDto> saveMaterial(@RequestBody JSONObject object) {
MaterialDto model = materialServiceImpl.saveMaterial(object);
Long mSequenceNbr = model.getSequenceNbr();
if (object.containsKey("subForm")){
JSONArray subForm = object.getJSONArray("subForm");
attachmentServiceImpl.saveAttachment(subForm,mSequenceNbr);
}
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr查询材料的附件
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "IM/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询材料和附件", notes = "根据sequenceNbr查询材料和附件")
public ResponseModel<JSONObject> selectIMOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(materialServiceImpl.groupBySeq(sequenceNbr));
}
/**
* 根据sequenceNbr更新材料及附件
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "IM/{sequenceNbr}")
@ApiOperation(httpMethod = "POST",value = "根据sequenceNbr更新设备和附件", notes = "根据sequenceNbr更新设备和附件")
public ResponseModel<String> updataIMOne(@PathVariable Long sequenceNbr,@RequestBody JSONObject object) {
materialServiceImpl.updateMI(sequenceNbr,object);
return ResponseHelper.buildResponse("ok");
}
/**
*根据sequenceNbr删除材料和附件
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@DeleteMapping(value = "IM/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除材料和附件", notes = "根据sequenceNbr删除材料和附件")
public ResponseModel<Boolean> deleteIMBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
attachmentMapper.deleteBySourceId(sequenceNbr);
return ResponseHelper.buildResponse(materialServiceImpl.removeById(sequenceNbr));
}
}
package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.WelderEquipmentDto;
import com.alibaba.fastjson.JSONObject;
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 org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -38,6 +41,9 @@ public class ProjectResourceController extends BaseController {
@Autowired
ProjectResourceServiceImpl projectResourceServiceImpl;
@Autowired
ProjectResourceMapper projectResourceMapper;
/**
* 新增项目资源表(包括焊工、管材、设备)
*
......@@ -178,4 +184,21 @@ public class ProjectResourceController extends BaseController {
public ResponseModel<ProjectResource> saveId(@RequestBody JSONObject jsonObject) {
return ResponseHelper.buildResponse(projectResourceServiceImpl.saveIds(jsonObject));
}
/**
* 项目管材分页列表,根据名称、编号查询
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/materialPage")
@ApiOperation(httpMethod = "GET", value = "焊机设备分页查询", notes = "焊机设备分页查询")
public ResponseModel<Page<MaterialDto>> queryForMaterialPage(
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "code", required = false) String code
) {
Page<MaterialDto> page = new Page<MaterialDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(projectResourceMapper.MaterialPage(page,name,code));
}
}
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.Attachment;
import com.yeejoin.amos.boot.module.ugp.api.mapper.AttachmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IAttachmentService;
......@@ -30,4 +33,29 @@ public class AttachmentServiceImpl extends BaseService<AttachmentDto,Attachment,
public List<AttachmentDto> queryForAttachmentList() {
return this.queryForList("" , false);
}
/**
* 根据sourceId添加附件
* @param subForm
* @param sequenceNbr
*
*/
public void saveAttachment(JSONArray subForm, Long sequenceNbr){
Attachment attachment = new Attachment();
for(Object o:subForm){
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(o));
jsonObject.getString("Symbol_key");
JSONArray jsonArray = jsonObject.getJSONArray("info");
for(Object j:jsonArray){
JSONObject info = JSON.parseObject(JSON.toJSONString(j));
String name = info.getString("name");
attachment.setSourceId(sequenceNbr);
attachment.setName(info.getString("name"));
attachment.setInfo(JSON.toJSONString(subForm));
attachment.setType(name.substring(name.lastIndexOf(".")+1));
this.save(attachment);
break;
}
}
}
}
\ No newline at end of file
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ugp.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.ugp.api.dto.MaterialDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.Attachment;
import com.yeejoin.amos.boot.module.ugp.api.entity.Equipment;
import com.yeejoin.amos.boot.module.ugp.api.entity.Material;
import com.yeejoin.amos.boot.module.ugp.api.mapper.AttachmentMapper;
import com.yeejoin.amos.boot.module.ugp.api.mapper.MaterialMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -22,11 +31,16 @@ import java.util.List;
*/
@Service
public class MaterialServiceImpl extends BaseService<MaterialDto, Material, MaterialMapper> implements IMaterialService {
@Autowired
AttachmentServiceImpl attachmentServiceImpl;
@Autowired
AttachmentMapper attachmentMapper;
/**
* 分页查询
*/
public Page<MaterialDto> queryForMaterialPage(Page<MaterialDto> page) {
return this.queryForPage(page, null, false);
public Page<MaterialDto> queryForMaterialPage(Page<MaterialDto> page,String name ,String code) {
return this.queryForPage(page, null, false,name,code);
}
/**
......@@ -57,4 +71,84 @@ public class MaterialServiceImpl extends BaseService<MaterialDto, Material, Mate
return names;
}
/**
* 新增材料
*/
@Override
public MaterialDto saveMaterial(JSONObject jsonObject){
MaterialDto materialDto = new MaterialDto();
materialDto.setRecDate(new Date());
materialDto.setName(jsonObject.getString("name"));
materialDto.setCode(jsonObject.getString("code"));
materialDto.setMaterial(jsonObject.getString("material"));
materialDto.setSpec(jsonObject.getString("spec"));
materialDto.setLength(jsonObject.getDouble("length"));
materialDto.setDiameter(jsonObject.getDouble("diameter"));
materialDto.setWallThickness(jsonObject.getInteger("wallThickness"));
materialDto.setManufacturer(jsonObject.getString("manufacturer"));
materialDto.setManufactureAddr(jsonObject.getString("manufactureAddr"));
materialDto.setManufactureDate(jsonObject.getDate("manufactureDate"));
materialDto.setBatchNum(jsonObject.getString("batchNum"));
MaterialDto result = this.createWithModel(materialDto);
return result;
}
/**
* 修改设备+附件信息
* @param sequenceNbr
* @param jsonObject
*/
public void updateMI(Long sequenceNbr,JSONObject jsonObject){
MaterialDto materialDto = this.queryBySeq(sequenceNbr);
LambdaQueryWrapper<Attachment> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Attachment::getSourceId,sequenceNbr);
Attachment attachment = attachmentServiceImpl.getOne(wrapper);
materialDto.setName(jsonObject.getString("name"));
materialDto.setCode(jsonObject.getString("code"));
materialDto.setMaterial(jsonObject.getString("material"));
materialDto.setSpec(jsonObject.getString("spec"));
materialDto.setLength(jsonObject.getDouble("length"));
materialDto.setDiameter(jsonObject.getDouble("diameter"));
materialDto.setWallThickness(jsonObject.getInteger("wallThickness"));
materialDto.setManufacturer(jsonObject.getString("manufacturer"));
materialDto.setManufactureAddr(jsonObject.getString("manufactureAddr"));
materialDto.setManufactureDate(jsonObject.getDate("manufactureDate"));
materialDto.setBatchNum(jsonObject.getString("batchNum"));
this.updateWithModel(materialDto);
JSONArray subForm = jsonObject.getJSONArray("subForm");
if(ValidationUtil.isEmpty(attachment)){
attachmentServiceImpl.saveAttachment(subForm,sequenceNbr);
}else {
attachment.setInfo(JSON.toJSONString(subForm));
attachmentServiceImpl.updateById(attachment);
}
}
/**
* 根据sequenceNbr查询材料的附件
*
* @param sequenceNbr 主键
* @return
*/
public JSONObject groupBySeq(Long sequenceNbr){
MaterialDto materialDto = queryBySeq(sequenceNbr);
AttachmentDto attachmentDto = attachmentMapper.selectAttBySeq(sequenceNbr);
JSONObject jsonObject = new JSONObject();
jsonObject.put("name",materialDto.getName());
jsonObject.put("code",materialDto.getCode());
jsonObject.put("material",materialDto.getMaterial());
jsonObject.put("spec",materialDto.getSpec());
jsonObject.put("length",materialDto.getLength());
jsonObject.put("diameter",materialDto.getDiameter());
jsonObject.put("wallThickness",materialDto.getWallThickness());
jsonObject.put("manufacturer",materialDto.getManufacturer());
jsonObject.put("manufactureAddr",materialDto.getManufactureAddr());
jsonObject.put("manufactureDate",materialDto.getManufactureDate());
jsonObject.put("batchNum",materialDto.getBatchNum());
if (attachmentDto != null){
JSONArray jsonArray = JSON.parseArray(attachmentDto.getInfo());
jsonObject.put("subForm",jsonArray);
}
return jsonObject;
}
}
\ 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