forked from I3-YF/i3plus-mes-yfai
Merge remote-tracking branch 'origin/dev' into dev
commit
beb84ec246
@ -0,0 +1,15 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.api.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesWcEquipment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 工作单元设备关系
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:52
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface IMesWcEquipmentService extends IBaseMesService<MesWcEquipment> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.api.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.SapProductPlan;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : SAP生产计划
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:52
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface ISapProductPlanService extends IBaseMesService<SapProductPlan> {
|
||||||
|
|
||||||
|
@ApiOperation(value = "分页查询SAP生产计划", notes = "分页查询SAP生产计划")
|
||||||
|
ListPager<SapProductPlan> querySapProductPlanPager(SapProductPlan sapProductPlan, Pager pager);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesWcEquipment;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 工作单元设备关系
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:53
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesWcEquipment")
|
||||||
|
@Api("工作单元设备关系")
|
||||||
|
public class MesWcEquipmentController extends BaseMesController<MesWcEquipment> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.api.base.ISapProductPlanService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.SapProductPlan;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
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 : SAP生产计划
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:53
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MesCommonConstant.MES_YANFEN + "/sapProductPlan")
|
||||||
|
@Api("SAP生产计划")
|
||||||
|
public class SapProductPlanController extends BaseMesController<SapProductPlan> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISapProductPlanService iSapProductPlanService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/query-by-pager")
|
||||||
|
@ApiOperation(value = "分页查询SAP生产计划", notes = "分页查询SAP生产计划")
|
||||||
|
public ResultBean querySapProductPlanByPager(SapProductPlan sapProductPlan, Pager pager) {
|
||||||
|
try {
|
||||||
|
ListPager<SapProductPlan> listPager = iSapProductPlanService.querySapProductPlanPager(sapProductPlan, pager);
|
||||||
|
return ResultBean.success("查询成功")
|
||||||
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
||||||
|
.setListPager(listPager);
|
||||||
|
} catch (ImppBusiException e) {
|
||||||
|
return ResultBean.fail(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.dao;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.SapProductPlan;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : SAP生产计划
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/7 15:13
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface ISapProductPlanDao {
|
||||||
|
|
||||||
|
@ApiOperation(value = "分页查询SAP生产计划", notes = "分页查询SAP生产计划")
|
||||||
|
ListPager<SapProductPlan> querySapProductPlanPager(SapProductPlan sapProductPlan, Pager pager);
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.daoimpl;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.dao.ISapProductPlanDao;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.SapProductPlan;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :SAP生产计划
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:52
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SapProductPlanDaoImpl implements ISapProductPlanDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListPager<SapProductPlan> querySapProductPlanPager(SapProductPlan sapProductPlan, Pager pager) {
|
||||||
|
//查询数据
|
||||||
|
StringBuffer dataHql = new StringBuffer("select sap.plnum,sap.plmat,sap.gsmng," +
|
||||||
|
"mes.complete_qty,sap.gsmng-mes.complete_qty as unFinishQty,sap.meins,sap.psttr,sap.pedtr,sap.l_str," +
|
||||||
|
"sap.plwrk,mes.create_date_time,mes.create_user,mes.modify_date_time,mes.modify_user");
|
||||||
|
StringBuilder hql = new StringBuilder();
|
||||||
|
hql.append(" from sap_product_plan sap left join mes_work_order mes on sap.plnum = mes.plnum and sap.plmat = mes.part_no " +
|
||||||
|
"where sap.is_deleted=:isDeleted and sap.is_valid=:isValid and sap.organize_code=:organizeCode " +
|
||||||
|
" and mes.is_deleted=:isDeleted and mes.is_valid=:isValid and mes.organize_code=:organizeCode");
|
||||||
|
//拼接查询条件
|
||||||
|
packWhere(sapProductPlan, hql);
|
||||||
|
StringBuffer unionDataHql = new StringBuffer("select sap.plnum,mes.part_no,mes.qty," +
|
||||||
|
"mes.complete_qty,mes.qty-mes.complete_qty as unFinishQty,sap.meins,sap.psttr,sap.pedtr,sap.l_str," +
|
||||||
|
"sap.plwrk,mes.create_date_time,mes.create_user,mes.modify_date_time,mes.modify_user");
|
||||||
|
StringBuilder unionHql = new StringBuilder();
|
||||||
|
unionHql.append(" from sap_product_plan sap right join mes_work_order mes on sap.plnum = mes.plnum and sap.plmat = mes.part_no " +
|
||||||
|
"where mes.is_deleted=:isDeleted and mes.is_valid=:isValid and mes.organize_code=:organizeCode and sap.id is null ");
|
||||||
|
//拼接查询条件
|
||||||
|
packWhere(sapProductPlan, unionHql);
|
||||||
|
//查询行数
|
||||||
|
int count = getCount(sapProductPlan, hql) + getCount(sapProductPlan, unionHql);
|
||||||
|
pager = PagerHelper.getPager(pager, count);
|
||||||
|
if (count <= 0) {
|
||||||
|
return new ListPager<>(new ArrayList<>(), pager);
|
||||||
|
}
|
||||||
|
//排序
|
||||||
|
String orderBy = " order by create_date_time desc";
|
||||||
|
//查询数据
|
||||||
|
Query query = entityManager.createNativeQuery(dataHql.append(hql) + " union all " + unionDataHql.append(unionHql) + orderBy);
|
||||||
|
//赋值
|
||||||
|
setParameter(sapProductPlan, query);
|
||||||
|
List resultList = query.setFirstResult(pager.getStartRow()).setMaxResults(pager.getPageSize()).getResultList();
|
||||||
|
List<SapProductPlan> list = new ArrayList<>();
|
||||||
|
for (Object result : resultList) {
|
||||||
|
Object[] cells = (Object[]) result;
|
||||||
|
SapProductPlan tjMgnBoardModel = new SapProductPlan(String.valueOf(cells[0]), String.valueOf(cells[1]), Double.valueOf(String.valueOf(cells[2])),
|
||||||
|
Double.valueOf(String.valueOf(cells[3])), Double.valueOf(String.valueOf(cells[4])), String.valueOf(cells[5]), String.valueOf(cells[6]), String.valueOf(cells[7]),
|
||||||
|
String.valueOf(cells[8]), String.valueOf(cells[9]), String.valueOf(cells[10]), String.valueOf(cells[11]), String.valueOf(cells[12]), String.valueOf(cells[13]));
|
||||||
|
list.add(tjMgnBoardModel);
|
||||||
|
}
|
||||||
|
return new ListPager<>(list, pager);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCount(SapProductPlan sapProductPlan, StringBuilder hql) {
|
||||||
|
Query query = entityManager.createNativeQuery("select count(1) " + hql);
|
||||||
|
//赋值
|
||||||
|
setParameter(sapProductPlan, query);
|
||||||
|
return Integer.parseInt(query.getSingleResult() + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setParameter(SapProductPlan sapProductPlan, Query query) {
|
||||||
|
query.setParameter("organizeCode", sapProductPlan.getOrganizeCode());
|
||||||
|
query.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||||
|
query.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPlnum())) {
|
||||||
|
query.setParameter("plnum", sapProductPlan.getPlnum());
|
||||||
|
}
|
||||||
|
//计划物料
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPlmat())) {
|
||||||
|
query.setParameter("plmat", sapProductPlan.getPlmat());
|
||||||
|
}
|
||||||
|
//生产线
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getLStr())) {
|
||||||
|
query.setParameter("lStr", sapProductPlan.getLStr());
|
||||||
|
}
|
||||||
|
//计划开始&结束
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPsttr())) {
|
||||||
|
query.setParameter("psttr", sapProductPlan.getPsttr());
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPedtr())) {
|
||||||
|
query.setParameter("pedtr", sapProductPlan.getPedtr());
|
||||||
|
}
|
||||||
|
//开始创建&结束日期
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getCreateDateTimeStart())) {
|
||||||
|
query.setParameter("createDateTimeStart", sapProductPlan.getCreateDateTimeStart());
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getCreateDateTimeEnd())) {
|
||||||
|
query.setParameter("createDateTimeEnd", sapProductPlan.getCreateDateTimeEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void packWhere(SapProductPlan sapProductPlan, StringBuilder hql) {
|
||||||
|
//计划订单号
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPlnum())) {
|
||||||
|
hql.append(" and sap.plnum = :plnum");
|
||||||
|
}
|
||||||
|
//计划物料
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPlmat())) {
|
||||||
|
hql.append(" and sap.plmat = :plmat");
|
||||||
|
}
|
||||||
|
//生产线
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getLStr())) {
|
||||||
|
hql.append(" and sap.l_str = :lStr");
|
||||||
|
}
|
||||||
|
//计划开始&结束
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPsttr())) {
|
||||||
|
hql.append(" and sap.psttr >= :psttr");
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getPedtr())) {
|
||||||
|
hql.append(" and sap.pedtr <= :pedtr");
|
||||||
|
}
|
||||||
|
//开始创建&结束日期
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getCreateDateTimeStart())) {
|
||||||
|
hql.append(" and sap.create_date_time >= :createDateTimeStart");
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(sapProductPlan.getCreateDateTimeEnd())) {
|
||||||
|
hql.append(" and sap.create_date_time <= :createDateTimeEnd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.api.base.ISapProductPlanService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.dao.ISapProductPlanDao;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.SapProductPlan;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :SAP生产计划
|
||||||
|
* @Reference :
|
||||||
|
* @Author : junsheng.li
|
||||||
|
* @CreateDate 2024/5/6 15:52
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SapProductPlanServiceImpl extends BaseMesService<SapProductPlan> implements ISapProductPlanService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISapProductPlanDao iSapProductPlanDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListPager<SapProductPlan> querySapProductPlanPager(SapProductPlan sapProductPlan, Pager pager) {
|
||||||
|
return iSapProductPlanDao.querySapProductPlanPager(sapProductPlan,pager);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue