add:增加一体机设备,工单,操作接口;

This commit is contained in:
2023-04-10 16:00:41 +08:00
parent 3dcbb17f75
commit f7acb14776
9 changed files with 1161 additions and 843 deletions

View File

@@ -76,8 +76,8 @@ public enum AcsTaskEnum {
JSONArray res = new JSONArray();
task.forEach(t -> {
JSONObject taskEnum = new JSONObject();
taskEnum.put("name", t.getDesc());
taskEnum.put("code", t.getCode());
taskEnum.put("text", t.getDesc());
taskEnum.put("value", t.getCode());
res.add(taskEnum);
});
return res;

View File

@@ -1,24 +1,21 @@
package org.nl.wms.mps.rest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.nl.common.anno.Log;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.api.ResultCode;
import org.nl.modules.common.exception.BizCoreException;
import org.nl.wms.mps.service.ProduceshiftorderService;
import org.nl.wms.mps.service.dto.ProduceshiftorderDto;
import org.nl.wms.mps.service.dto.DeviceDto;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@@ -30,16 +27,14 @@ import java.util.Map;
@RequiredArgsConstructor
@Api(tags = "一体机工单管理")
@RequestMapping("/api/produceshiftorder")
@SaIgnore
@Slf4j
public class ProduceshiftorderController {
public class ProduceshiftorderController{
private final ProduceshiftorderService produceshiftorderService;
@PostMapping("/getDevice")
@Log("根据登录用户设备下拉")
@ApiOperation("根据登录用户设备下拉")
//@PreAuthorize("@el.check('produceshiftorder:list')")
public ResponseEntity<Object> getDevice(@RequestBody JSONObject param) {
return new ResponseEntity<>(produceshiftorderService.getDevice(param), HttpStatus.OK);
}
@@ -52,29 +47,44 @@ public class ProduceshiftorderController {
return new ResponseEntity<>(produceshiftorderService.getTable(param), HttpStatus.OK);
}
@PostMapping("/getDeviceList")
@Log("一体机-根据登录人信息获取设备列表")
@ApiOperation("一体机-根据登录人信息获取设备列表")
public ResponseEntity<List<DeviceDto>> getDeviceList(@RequestBody JSONObject form) {
log.info("海亮一体机服务 [根据登录人信息获取设备列表] 接口被请求");
return new ResponseEntity<>(produceshiftorderService.getDeviceList(form.getString("search_bar")), HttpStatus.OK);
}
@PostMapping("/getOrderList")
@Log("一体机-工单管理列表")
@ApiOperation("一体机-工单管理列表")
public ResponseEntity<Object> getOrderList(@RequestBody Map<String,String> param, Pageable page) {
log.info("海亮一体机服务 [工单管理列表] 接口被请求, 请求参数-{}", param);
if(null == param) {
throw new BizCoreException(ResultCode.VALIDATE_FAILED);
}
return new ResponseEntity<>(produceshiftorderService.getOrderList(param, page), HttpStatus.OK);
}
@PostMapping("/openStart")
@Log("看板开工")
@ApiOperation("看板开工")
//@PreAuthorize("@el.check('produceshiftorder:list')")
public ResponseEntity<Object> openStart(@RequestBody JSONObject param) {
produceshiftorderService.openStart(param);
return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(produceshiftorderService.openStart(param), HttpStatus.OK);
}
@PostMapping("/saveReport")
@Log("看板报工")
@ApiOperation("看板报工")
public ResponseEntity<Object> saveReport(@RequestBody JSONObject param) {
produceshiftorderService.saveReport(param);
return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(produceshiftorderService.saveReport(param), HttpStatus.OK);
}
@PostMapping("/finish")
@Log("看板强制完成")
@ApiOperation("看板强制完成")
public ResponseEntity<Object> finish(@RequestBody JSONObject param) {
produceshiftorderService.finish(param);
return new ResponseEntity<>(HttpStatus.OK);
return new ResponseEntity<>(produceshiftorderService.finish(param), HttpStatus.OK);
}
@PostMapping("/getReportWork")
@@ -90,7 +100,7 @@ public class ProduceshiftorderController {
@ApiOperation("根据工序查询没有工单的设备")
//@PreAuthorize("@el.check('WorkProcedure:add')")
public ResponseEntity<Object> getNotWorkDeviceByWorkproceduceId(@RequestBody JSONObject param) {
return new ResponseEntity<>(produceshiftorderService.getNotWorkDeviceByWorkproceduceId(param),HttpStatus.CREATED);
return new ResponseEntity<>(produceshiftorderService.getNotWorkDeviceByWorkproceduceId(param), HttpStatus.CREATED);
}
@PostMapping("/replaceDevice")
@@ -98,7 +108,7 @@ public class ProduceshiftorderController {
@ApiOperation("更换工单设备")
public ResponseEntity<Object> replaceDevice(@RequestBody JSONObject param) {
produceshiftorderService.replaceDevice(param);
return new ResponseEntity<>( HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getUser")

View File

@@ -2,7 +2,9 @@ package org.nl.wms.mps.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.common.utils.api.CommonResult;
import org.nl.system.service.user.dao.SysUser;
import org.nl.wms.mps.service.dto.DeviceDto;
import org.nl.wms.mps.service.dto.ProduceshiftorderDto;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
@@ -12,22 +14,23 @@ import java.util.List;
import java.util.Map;
/**
* @description 服务接口
* @author qinx
* @date 2022-05-24
**/
public interface ProduceshiftorderService {
* @author qinx
* @description 服务接口
* @date 2022-05-24
**/
public interface ProduceshiftorderService{
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
* @return Map<String, Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
*
* @param whereJson 条件参数
* @return List<ProduceshiftorderDto>
*/
@@ -35,6 +38,7 @@ public interface ProduceshiftorderService {
/**
* 根据ID查询
*
* @param produceorder_id ID
* @return Produceshiftorder
*/
@@ -42,79 +46,108 @@ public interface ProduceshiftorderService {
/**
* 根据编码查询
*
* @param code code
* @return Produceshiftorder
*/
ProduceshiftorderDto findByCode(String code);
/**
* 创建
*
* @param dto /
*/
void create(ProduceshiftorderDto dto);
/**
* 编辑
*
* @param dto /
*/
void update(ProduceshiftorderDto dto);
/**
* 多选删除
*
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 根据当前登录用户下拉
*
* @param param
* @return
*/
JSONArray getDevice(JSONObject param);
/**
* 一体机获取设备列表
*
* @Param: form 请求参数
* @return: 设备列表
* @author gbx
* @date 2023/4/7
*/
List<DeviceDto> getDeviceList(String param);
/**
* 一体机-工单管理列表
*
* @return 工单列表
* @Param form 请求参数
* @author gbx
* @date 2023/04/7
*/
Map<String,Object> getOrderList(Map<String,String> param, Pageable page);
/**
* 获取工单生产记录
*
* @param param
* @return
*/
JSONArray getTable(JSONObject param);
/**
* 看板开工
* @param param
* 开工操作
*
* @param param 请求参数
*/
void openStart(JSONObject param);
CommonResult<Map<String,Object>> openStart(JSONObject param);
/**
* 看板报工
* @param param
* 报工操作
*
* @param param 请求参数
*/
void saveReport(JSONObject param);
CommonResult<Map<String,Object>> saveReport(JSONObject param);
/**
* 看板强制完成
* @param param
* 完工操作
*
* @param param 请求参数
*/
void finish(JSONObject param);
CommonResult<Map<String,Object>> finish(JSONObject param);
/**
* 获取当前报工记录
*
* @param param
* @return
*/
JSONObject getReportWork(JSONObject param);
/**
* 工单强制完成
*
* @param param
*/
void forceFinish(JSONObject param);
/**
* 获取当前工单下的工单生产记录
*
* @param param
* @return
*/
@@ -122,6 +155,7 @@ public interface ProduceshiftorderService {
/**
* excel工单批量导入
*
* @param file
* @param request
*/
@@ -129,6 +163,7 @@ public interface ProduceshiftorderService {
/**
* 更换设备时根据工单所属工序 查询所有工单中没有生产的设备
*
* @param param
* @return
*/
@@ -136,6 +171,7 @@ public interface ProduceshiftorderService {
/**
* 更换设备
*
* @param param
*/
void replaceDevice(JSONObject param);

View File

@@ -0,0 +1,58 @@
package org.nl.wms.mps.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 设备信息
*
* @author gbx
* @since 2023-04-10
*/
@Data
@SuppressWarnings("serial")
public class DeviceDto{
/**
* 设备编码
*/
@ApiModelProperty(value = "/**设备编码*/")
private String deviceCode;
/**
* 设备名称
*/
@ApiModelProperty(value = "/**设备名称*/")
private String deviceName;
/**
* 设备名称
*/
@ApiModelProperty(value = "/**设备名称*/")
private String device_status_name;
/**
* 工单编号
*/
@ApiModelProperty(value = "/**工单编号*/")
private String workorderCode;
/**
* 工单数
*/
@ApiModelProperty(value = "/**工单数*/")
private String job_count;
/**
* 设备状态
*/
@ApiModelProperty(value = "/**设备状态*/")
private String device_status;
/**
* 设备图标路径
*/
@ApiModelProperty(value = "/**设备图标路径*/")
private String device_icon;
/**
* 运行状态
*/
@ApiModelProperty(value = "/**运行状态*/")
private String is_run;
}

View File

@@ -1,7 +1,5 @@
package org.nl.wms.mps.service.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
@@ -15,14 +13,14 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.nl.common.anno.Log;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.enums.WorkerOrderEnum;
import org.nl.common.utils.MapOf;
import org.nl.common.utils.api.CommonResult;
import org.nl.common.utils.api.RestBusinessTemplate;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
@@ -33,8 +31,8 @@ import org.nl.wms.basedata.master.service.ClassstandardService;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.mps.service.ProduceshiftorderService;
import org.nl.wms.mps.service.WorkOrderImportEnum;
import org.nl.wms.mps.service.dto.DeviceDto;
import org.nl.wms.mps.service.dto.ProduceshiftorderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -53,18 +51,14 @@ import java.util.*;
@Service
@RequiredArgsConstructor
@Slf4j
public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public class ProduceshiftorderServiceImpl implements ProduceshiftorderService{
private final ClassstandardService classstandardService;
private final WmsToAcsService wmsToAcsService;
@Autowired
ISysUserService userService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
public Map<String,Object> queryAll(Map whereJson, Pageable page) {
String produceorder_code = MapUtil.getStr(whereJson, "produceorder_code");
String material = MapUtil.getStr(whereJson, "material");
String begin_time = MapUtil.getStr(whereJson, "begin_time");
@@ -83,27 +77,27 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
map.put("shift_type_scode", shift_type_scode);
map.put("begin_time", begin_time);
map.put("end_time", end_time);
if (StrUtil.isNotEmpty(order_status)) {
if(StrUtil.isNotEmpty(order_status)) {
order_status = order_status.replace("[\"", "").replace("\"]", "").replace("\"", "");
}
map.put("order_status", order_status);
map.put("is_error", is_error);
//处理状态为未完成
if (StrUtil.isNotEmpty(order_status) && order_status.contains("-1")) {
if(StrUtil.isNotEmpty(order_status) && order_status.contains("-1")) {
map.put("unFinish", "-1");
map.put("order_status", order_status.replace("-1", ""));
}
if (StrUtil.isNotEmpty(parent_id)) {
if(StrUtil.isNotEmpty(parent_id)) {
product_series = classstandardService.getChildIdStr(parent_id);
map.put("product_series", product_series);
}
if (StrUtil.isNotEmpty(produceorder_code)) {
if(StrUtil.isNotEmpty(produceorder_code)) {
map.put("produceorder_code", "%" + produceorder_code + "%");
}
if (StrUtil.isNotEmpty(material)) {
if(StrUtil.isNotEmpty(material)) {
map.put("material", "%" + material + "%");
}
if (StrUtil.isNotEmpty(sale_id)) {
if(StrUtil.isNotEmpty(sale_id)) {
map.put("sale_id", "%" + sale_id + "%");
}
WQLObject wo = WQLObject.getWQLObject("mps_bd_macoperaterecord");
@@ -115,7 +109,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public List<ProduceshiftorderDto> queryAll(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONArray arr = wo.query().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(arr)) {
if(ObjectUtil.isNotEmpty(arr)) {
return arr.toJavaList(ProduceshiftorderDto.class);
}
return null;
@@ -125,7 +119,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public ProduceshiftorderDto findById(Long produceorder_id) {
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject json = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
if(ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(ProduceshiftorderDto.class);
}
return null;
@@ -135,7 +129,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public ProduceshiftorderDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject json = wo.query("produceorder_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
if(ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(ProduceshiftorderDto.class);
}
return null;
@@ -145,10 +139,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
@Transactional(rollbackFor = Exception.class)
public void create(ProduceshiftorderDto dto) {
Integer orderNum = dto.getOrderNum();
for (Integer i = 0; i < orderNum; i++) {
for(Integer i = 0; i < orderNum; i++) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
CurrentUser currentUser = SecurityUtils.getCurrentUser();
String newCode = CodeUtil.getNewCode("PDM_SHIFTORDER");
dto.setProduce_date(dto.getProduce_date().substring(0, 10));
@@ -172,18 +165,14 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
@Transactional(rollbackFor = Exception.class)
public void update(ProduceshiftorderDto dto) {
ProduceshiftorderDto entity = this.findById(dto.getProduceorder_id());
if (entity == null) {
if(entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
dto.setUpdate_time(DateUtil.now());
dto.setUpdate_id(currentUserId);
dto.setUpdate_name(nickName);
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.update(json);
@@ -194,10 +183,8 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public void deleteAll(Long[] ids) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
for (Long produceorder_id : ids) {
for(Long produceorder_id : ids) {
JSONObject param = new JSONObject();
param.put("produceorder_id", String.valueOf(produceorder_id));
param.put("is_delete", "1");
@@ -208,7 +195,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
}
}
@Override
public JSONArray getDevice(JSONObject param) {
final String workprocedure_id = param.getString("workprocedure_id");
@@ -221,6 +207,84 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
return resultJSONArray;
}
/**
* 一体机获取设备列表
* 设备状态枚举1-关机、2-开机、3-生产中、4-待机、5-故障
*
* @author gbx
* @since 2023/4/7
*/
@Override
public List<DeviceDto> getDeviceList(String param) {
List<DeviceDto> list = WQL.getWO("ONEPART_QUERY").addParam("flag", "1").addParam("condition", param).process().getResultJSONArray(0).toJavaList(DeviceDto.class);
list.forEach(r -> {
//状态为为关机
if(StrUtil.isEmpty(r.getDevice_status())) {
r.setDevice_status("1");
r.setDevice_status_name("关机");
}
else{
//不是关机与故障状态则为运行
if(!Objects.equals(r.getDevice_status(), "1") && !Objects.equals(r.getDevice_status(), "5")) {
r.setIs_run("1");
}
else{
r.setIs_run("0");
}
}
//todo 当前工单数
r.setJob_count("1");
});
return list;
}
/**
* 一体机获取工单列表
*
* @author gbx
* @since 2023/4/7
*/
@Override
public Map<String,Object> getOrderList(Map<String,String> param, Pageable page) {
HashMap<String,String> map = new HashMap<>();
map.put("flag", "2");
Integer pageNumber = 0;
Integer pageSize = 20;
JSONObject whereJson = JSONObject.parseObject(JSON.toJSONString(param));
//设备编号
if(StrUtil.isNotEmpty(whereJson.getString("device_code"))) {
map.put("device_code", "%" + whereJson.getString("device_code") + "%");
}
//搜索条件
if(StrUtil.isNotEmpty(whereJson.getString("key_value"))) {
map.put("key_value", "%" + whereJson.getString("key_value") + "%");
}
//开始时间
if(StrUtil.isNotEmpty(whereJson.getString("realproducestart_date"))) {
map.put("realproducestart_date", whereJson.getString("realproducestart_date"));
}
//结束时间
if(StrUtil.isNotEmpty(whereJson.getString("realproduceend_date"))) {
map.put("realproduceend_date", whereJson.getString("realproduceend_date"));
}
//分页参数
if(StrUtil.isNotEmpty(whereJson.getString("page")) && StrUtil.isNotEmpty(whereJson.getString("size"))) {
pageNumber = whereJson.getInteger("page");
pageSize = whereJson.getInteger("size");
//暂时无分页
if(pageNumber == 1) {
pageNumber = 0;
pageSize = 100;
}
}
JSONObject jsonObject = WQL.getWO("ONEPART_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageNumber, pageSize), "workorder.create_time desc");
String size = jsonObject.getString("totalElements");
jsonObject.put("size", size);
//适配前端分页条件
jsonObject.remove("totalElements");
return jsonObject;
}
@Override
public JSONArray getTable(JSONObject param) {
//获取当前登录用户下的所有设备
@@ -228,7 +292,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
SysUser userDto = userService.getById(currentUserId);
Boolean isAdmin = userDto.getIsAdmin();
String jockey_id = String.valueOf(currentUserId);
if (isAdmin) {
if(isAdmin) {
jockey_id = "";
}
JSONObject map = new JSONObject();
@@ -239,96 +303,115 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
return resultJSONArray;
}
/**
* 开工操作
*
* @author gbx
* @since 2023/4/7
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void openStart(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
public CommonResult<Map<String,Object>> openStart(JSONObject param) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
//获取前台传入的开工的工单信息
String workorder_id = param.getString("workorder_id");
String device_code = param.getString("device_code");
//1-创建、2-下发、3-生产中、4-暂停、5-完成
JSONObject result = wo.query("current_device_code = '" + device_code + "' and workorder_status in ('2','3','4') and workorder_id != '" + workorder_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(result)) {
//判断该工单状态
if(ObjectUtil.isNotEmpty(result)) {
throw new BadRequestException("已有工单选择该设备开工,请更换开工设备!");
}
//TODO:开工时修改生产班次工单表 生产设备、以及工单状态
wo.update(MapOf.of("workorder_id",workorder_id,"workorder_status",WorkerOrderEnum.SEND.getCode(),"update_id", currentUserId,"update_name", nickName,"update_time", DateUtil.now()));
wo.update(MapOf.of("workorder_id", workorder_id, "workorder_status", WorkerOrderEnum.SEND.getCode(), "update_id", currentUserId, "update_name", nickName, "update_time", DateUtil.now()));
JSONArray array = new JSONArray();
JSONObject order = new JSONObject(MapOf.of("workorder_id", workorder_id,"type",WorkerOrderEnum.SEND.getCode()));
JSONObject order = new JSONObject(MapOf.of("workorder_id", workorder_id, "type", WorkerOrderEnum.SEND.getCode()));
array.add(order);
Map<String, Object> resp = wmsToAcsService.orderStatusUpdate(array);
String status = String.valueOf(resp.get("status"));
String message = (String) resp.get("message");
if (!status.equals("200")) {
throw new BadRequestException(message);
}
//下发acs
// Map<String,Object> resp = wmsToAcsService.orderStatusUpdate(array);
// return RestBusinessTemplate.execute(() -> resp);
return RestBusinessTemplate.execute(() -> new JSONObject());
}
/**
* 报工操作
*
* @author gbx
* @since 2023/4/7
*/
@Override
public void saveReport(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
public CommonResult<Map<String,Object>> saveReport(JSONObject param) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String report_qty = param.getString("report_qty");
String workorder_id = param.getString("workorder_id");
wo.update(MapOf.of("workorder_status",WorkerOrderEnum.STOP.getCode(),"real_qty",report_qty,"update_id",currentUserId,"update_name",nickName),"workorder_id = '"+workorder_id+"'");
//下发acs暂时
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
//1.更新工单表报工数量
wo.update(MapOf.of("workorder_status", WorkerOrderEnum.STOP.getCode(), "real_qty", report_qty, "update_id", currentUserId, "update_name", nickName), "workorder_id = '" + workorder_id + "'");
//2.下发acs更新暂停状态
JSONArray arr = new JSONArray();
arr.add(MapOf.of("workorder_id",workorder_id,"status", WorkerOrderEnum.STOP.getCode()));
wmsToAcsService.orderStatusUpdate(arr);
arr.add(MapOf.of("workorder_id", workorder_id, "status", WorkerOrderEnum.STOP.getCode()));
// Map<String,Object> resp = wmsToAcsService.orderStatusUpdate(arr);
//return RestBusinessTemplate.execute(() -> resp);
return RestBusinessTemplate.execute(() -> new JSONObject());
}
/**
* 完工操作
* 设备状态枚举1-关机、2-开机、3-生产中、4-待机、5-故障
*
* @author gbx
* @since 2023/4/7
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void finish(JSONObject param) {
public CommonResult<Map<String,Object>> finish(JSONObject param) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
//选中的工单信息
JSONObject row = param.getJSONObject("row");
//强制完成时修改工单状态
String produceorder_id = row.getString("produceorder_id");
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
ProduceshiftorderDto produceshiftorderDto = this.findById(Long.parseLong(produceorder_id));
JSONObject produceorderMap = new JSONObject();
produceorderMap.put("produceorder_id", produceorder_id);
produceorderMap.put("order_status", "04");
produceorderMap.put("update_optid", currentUserId);
produceorderMap.put("device_id", null);
produceorderMap.put("update_optname", nickName);
produceorderMap.put("update_time", DateUtil.now());
produceorderMap.put("realproduceend_date", DateUtil.now());
wo.update(produceorderMap);
JSONObject jsonObject = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
//1.强制完成时修改工单状态
String workorder_id = row.getString("workorder_id");
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
JSONObject map = new JSONObject();
map.put("produceorder_id", workorder_id);
map.put("workorder_status", "4");
map.put("current_device_code", null);
map.put("update_id", currentUserId);
map.put("update_name", nickName);
map.put("update_time", DateUtil.now());
map.put("realproduceend_date", DateUtil.now());
wo.update(map, "workorder_id = '" + workorder_id + "'");
//2.设置实际数量
JSONObject jsonObject = wo.query("workorder_id = '" + workorder_id + "'").uniqueResult(0);
String real_qty = jsonObject.getString("real_qty");
if (StrUtil.isEmpty(real_qty)) {
if(StrUtil.isEmpty(real_qty)) {
real_qty = "0";
}
//同时修改工单记录表中的期末数量及完成数量
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
JSONObject result = wo_record.query("produceorder_id = '" + produceorder_id + "' and (operatetime_end = '' or operatetime_end is null) ").uniqueResult(0);
if (ObjectUtil.isNotEmpty(result)) {
result.put("finish_qty", real_qty);
result.put("finishproduct_qty", real_qty);
//3.修改工单记录表中的期末数量及完成数量
WQLObject wo_record = WQLObject.getWQLObject("pdm_produce_workorderrecord");
JSONObject result = wo_record.query("workorder_id = '" + workorder_id + "' and (operatetime_end = '' or operatetime_end is null) ").uniqueResult(0);
if(ObjectUtil.isNotEmpty(result)) {
result.put("dq_finish_qty", real_qty);
result.put("person_finish_qty", real_qty);
result.put("operatetime_end", DateUtil.now());
wo_record.update(result);
}
//工单开工以后需要向acs强制完成 wms向acs发送请求 工单强制完成
// TODO
String order_status = produceshiftorderDto.getOrder_status();
if (!order_status.equals("00") && !order_status.equals("01")) {
//4.工单开工以后需要向acs强制完成,wms向acs发送请求,工单强制完成
String workorder_status = jsonObject.getString("workorder_status");
if(!workorder_status.equals("0") && !workorder_status.equals("1")) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("ext_order_id", produceorder_id);
map.put("type", "3");
array.add(map);
wmsToAcsService.orderStatusUpdate(array);
JSONObject acs = new JSONObject();
acs.put("ext_order_id", workorder_id);
acs.put("type", "3");
array.add(acs);
//Map<String,Object> resp = wmsToAcsService.orderStatusUpdate(array);
// return RestBusinessTemplate.execute(() -> resp);
return RestBusinessTemplate.execute(() -> new JSONObject());
}
return RestBusinessTemplate.execute(() -> new JSONObject());
}
@Override
@@ -365,17 +448,17 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
@Override
@Transactional(rollbackFor = Exception.class)
public void excelImport(MultipartFile file, HttpServletRequest request) {
if (file.isEmpty()) {
if(file.isEmpty()) {
throw new BadRequestException("文件为空,请添加数据后重新导入");
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
// 1.获取上传文件输入流
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
}
catch(Exception e) {
e.printStackTrace();
}
//工单表
@@ -388,7 +471,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
WQLObject wo_workprocedure = WQLObject.getWQLObject("pdm_bi_workprocedure");
//人员表
//WQLObject wo_user = WQLObject.getWQLObject("sys_user");
// 调用用 hutool 方法读取数据 调用第一个sheet白班数据
ExcelReader excelReader = ExcelUtil.getReader(inputStream, 0);
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list外层是行内层是行对应的所有列
@@ -396,9 +478,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String produce_date = "";
// 循环获取的数据
row:
for (int i = 0; i < read.size(); i++) {
for(int i = 0; i < read.size(); i++) {
List<Object> list = read.get(i);
if (ObjectUtil.isEmpty(list)) {
if(ObjectUtil.isEmpty(list)) {
continue;
}
//获取每列
@@ -415,92 +497,96 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String error_message = "";
//循环每一行
col:
for (int j = 0; j < list.size(); j++) {
for(int j = 0; j < list.size(); j++) {
String col = String.valueOf(list.get(j));
//如果是第一行 为生产日期
if (i == 0 && j == 0) {
if(i == 0 && j == 0) {
produce_date = col.split("")[col.split("").length - 1];
continue row;
}
//如果第一列包含规格二字 则为表头 结束内循环列
if (j == 0 && col.contains("规格名称")) {
if(j == 0 && col.contains("规格名称")) {
continue row;
}
if (j == 0) {
if(j == 0) {
//物料
if (StrUtil.isEmpty(col)) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "物料规格为空,";
}
JSONObject json_material = wo_material.query("is_delete = '0' and material_spec = '" + col + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_material)) {
if(ObjectUtil.isEmpty(json_material)) {
is_error = "1";
error_message = error_message + "物料规格对应物料信息不存在,";
}else {
}
else{
param.put("material_id", json_material.getString("material_id"));
}
}
if (j == 2) {
if (StrUtil.isEmpty(col)) {
if(j == 2) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "工序名称为空,";
}
WorkOrderImportEnum idByName = WorkOrderImportEnum.getIdByName(col);
if (ObjectUtil.isEmpty(idByName)) {
if(ObjectUtil.isEmpty(idByName)) {
is_error = "1";
error_message = error_message + "工序名称是否正确,";
}else {
}
else{
param.put("workprocedure_id", idByName.getId());
}
}
if (j == 4) {
if(j == 4) {
//单重
param.put("material_weight", col);
}
if (j == 6) {
if (StrUtil.isEmpty(col)) {
if(j == 6) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "工单计划数量为空,";
}else {
}
else{
param.put("plan_qty", col);
}
}
if (j == 10) {
if(j == 10) {
String workprocedure_id = param.getString("workprocedure_id");
JSONObject json_device = wo_device.query("is_delete = '0' and device_code = '" + col + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_device)) {
if(ObjectUtil.isEmpty(json_device)) {
is_error = "1";
error_message = error_message + "设备编码不存在,";
}
if (!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
if(!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
is_error = "1";
error_message = error_message + "设备与所属工序不匹配,";
}else {
}
else{
param.put("device_id", json_device.getString("device_id"));
}
}
if (j == 11) {
if(j == 11) {
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
if (ObjectUtil.isEmpty(jsonUser)) {
if(ObjectUtil.isEmpty(jsonUser)) {
is_error = "1";
error_message = error_message + "生产人员编码不存在!";
}else {
}
else{
param.put("jockey_id", jsonUser.getUserId());
}
}
if (j == 12) {
if(j == 12) {
//允许修改报工数量
String is_canupdate = "0";
if (col.equals("")) {
if(col.equals("")) {
is_canupdate = "1";
}
param.put("is_canupdate_update", is_canupdate);
}
if (j == 13) {
if(j == 13) {
//是否agv搬运
String needmoce = "0";
if (col.equals("")) {
if(col.equals("")) {
needmoce = "1";
}
param.put("is_needmove", needmoce);
@@ -515,12 +601,12 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
param.put("create_time", DateUtil.now());
wo_order.insert(param);
}
// 1.获取上传文件输入流
inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
}
catch(Exception e) {
e.printStackTrace();
}
//读取夜班工单数据
@@ -530,7 +616,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String error_message = "";
// 循环获取的数据
row:
for (int i = 0; i < read.size(); i++) {
for(int i = 0; i < read.size(); i++) {
List<Object> list = read.get(i);
//获取每列
JSONObject param = new JSONObject();
@@ -544,100 +630,104 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
param.put("shift_type_scode", "02");
//循环每一行
col:
for (int j = 0; j < list.size(); j++) {
for(int j = 0; j < list.size(); j++) {
String col = String.valueOf(list.get(j));
//如果是第一行 为生产日期
if (i == 0 && j == 0) {
if(i == 0 && j == 0) {
produce_date = col.split("")[col.split("").length - 1];
continue row;
}
//如果第一列包含规格二字 则为表头 结束内循环列
if (j == 0 && col.contains("规格名称")) {
if(j == 0 && col.contains("规格名称")) {
continue row;
}
if (j == 0) {
if(j == 0) {
//物料
if (StrUtil.isEmpty(col)) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "物料规格为空,";
}
JSONObject json_material = wo_material.query("is_delete = '0' and material_spec = '" + col + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_material)) {
if(ObjectUtil.isEmpty(json_material)) {
is_error = "1";
error_message = error_message + "物料规格对应物料信息不存在,";
}else {
}
else{
param.put("material_id", json_material.getString("material_id"));
}
}
if (j == 2) {
if (StrUtil.isEmpty(col)) {
if(j == 2) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "工序名称为空,";
}
WorkOrderImportEnum idByName = WorkOrderImportEnum.getIdByName(col);
if (ObjectUtil.isEmpty(idByName)) {
if(ObjectUtil.isEmpty(idByName)) {
is_error = "1";
error_message = error_message + "工序名称是否正确,";
}else {
}
else{
param.put("workprocedure_id", idByName.getId());
}
}
if (j == 4) {
if(j == 4) {
//单重
param.put("material_weight", col);
}
if (j == 6) {
if (StrUtil.isEmpty(col)) {
if(j == 6) {
if(StrUtil.isEmpty(col)) {
is_error = "1";
error_message = error_message + "工单计划数量为空,";
}else {
}
else{
param.put("plan_qty", col);
}
}
// if (j == 10) {
// //物料
// JSONObject json_material = wo_material.query("is_delete = '0' and material_code = '" + col + "'").uniqueResult(0);
// if (ObjectUtil.isEmpty(json_material)) {
// throw new BadRequestException("第'" + (i + 2) + "'行,物料编码不存在");
// }
// param.put("material_id", json_material.getString("material_id"));
// }
if (j == 10) {
// if (j == 10) {
// //物料
// JSONObject json_material = wo_material.query("is_delete = '0' and material_code = '" + col + "'").uniqueResult(0);
// if (ObjectUtil.isEmpty(json_material)) {
// throw new BadRequestException("第'" + (i + 2) + "'行,物料编码不存在");
// }
// param.put("material_id", json_material.getString("material_id"));
// }
if(j == 10) {
String workprocedure_id = param.getString("workprocedure_id");
JSONObject json_device = wo_device.query("is_delete = '0' and device_code = '" + col + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_device)) {
if(ObjectUtil.isEmpty(json_device)) {
is_error = "1";
error_message = error_message + "设备编码不存在,";
}
if (!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
if(!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
is_error = "1";
error_message = error_message + "设备与所属工序不匹配,";
}else {
}
else{
param.put("device_id", json_device.getString("device_id"));
}
}
if (j == 11) {
if(j == 11) {
SysUser jsonUser = userService.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
if (ObjectUtil.isEmpty(jsonUser)) {
if(ObjectUtil.isEmpty(jsonUser)) {
is_error = "1";
error_message = error_message + "生产人员编码不存在!";
}else {
}
else{
param.put("jockey_id", jsonUser.getUserId());
}
}
if (j == 12) {
if(j == 12) {
//允许修改报工数量
String is_canupdate = "0";
if (col.equals("")) {
if(col.equals("")) {
is_canupdate = "1";
}
param.put("is_canupdate_update", is_canupdate);
}
if (j == 13) {
if(j == 13) {
//是否agv搬运
String needmoce = "0";
if (col.equals("")) {
if(col.equals("")) {
needmoce = "1";
}
param.put("is_needmove", needmoce);
@@ -647,13 +737,12 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
param.put("error_info", error_message);
param.put("planproducestart_date", produce_date + "18:30:00");
DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(produce_date), 1);
param.put("planproduceend_date", DateUtil.format(dateTime,"yyyy-MM-dd") + " 07:30:00");
param.put("planproduceend_date", DateUtil.format(dateTime, "yyyy-MM-dd") + " 07:30:00");
param.put("create_id", currentUserId);
param.put("create_name", nickName);
param.put("create_time", DateUtil.now());
wo_order.insert(param);
}
}
@Override
@@ -664,20 +753,21 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
map.put("workproceduce_id", workproceduce_id);
JSONArray devices = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).process().getResultJSONArray(0);
StringBuilder sb = new StringBuilder();
if (ObjectUtil.isNotEmpty(devices)) {
if(ObjectUtil.isNotEmpty(devices)) {
sb.append("(");
for (int i = 0; i < devices.size(); i++) {
for(int i = 0; i < devices.size(); i++) {
JSONObject device = devices.getJSONObject(i);
String device_id = device.getString("device_id");
if (devices.size() - 1 == i) {
if(devices.size() - 1 == i) {
sb.append("'" + device_id + "')");
}
if (devices.size() - 1 != i) {
if(devices.size() - 1 != i) {
sb.append("'" + device_id + "',");
}
}
param.put("device_ids", sb.toString());
} else {
}
else{
param.put("device_ids", "('-1')");
}
param.put("flag", "7");
@@ -694,23 +784,22 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String device_code = param.getString("device_code");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
ProduceshiftorderDto produceshiftorderDto = this.findByCode(produceorder_code);
produceshiftorderDto.setDevice_id(Long.parseLong(device_id));
produceshiftorderDto.setUpdate_id(currentUserId);
produceshiftorderDto.setUpdate_name(nickName);
produceshiftorderDto.setUpdate_time(DateUtil.now());
String order_status = produceshiftorderDto.getOrder_status();
if (!order_status.equals("03") && !order_status.equals("01") && !order_status.equals("00")) {
if(!order_status.equals("03") && !order_status.equals("01") && !order_status.equals("00")) {
JSONArray array = new JSONArray();
JSONObject acsObj = new JSONObject();
acsObj.put("order_code", produceorder_code);
acsObj.put("device_code", device_code);
array.add(acsObj);
Map<String, Object> resp = wmsToAcsService.replaceDevice(array);
Map<String,Object> resp = wmsToAcsService.replaceDevice(array);
String status = String.valueOf(resp.get("status"));
String message = (String) resp.get("message");
if (!status.equals("200")) {
if(!status.equals("200")) {
throw new BadRequestException(message);
}
}
@@ -721,5 +810,4 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public List<SysUser> getUser() {
return userService.list(new QueryWrapper<SysUser>().select("user_id,person_name"));
}
}

View File

@@ -0,0 +1,126 @@
[交易说明]
交易名: pda手持服务查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.device_code TYPEAS s_string
输入.key_value TYPEAS s_string
输入.realproducestart_date TYPEAS s_string
输入.realproduceend_date TYPEAS s_string
输入.flag TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
s.label device_status_name,
r.status_type device_status,
d.device_code,
d.device_name,
d.device_icon,
d.workorder_code
FROM
pdm_bi_device d
LEFT JOIN (
SELECT
device_code,
status_type,
max( order_num ) AS num
FROM
( SELECT order_num, device_code, status_type FROM pdm_bi_devicerunstatusrecord ORDER BY device_code, order_num DESC ) c
GROUP BY
c.device_code
) r ON d.device_code = r.device_code
LEFT JOIN sys_dict s ON s.`value` = r.status_type
AND s.`code` = 'PDM_BI_DEVICERUNSTATUS'
ORDER BY
device_code
LIMIT 10
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
PAGEQUERY
SELECT
dict1.label shift_type_scode_name,
dict2.label order_status_name,
mater.material_name,
workorder.shift_type_scode,
workprocedure.workprocedure_name,
workorder.workorder_status order_status,
workorder.workorder_id,
workorder.workorder_code,
workorder.current_device_code device_code,
workorder.material_id,
workorder.workprocedure_id,
workorder.plan_qty,
workorder.real_qty,
workorder.report_qty,
workorder.realproducestart_date,
workorder.realproduceend_date
FROM
pdm_produce_workorder workorder
LEFT JOIN md_me_materialbase mater ON workorder.material_id = mater.material_id
LEFT JOIN pdm_bi_workprocedure workprocedure ON workorder.workprocedure_id = workprocedure.workprocedure_id
LEFT JOIN sys_dict dict1 ON dict1.`value` = workorder.shift_type_scode
AND dict1.`code` = 'PDM_BI_SHIFTTYPE'
LEFT JOIN sys_dict dict2 ON dict2.`value` = workorder.workorder_status
AND dict2.`code` = 'MPS_BD_ORDERSTATUS'
WHERE
workorder.is_delete = '0'
OPTION 输入.device_code <> ""
(workorder.current_device_code like CONCAT ('%', 输入.device_code, '%'))
ENDOPTION
OPTION 输入.key_value <> ""
(
(workorder.workorder_code like CONCAT ('%', 输入.key_value, '%')) or
(mater.material_name like CONCAT ('%', 输入.key_value, '%')) or
(mater.material_code like CONCAT ('%', 输入.key_value, '%'))
)
ENDOPTION
OPTION 输入.realproducestart_date <> ""
workorder.realproducestart_date >= 输入.realproducestart_date
ENDOPTION
OPTION 输入.realproduceend_date <> ""
workorder.realproduceend_date <= 输入.realproduceend_date
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -163,8 +163,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
map.put("product_area", whereJson.getString("product_area"));
}
//任务类型
if(StrUtil.isNotEmpty(whereJson.getString("task_type"))) {
map.put("task_type", whereJson.getString("task_type"));
if(StrUtil.isNotEmpty(whereJson.getString("code"))) {
map.put("task_type", whereJson.getString("code"));
}
if(StrUtil.isNotEmpty(task_status)) {
task_status = task_status.replace("[\"", "").replace("\"]", "").replace("\"", "");

View File

@@ -82,7 +82,7 @@ public class TaskController {
.eq(Dict::getCode, "task_status")), HttpStatus.OK);
}
@GetMapping("/taskType")
@PostMapping("/taskType")
@Log("获取任务类型列表")
@ApiOperation("获取任务类型列表")
public ResponseEntity<Object> getTaskType() {