检验报告同步
This commit is contained in:
parent
3552543416
commit
422ff90370
|
|
@ -1,24 +1,27 @@
|
||||||
package com.bonus.material.ma.controller;
|
package com.bonus.material.ma.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||||
import com.bonus.material.ma.domain.Type;
|
import com.bonus.material.ma.domain.Type;
|
||||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.bonus.common.log.annotation.SysLog;
|
import com.bonus.common.log.annotation.SysLog;
|
||||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
import com.bonus.material.ma.domain.Machine;
|
import com.bonus.material.ma.domain.Machine;
|
||||||
|
|
@ -27,6 +30,7 @@ import com.bonus.common.core.web.controller.BaseController;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.page.TableDataInfo;
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机具设备管理Controller
|
* 机具设备管理Controller
|
||||||
|
|
@ -184,4 +188,70 @@ public class MachineController extends BaseController {
|
||||||
public AjaxResult getInfoByMaId(LeaseApplyInfo leaseApplyInfo) {
|
public AjaxResult getInfoByMaId(LeaseApplyInfo leaseApplyInfo) {
|
||||||
return success(machineService.getInfoByMaId(leaseApplyInfo));
|
return success(machineService.getInfoByMaId(leaseApplyInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取报告")
|
||||||
|
@PostMapping("/getReport")
|
||||||
|
public AjaxResult getReport(@RequestBody Machine machine){
|
||||||
|
try {
|
||||||
|
// 创建RestTemplate实例
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
// 设置请求头
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
// 创建请求参数
|
||||||
|
SortedMap<String, String> params = new TreeMap<>();
|
||||||
|
params.put("code", "12");
|
||||||
|
params.put("timeStamp", "12");
|
||||||
|
params.put("reportNum", machine.getReportCode());
|
||||||
|
params.put("sign", "12");
|
||||||
|
|
||||||
|
// 创建请求实体
|
||||||
|
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
|
||||||
|
// 发送POST请求
|
||||||
|
ResponseEntity<String> response = restTemplate.postForEntity(
|
||||||
|
"https://skjc.dunchong.cc/skjc/app/doc/getInfoByReportCodeV1",
|
||||||
|
requestEntity,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
// 处理响应
|
||||||
|
if (response.getStatusCode().is2xxSuccessful()) {
|
||||||
|
// 将返回的JSON字符串转换为对象
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.getBody());
|
||||||
|
// 如果code等于1,返回空的reportResponse
|
||||||
|
if ("1".equals(jsonObject.getString("code"))) {
|
||||||
|
return success(new Machine());
|
||||||
|
}
|
||||||
|
// 创建返回对象
|
||||||
|
Machine reportResponse = new Machine();
|
||||||
|
reportResponse.setNextCheckTimeSynch(jsonObject.getString("nextCheckTime"));
|
||||||
|
reportResponse.setCheckTimeSynch(jsonObject.getString("checkTime"));
|
||||||
|
reportResponse.setReportNum(jsonObject.getString("reportNum"));
|
||||||
|
reportResponse.setReportName(jsonObject.getString("reportName"));
|
||||||
|
reportResponse.setCode(jsonObject.getString("code"));
|
||||||
|
reportResponse.setPdf(jsonObject.getString("pdf"));
|
||||||
|
reportResponse.setSamples(jsonObject.getJSONArray("samples").toJavaList(SampleSync.class));
|
||||||
|
return success(reportResponse);
|
||||||
|
} else {
|
||||||
|
return error("接口调用失败,状态码:" + response.getStatusCodeValue());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检验报告同步
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "检验报告同步")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@PostMapping("/synchReport")
|
||||||
|
public AjaxResult synchReport(@RequestBody Machine machine)
|
||||||
|
{
|
||||||
|
return machineService.synchReport(machine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ package com.bonus.material.ma.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.bonus.common.core.annotation.Excel;
|
import com.bonus.common.core.annotation.Excel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -184,4 +187,27 @@ public class Machine extends BaseEntity
|
||||||
|
|
||||||
@ApiModelProperty("是否为机具 (0 代表机具)")
|
@ApiModelProperty("是否为机具 (0 代表机具)")
|
||||||
private Integer isJj;
|
private Integer isJj;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "报告编号")
|
||||||
|
private String reportCode;
|
||||||
|
|
||||||
|
|
||||||
|
private String nextCheckTimeSynch;
|
||||||
|
|
||||||
|
private String checkTimeSynch;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "报告编号")
|
||||||
|
private String reportNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "pdf")
|
||||||
|
private String pdf;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "code")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "报告名称")
|
||||||
|
private String reportName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "集合")
|
||||||
|
private List<SampleSync> samples;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.bonus.material.ma.domain.vo;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机具设备管理对象 ma_machine
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-09-27
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SampleSync extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
private String preCode;
|
||||||
|
|
||||||
|
private String sampleName;
|
||||||
|
|
||||||
|
private String tester;
|
||||||
|
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
private String itemNo;
|
||||||
|
|
||||||
|
private String selfCode;
|
||||||
|
|
||||||
|
private String checkPeriod;
|
||||||
|
|
||||||
|
private String nextCheckTimeSynch;
|
||||||
|
|
||||||
|
private String checkTimeSynch;
|
||||||
|
|
||||||
|
private String pdf;
|
||||||
|
|
||||||
|
private String reportName;
|
||||||
|
|
||||||
|
private String reportNum;
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
import com.bonus.material.ma.domain.Machine;
|
import com.bonus.material.ma.domain.Machine;
|
||||||
import com.bonus.material.ma.domain.Type;
|
import com.bonus.material.ma.domain.Type;
|
||||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,4 +135,10 @@ public interface MachineMapper
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Machine> getByMaCode(Machine machine);
|
List<Machine> getByMaCode(Machine machine);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步检验报告
|
||||||
|
*/
|
||||||
|
int updateSynchReport(SampleSync sampleSync);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,12 @@ public interface IMachineService
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Machine> getByMaCode(Machine machine);
|
List<Machine> getByMaCode(Machine machine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步报告
|
||||||
|
*
|
||||||
|
* @param machine 同步报告
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public AjaxResult synchReport(Machine machine);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||||
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
||||||
import com.bonus.material.ma.domain.Type;
|
import com.bonus.material.ma.domain.Type;
|
||||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.SampleSync;
|
||||||
import com.bonus.material.purchase.config.RemoteConfig;
|
import com.bonus.material.purchase.config.RemoteConfig;
|
||||||
import com.bonus.material.scrap.domain.ScrapApplyDetails;
|
import com.bonus.material.scrap.domain.ScrapApplyDetails;
|
||||||
import com.bonus.material.scrap.mapper.ScrapApplyDetailsMapper;
|
import com.bonus.material.scrap.mapper.ScrapApplyDetailsMapper;
|
||||||
|
|
@ -24,9 +25,13 @@ import org.springframework.stereotype.Service;
|
||||||
import com.bonus.material.ma.mapper.MachineMapper;
|
import com.bonus.material.ma.mapper.MachineMapper;
|
||||||
import com.bonus.material.ma.domain.Machine;
|
import com.bonus.material.ma.domain.Machine;
|
||||||
import com.bonus.material.ma.service.IMachineService;
|
import com.bonus.material.ma.service.IMachineService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.bonus.common.core.web.domain.AjaxResult.error;
|
||||||
|
import static com.bonus.common.core.web.domain.AjaxResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机具设备管理Service业务层处理
|
* 机具设备管理Service业务层处理
|
||||||
*
|
*
|
||||||
|
|
@ -120,9 +125,9 @@ public class MachineServiceImpl implements IMachineService
|
||||||
machine.setUpdateTime(DateUtils.getNowDate());
|
machine.setUpdateTime(DateUtils.getNowDate());
|
||||||
int result = machineMapper.updateMachine(machine);
|
int result = machineMapper.updateMachine(machine);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
return success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||||
}
|
}
|
||||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
return error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -148,9 +153,9 @@ public class MachineServiceImpl implements IMachineService
|
||||||
{
|
{
|
||||||
int result = machineMapper.deleteMachineByMaId(maId);
|
int result = machineMapper.deleteMachineByMaId(maId);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
return success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||||
}
|
}
|
||||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
return error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,7 +166,7 @@ public class MachineServiceImpl implements IMachineService
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult selectByTypeList(Type type) {
|
public AjaxResult selectByTypeList(Type type) {
|
||||||
List<Type> typeList = machineMapper.selectByTypeList(type);
|
List<Type> typeList = machineMapper.selectByTypeList(type);
|
||||||
return AjaxResult.success(typeList);
|
return success(typeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -192,7 +197,7 @@ public class MachineServiceImpl implements IMachineService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AjaxResult.success(typeList);
|
return success(typeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -263,4 +268,38 @@ public class MachineServiceImpl implements IMachineService
|
||||||
public List<Machine> getByMaCode(Machine machine) {
|
public List<Machine> getByMaCode(Machine machine) {
|
||||||
return machineMapper.getByMaCode(machine);
|
return machineMapper.getByMaCode(machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult synchReport(Machine machine)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
String pdfUrl = machine.getPdf();
|
||||||
|
String checkTime = machine.getCheckTimeSynch()+ " 00:00:00";
|
||||||
|
String nextCheckTime = machine.getNextCheckTimeSynch()+ " 00:00:00";
|
||||||
|
String reportName = machine.getReportName();
|
||||||
|
String reportNum = machine.getReportNum();
|
||||||
|
if(machine.getSamples()!=null && machine.getSamples().size()>0){
|
||||||
|
int numAll = 0;
|
||||||
|
for(SampleSync sample : machine.getSamples()){
|
||||||
|
sample.setCheckTimeSynch(checkTime);
|
||||||
|
sample.setNextCheckTimeSynch(nextCheckTime);
|
||||||
|
sample.setPdf(pdfUrl);
|
||||||
|
sample.setReportName(reportName);
|
||||||
|
sample.setReportNum(reportNum);
|
||||||
|
int result = machineMapper.updateSynchReport(sample);
|
||||||
|
numAll += result;
|
||||||
|
}
|
||||||
|
if(numAll>0){
|
||||||
|
return success("同步成功");
|
||||||
|
}else{
|
||||||
|
return error("同步失败,暂无相关的机具编码");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return error("同步失败,暂无相关的机具编码");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("同步报告失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -478,4 +478,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
delete from ma_machine where ma_code = #{maCode} and type_id = #{typeId}
|
delete from ma_machine where ma_code = #{maCode} and type_id = #{typeId}
|
||||||
and ma_status = '0'
|
and ma_status = '0'
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<update id="updateSynchReport" >
|
||||||
|
update ma_machine
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="tester != null">check_man = #{tester},inspect_man = #{tester},</if>
|
||||||
|
<if test="checkTimeSynch != null">this_check_time = #{checkTimeSynch},</if>
|
||||||
|
<if test="nextCheckTimeSynch != null">next_check_time = #{nextCheckTimeSynch},</if>
|
||||||
|
<if test="result != null">inspect_status = #{result},</if>
|
||||||
|
<if test="reportNum != null">ex_code = #{reportNum},</if>
|
||||||
|
<if test="pdf != null">ex_url = #{pdf},</if>
|
||||||
|
<if test="reportName != null">ex_name = #{reportName},</if>
|
||||||
|
ex_up_time = NOW(),
|
||||||
|
</trim>
|
||||||
|
where ma_code = #{selfCode}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue