This commit is contained in:
2022-07-09 23:14:56 +08:00
parent 41fa644bf0
commit adf182f1d9
4 changed files with 128 additions and 0 deletions

View File

@@ -151,4 +151,25 @@ public class SparePartController {
public ResponseEntity<Object> queryDevice(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.queryDevice(whereJson),HttpStatus.OK);
}
@PostMapping("/queryRunRecord")
@Log("运行记录查询")
@ApiOperation("运行记录查询")
public ResponseEntity<Object> queryRunRecord(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.queryRunRecord(whereJson),HttpStatus.OK);
}
@PostMapping("/calculate")
@Log("计算")
@ApiOperation("计算")
public ResponseEntity<Object> calculate(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.calculate(whereJson),HttpStatus.OK);
}
@PostMapping("/save")
@Log("保存")
@ApiOperation("保存")
public ResponseEntity<Object> save(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.save(whereJson),HttpStatus.OK);
}
}

View File

@@ -45,5 +45,11 @@ public interface SparePartService {
Map<String, Object> queryDevice(Map jsonObject);
Map<String, Object> queryRunRecord(Map jsonObject);
Map<String, Object> calculate(Map jsonObject);
Map<String, Object> save(Map jsonObject);
Map<String, Object> repairs(Map map, HttpServletRequest request);
}

View File

@@ -45,6 +45,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -706,6 +707,83 @@ public class SparePartServiceImpl implements SparePartService {
return returnjo;
}
@Override
public Map<String, Object> queryRunRecord(Map jsonObject) {
if (ObjectUtil.isEmpty(jsonObject)) {
throw new PdaRequestException("传入参数不能为空!");
}
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject));
String device_code = jo.getString("device_code");
JSONObject content = WQL.getWO("QPDAEM_BI_SPAREPART").addParam("flag","7").addParam("device_code",device_code).process().uniqueResult(0);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("content", content);
returnjo.put("desc", "操作成功!");
return returnjo;
}
@Override
public Map<String, Object> calculate(Map jsonObject) {
if (ObjectUtil.isEmpty(jsonObject)) {
throw new PdaRequestException("传入参数不能为空!");
}
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject));
JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("device_code = '" + jo.getString("device_code") + "'").uniqueResult(0);
double run_times = jo.getDoubleValue("run_times"); //生产时间
double prepare_times = jo.getDoubleValue("prepare_times");//准备时间
double error_times = jo.getDoubleValue("error_times"); //故障时间
double adjust_times = jo.getDoubleValue("adjust_times"); //工装调整时间
double product_qty = jo.getDoubleValue("product_qty"); //生产总量
double nok_qty = jo.getDoubleValue("nok_qty"); //不合格数
double theory_beat = jsonFile.getDoubleValue("theory_beat"); // 理论节拍
JSONObject content = new JSONObject();
// 计算OEE指标
try {
BigDecimal div = NumberUtil.div(NumberUtil.sub(run_times, prepare_times, error_times, adjust_times), NumberUtil.sub(run_times, prepare_times, adjust_times));
BigDecimal div1 = NumberUtil.div(NumberUtil.mul(div, theory_beat, product_qty), NumberUtil.sub(run_times, prepare_times, error_times, adjust_times));
BigDecimal oee_value = NumberUtil.mul(div1, NumberUtil.div(NumberUtil.sub(product_qty, nok_qty), product_qty));
content.put("oee_value", oee_value);
} catch (Exception e) {
content.put("oee_value", 0);
}
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("content", content);
returnjo.put("desc", "操作成功!");
return returnjo;
}
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> save(Map jsonObject) {
if (ObjectUtil.isEmpty(jsonObject)) {
throw new PdaRequestException("传入参数不能为空!");
}
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject));
String device_code = jo.getString("device_code");
JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("device_code = '" + jo.getString("device_code") + "' AND is_delete = '0' AND status IN (10,11,20,30,40)").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonFile)){
throw new PdaRequestException("设备不存在!");
}
JSONObject run = WQLObject.getWQLObject("EM_BI_DeviceRunRecord").query("devicerecord_id = '"+jsonFile.getString("devicerecord_id")+"' AND run_date = '"+jo.getString("run_date")+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(run)){
}
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "操作成功!");
return returnjo;
}
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> repairs(Map map, HttpServletRequest request) {

View File

@@ -244,5 +244,28 @@
ENDQUERY
ENDIF
IF 输入.flag = "7"
QUERY
SELECT
file.device_code,
run.run_times,
run.prepare_times,
run.error_times,
run.adjust_times,
run.product_qty,
run.nok_qty,
run.oee_value
FROM
em_bi_equipmentfile file
LEFT JOIN em_bi_devicerunrecord run ON run.devicerecord_id = file.devicerecord_id
WHERE
file.is_delete = '0'
OPTION 输入.device_code <> ""
file.device_code = 输入.device_code
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF