forked from I3-YF/i3plus-mes-yfai
根据物料工位分组分页查询设备加工记录
parent
26834c591c
commit
32b76ad88d
@ -0,0 +1,49 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.api.base.IMesProductionRecordService;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Description : 设备加工记录表
|
||||
* @Reference :
|
||||
* @Author : gsz
|
||||
* @CreateDate 2024/8/10 10:50
|
||||
* @Modify:
|
||||
**/
|
||||
@Api("设备加工记录")
|
||||
@RestController
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesProductionRecord")
|
||||
public class MesProductionRecordController extends BaseMesController<MesProductionRecord>{
|
||||
@Autowired
|
||||
private IMesProductionRecordService mesProductionRecordService;
|
||||
|
||||
@GetMapping(value = "/group-by-part-cell/query")
|
||||
@ApiOperation(value = "设备加工记录", notes = "设备加工记录")
|
||||
public ResultBean queryProductionRecordGroupByPartNoWorkCellCode(MesProductionRecord mesProductionRecord, Pager pager) {
|
||||
try {
|
||||
ValidatorBean.beginValid(mesProductionRecord)
|
||||
.notNull("organizeCode", mesProductionRecord.getOrganizeCode());
|
||||
|
||||
return ResultBean.success("查询成功").setListPager(mesProductionRecordService.queryRecordGroupByPartNoWorkCellCode(mesProductionRecord, pager))
|
||||
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
||||
} catch (ImppBusiException busExcep) {
|
||||
return ResultBean.fail(busExcep);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.utils;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Map转Object 工具类
|
||||
*/
|
||||
public class BeanUtil {
|
||||
|
||||
public static Object populateBean(Map<String, ? extends Object> map, Class<? extends Object> clazz) throws Exception {
|
||||
Object obj = clazz.newInstance();
|
||||
BeanUtils.populate(obj, map);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static List<Object> popListToList(Object object, List<Map<String, Object>> list) throws Exception {
|
||||
|
||||
List<Object> listRetun = new ArrayList<Object>();
|
||||
for (Map<String, Object> map : list) {
|
||||
listRetun.add(BeanUtil.populateBean(map, object.getClass()));
|
||||
}
|
||||
return listRetun;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象父类和字类所有的数据库字段
|
||||
*
|
||||
* @param c 对象类
|
||||
* @return 属性名数组
|
||||
*/
|
||||
public static String[] getAllColumnFields(Class c) {
|
||||
//父子类属性合并
|
||||
Field[] fields = ArrayUtils.addAll(c.getFields(), c.getDeclaredFields());
|
||||
//循环所有属性把名称存入数组
|
||||
List<String> fieldsNameList = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
// 判断是否为数据库字段
|
||||
if (field.isAnnotationPresent(Column.class)) {
|
||||
fieldsNameList.add(field.getName());
|
||||
}
|
||||
}
|
||||
return fieldsNameList.toArray(new String[fieldsNameList.size()]);
|
||||
}
|
||||
|
||||
public static String getProperty(Object bean, String name) {
|
||||
String proVal = null;
|
||||
try {
|
||||
proVal = BeanUtils.getProperty(bean, name);
|
||||
} catch (Exception e) {
|
||||
MesException.throwMesBusiException("反射获取对象【" + bean.getClass().getName() + "】属性【" + name +
|
||||
"】值时异常:详情如下" + ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
return proVal;
|
||||
}
|
||||
|
||||
public static void setProperty(Object bean, String name, Object values) {
|
||||
try {
|
||||
BeanUtils.setProperty(bean, name, values);
|
||||
} catch (Exception e) {
|
||||
MesException.throwMesBusiException("反射设置对象【" + bean.getClass().getName() + "】属性【" + name +
|
||||
"】值时异常:详情如下" + ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue