Commit 67b0888c authored by srx's avatar srx

设备附件查看

parent a192b998
package com.yeejoin.amos.boot.module.ugp.biz.controller; package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.ugp.api.dto.AttachmentDto; import com.yeejoin.amos.boot.module.ugp.api.dto.AttachmentDto;
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.mapper.AttachmentMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.AttachmentMapper;
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.biz.service.impl.AttachmentServiceImpl;
import org.springframework.beans.BeanUtils;
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;
...@@ -15,6 +21,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController; ...@@ -15,6 +21,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.Date; import java.util.Date;
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.foundation.utils.ValidationUtil;
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;
...@@ -45,6 +52,9 @@ public class EquipmentController extends BaseController { ...@@ -45,6 +52,9 @@ public class EquipmentController extends BaseController {
@Autowired @Autowired
AttachmentMapper attachmentMapper; AttachmentMapper attachmentMapper;
@Autowired
AttachmentServiceImpl attachmentService;
/** /**
* 新增设备信息表 * 新增设备信息表
* *
...@@ -154,7 +164,7 @@ public class EquipmentController extends BaseController { ...@@ -154,7 +164,7 @@ public class EquipmentController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping (value = "/saveIE") @PostMapping (value = "/saveIE")
@ApiOperation(httpMethod = "Post", value = "新增设备+附件", notes = "新增设备+附件") @ApiOperation(httpMethod = "POST", value = "新增设备+附件", notes = "新增设备+附件")
public ResponseModel<EquipmentDto> saveEquipment(@RequestBody JSONObject object) { public ResponseModel<EquipmentDto> saveEquipment(@RequestBody JSONObject object) {
EquipmentDto equipmentDto = equipmentServiceImpl.saveEI(object); EquipmentDto equipmentDto = equipmentServiceImpl.saveEI(object);
Long sequenceNbr = equipmentDto.getSequenceNbr(); Long sequenceNbr = equipmentDto.getSequenceNbr();
...@@ -186,21 +196,49 @@ public class EquipmentController extends BaseController { ...@@ -186,21 +196,49 @@ public class EquipmentController extends BaseController {
public ResponseModel<JSONObject> selectIEOne(@PathVariable Long sequenceNbr) { public ResponseModel<JSONObject> selectIEOne(@PathVariable Long sequenceNbr) {
EquipmentDto equipmentDto = equipmentServiceImpl.queryBySeq(sequenceNbr); EquipmentDto equipmentDto = equipmentServiceImpl.queryBySeq(sequenceNbr);
AttachmentDto attachmentDto = attachmentMapper.selectAttBySeq(sequenceNbr);
AttachmentDto attachmentDto = null;
JSONObject jsonObject = new JSONObject(); try {
jsonObject.put("name",equipmentDto.getName()); attachmentDto = attachmentMapper.selectAttBySeq(sequenceNbr);
jsonObject.put("type",equipmentDto.getType()); } catch (Exception e) {
jsonObject.put("code",equipmentDto.getCode()); e.printStackTrace();
jsonObject.put("manufacturer",equipmentDto.getManufacturer()); }finally {
jsonObject.put("manufactureDate",equipmentDto.getManufactureDate()); JSONObject jsonObject = new JSONObject();
jsonObject.put("serviceLife",equipmentDto.getServiceLife()); jsonObject.put("name",equipmentDto.getName());
jsonObject.put("inspectionDate",equipmentDto.getInspectionDate()); jsonObject.put("type",equipmentDto.getType());
jsonObject.put("useStatus",equipmentDto.getUseStatus()); jsonObject.put("code",equipmentDto.getCode());
jsonObject.put("verifyStatus",equipmentDto.getVerifyStatus()); jsonObject.put("manufacturer",equipmentDto.getManufacturer());
jsonObject.put("subForm",JSON.parseArray(attachmentDto.getInfo())); jsonObject.put("manufactureDate",equipmentDto.getManufactureDate());
jsonObject.put("serviceLife",equipmentDto.getServiceLife());
return ResponseHelper.buildResponse(jsonObject); jsonObject.put("inspectionDate",equipmentDto.getInspectionDate());
jsonObject.put("useStatus",equipmentDto.getUseStatus());
jsonObject.put("verifyStatus",equipmentDto.getVerifyStatus());
JSONArray jsonArray = new JSONArray();
try{
jsonArray = JSON.parseArray(attachmentDto.getInfo());
} catch (Exception e){
}
jsonObject.put("subForm",jsonArray);
return ResponseHelper.buildResponse(jsonObject);
}
} }
/**
* 根据sequenceNbr更新设备的附件
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "IE/{sequenceNbr}")
@ApiOperation(httpMethod = "POST",value = "根据sequenceNbr更新设备和附件", notes = "根据sequenceNbr更新设备和附件")
public ResponseModel<String> selectIEOne(@PathVariable Long sequenceNbr,@RequestBody JSONObject object) {
equipmentServiceImpl.updateEI(sequenceNbr,object);
return ResponseHelper.buildResponse("ok");
}
} }
...@@ -7,8 +7,10 @@ import com.alibaba.fastjson.JSON; ...@@ -7,8 +7,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.api.dto.AttachmentDto; import com.yeejoin.amos.boot.module.ugp.api.dto.AttachmentDto;
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.Equipment;
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.AttachmentMapper;
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.mapper.ProjectMapper; import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IEquipmentService; import com.yeejoin.amos.boot.module.ugp.api.service.IEquipmentService;
...@@ -93,26 +95,29 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto, Equipment, E ...@@ -93,26 +95,29 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto, Equipment, E
public void saveAttachment(JSONObject object,Long SequenceNbr){ public void saveAttachment(JSONObject object,Long SequenceNbr){
AttachmentDto attachmentDto = new AttachmentDto(); AttachmentDto attachmentDto = new AttachmentDto();
JSONArray subForm = object.getJSONArray("subForm"); JSONArray subForm = object.getJSONArray("subForm");
for(Object o:subForm){ if (!subForm.isEmpty()){
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(o)); for(Object o:subForm){
jsonObject.getString("Symbol_key"); JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(o));
JSONArray jsonArray = jsonObject.getJSONArray("info"); jsonObject.getString("Symbol_key");
for(Object j:jsonArray){ JSONArray jsonArray = jsonObject.getJSONArray("info");
JSONObject info = JSON.parseObject(JSON.toJSONString(j)); for(Object j:jsonArray){
String name = info.getString("name"); JSONObject info = JSON.parseObject(JSON.toJSONString(j));
attachmentDto.setSourceId(SequenceNbr); String name = info.getString("name");
attachmentDto.setName(info.getString("name")); attachmentDto.setSourceId(SequenceNbr);
attachmentDto.setName(info.getString("name"));
// attachmentDto.setInfo("name: "+name+","+ // attachmentDto.setInfo("name: "+name+","+
// "type: "+name.substring(name.lastIndexOf(".")+1)+","+ // "type: "+name.substring(name.lastIndexOf(".")+1)+","+
// "path: "+info.getString("url")+","+ // "path: "+info.getString("url")+","+
// "certCode: "+jsonObject.getString("certCode")+","+ // "certCode: "+jsonObject.getString("certCode")+","+
// "certType: "+jsonObject.getString("certType")); // "certType: "+jsonObject.getString("certType"));
attachmentDto.setInfo(JSON.toJSONString(subForm)); attachmentDto.setInfo(JSON.toJSONString(subForm));
attachmentDto.setType(name.substring(name.lastIndexOf(".")+1)); attachmentDto.setType(name.substring(name.lastIndexOf(".")+1));
attachmentServiceImpl.createWithModel(attachmentDto); attachmentServiceImpl.createWithModel(attachmentDto);
break; break;
}
} }
} }
} }
@Override @Override
...@@ -131,4 +136,35 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto, Equipment, E ...@@ -131,4 +136,35 @@ public class EquipmentServiceImpl extends BaseService<EquipmentDto, Equipment, E
return result; return result;
} }
/**
* 修改设备+附件信息
* @param sequenceNbr
* @param object
*/
public void updateEI(Long sequenceNbr,JSONObject object){
Equipment model = this.getById(sequenceNbr);
LambdaQueryWrapper<Attachment> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Attachment::getSourceId,sequenceNbr);
Attachment attachment = attachmentServiceImpl.getOne(wrapper);
// AttachmentDto attachmentDto = attachmentMapper.selectAttBySeq(sequenceNbr);
model.setName(object.getString("name"));
model.setType(object.getString("type"));
model.setCode(object.getString("code"));
model.setManufacturer(object.getString("manufacturer"));
model.setManufactureDate(object.getDate("manufactureDate"));
model.setServiceLife(object.getString("serviceLife"));
model.setInspectionDate(object.getDate("inspectionDate"));
model.setUseStatus(object.getString("useStatus"));
model.setVerifyStatus(object.getString("verifyStatus"));
updateById(model);
JSONArray subForm = object.getJSONArray("subForm");
attachment.setInfo(JSON.toJSONString(subForm));
// new Attachment();
// BeanUtils.copyProperties(attachmentDto,attachment);
attachmentServiceImpl.updateById(attachment);
}
} }
\ 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