工装定检增删改查接口、定检模型查询接口

This commit is contained in:
star 2024-10-31 17:53:46 +08:00
parent 4fe19336cd
commit 6673efa2c0
8 changed files with 744 additions and 0 deletions

View File

@ -0,0 +1,95 @@
package com.ktg.mes.qc.controller;
import com.ktg.common.annotation.Log;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
import com.ktg.common.enums.BusinessType;
import com.ktg.mes.qc.domain.InventoryTask;
import com.ktg.mes.qc.domain.QcDefect;
import com.ktg.mes.qc.service.InventoryTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static com.ktg.common.utils.PageUtils.startPage;
/**
* 常见缺陷Controller
*
* @author yinjinlu
* @date 2022-05-19
*/
@RestController
@RequestMapping("InventoryTaskController")
public class InventoryTaskController extends BaseController {
@Autowired
private InventoryTaskService inventoryTaskService;
/**
* 查询定检任务列表
*/
@GetMapping("/list")
public TableDataInfo list(InventoryTask inventoryTask) {
startPage();
List<InventoryTask> list = inventoryTaskService.getList(inventoryTask);
return getDataTable(list);
}
/**
* 修改任务
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:edit')")
@Log(title = "定检任务", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody InventoryTask inventoryTask)
{
return toAjax(inventoryTaskService.updateInventoryTask(inventoryTask));
}
/**
* 新增计划
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:add')")
@Log(title = "定检任务", businessType = BusinessType.INSERT)
@PostMapping("/save")
public AjaxResult add(@RequestBody InventoryTask inventoryTask)
{
return toAjax(inventoryTaskService.insertInventoryTask(inventoryTask));
}
/**
* 获取定检任务详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:query')")
@GetMapping(value = "/{wmsInventoryID}")
public AjaxResult getInfo(@PathVariable("wmsInventoryID") Long wmsInventoryID)
{
return AjaxResult.success(inventoryTaskService.selectInventoryTaskById(wmsInventoryID));
}
/**
* 删除
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:remove')")
@Log(title = "定检任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{wmsInventoryID}")
public AjaxResult remove(@PathVariable Long wmsInventoryID)
{
return toAjax(inventoryTaskService.delById(wmsInventoryID));
}
/**
* 批量删除
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:remove')")
@Log(title = "定检任务", businessType = BusinessType.DELETE)
@DeleteMapping("del/{wmsInventoryIDs}")
public AjaxResult remove(@PathVariable Long[] wmsInventoryIDs)
{
return toAjax(inventoryTaskService.delByIds(wmsInventoryIDs));
}
}

View File

@ -0,0 +1,288 @@
package com.ktg.mes.qc.domain;
import com.ktg.common.core.domain.BaseEntity;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 工装定检对象对象 qc_defect
*
*/
public class InventoryTask extends BaseEntity {
private static final long serialVersionUID = 1L;
//id
private Long wmsInventoryID;
//编码
private String wmsInventoryCode;
//名称
private String name;
//分类Id
private String uomId;
//分类名称
private String uomName;
//物料Id名称
private String productId;
//物料名称
private String productName;
//点检模型
private String mrlModel;
//点检模型名称
private String mrlModelName;
//点检周期
private String mrlPeriod;
//计划规则
private String planPeriod;
//开始时间
private Timestamp startTime;
//结束时间
private Timestamp finishTime;
//上次检测时间
private Timestamp superiorTime;
//下次检测时间
private Timestamp belowTime;
//工装定检预警
private String mrlWarning;
//是否完成
private String updatebby;
//是否删除
private int isDelete;
//是否激活
private int isActive;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
// 其他 getter setter 也需要相应地调整
public String getMrlModel() {
return mrlModel;
}
public void setMrlModel(String mrlModel) {
this.mrlModel = mrlModel;
}
public String getMrlPeriod() {
return mrlPeriod;
}
public void setMrlPeriod(String mrlPeriod) {
this.mrlPeriod = mrlPeriod;
}
public String getPlanPeriod() {
return planPeriod;
}
public void setPlanPeriod(String planPeriod) {
this.planPeriod = planPeriod;
}
public Timestamp getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parsedDate = format.parse(startTime);
this.startTime = new Timestamp(parsedDate.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
public Timestamp getFinishTime() {
return finishTime;
}
public void setFinishTime(String finishTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parsedDate = format.parse(finishTime);
this.finishTime = new Timestamp(parsedDate.getTime());
} catch (ParseException e) {
e.printStackTrace(); // 或记录日志抛出自定义异常等
}
}
public Timestamp getSuperiorTime() {
return superiorTime;
}
public void setSuperiorTime(String superiorTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parsedDate = format.parse(superiorTime);
this.superiorTime = new Timestamp(parsedDate.getTime());
} catch (ParseException e) {
e.printStackTrace(); // 或记录日志抛出自定义异常等
}
}
public Timestamp getBelowTime() {
return belowTime;
}
public void setBelowTime(String belowTime) {
System.out.println(belowTime);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parsedDate = format.parse(belowTime);
this.belowTime = new Timestamp(parsedDate.getTime());
} catch (ParseException e) {
e.printStackTrace(); // 或记录日志抛出自定义异常等
}
}
public String getMrlWarning() {
return mrlWarning;
}
public void setMrlWarning(String mrlWarning) {
this.mrlWarning = mrlWarning;
}
public String getUpdatebby() {
return updatebby;
}
public void setUpdatebby(String updatebby) {
this.updatebby = updatebby;
}
public int getIsDelete() {
return isDelete;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
public int getIsActive() {
return isActive;
}
public void setIsActive(int isActive) {
this.isActive = isActive;
}
public String getMrlModelName() {
return mrlModelName;
}
public void setMrlModelName(String mrlModelName) {
this.mrlModelName = mrlModelName;
}
public Long getWmsInventoryID() {
return wmsInventoryID;
}
public void setWmsInventoryID(Long wmsInventoryID) {
this.wmsInventoryID = wmsInventoryID;
}
public String getWmsInventoryCode() {
return wmsInventoryCode;
}
public void setWmsInventoryCode(String wmsInventoryCode) {
this.wmsInventoryCode = wmsInventoryCode;
}
public String getUomId() {
return uomId;
}
public void setUomId(String uomId) {
this.uomId = uomId;
}
public String getUomName() {
return uomName;
}
public void setUomName(String uomName) {
this.uomName = uomName;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public void setStartTime(Timestamp startTime) {
this.startTime = startTime;
}
public void setFinishTime(Timestamp finishTime) {
this.finishTime = finishTime;
}
public void setSuperiorTime(Timestamp superiorTime) {
this.superiorTime = superiorTime;
}
public void setBelowTime(Timestamp belowTime) {
this.belowTime = belowTime;
}
@Override
public String toString() {
return "InventoryTask{" +
"wmsInventoryID=" + wmsInventoryID +
", wmsInventoryCode='" + wmsInventoryCode + '\'' +
", name='" + name + '\'' +
", uomId='" + uomId + '\'' +
", uomName='" + uomName + '\'' +
", productId='" + productId + '\'' +
", productName='" + productName + '\'' +
", mrlModel='" + mrlModel + '\'' +
", mrlModelName='" + mrlModelName + '\'' +
", mrlPeriod='" + mrlPeriod + '\'' +
", planPeriod='" + planPeriod + '\'' +
", startTime=" + startTime +
", finishTime=" + finishTime +
", superiorTime=" + superiorTime +
", belowTime=" + belowTime +
", mrlWarning='" + mrlWarning + '\'' +
", updatebby='" + updatebby + '\'' +
", isDelete=" + isDelete +
", isActive=" + isActive +
'}';
}
}

View File

@ -0,0 +1,57 @@
package com.ktg.mes.qc.mapper;
import com.ktg.mes.qc.domain.InventoryTask;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 工装定检Mapper接口
*
*/
public interface InventoryTaskMapper {
/**
* 查询工装定检任务
*
* @param id 工装定检主键
* @return 工装定检
*/
public InventoryTask selectInventoryTaskById(@Param("Id") Long id);
/**
* 查询工装定检任务集合
*
* @param inventoryTask 工装定检对象
* @return 工装定检集合
*/
List<InventoryTask> getList(InventoryTask inventoryTask);
/**
* 新增工装定检任务
* @param inventoryTask
* @return
*/
public int insertInventoryTask(InventoryTask inventoryTask);
/**
* 修改工装定检任务
* @param inventoryTask
* @return
*/
public int updateInventoryTask(InventoryTask inventoryTask);
/**
* 删除工装定检任务
* @param id
* @return
*/
public int delById(@Param("Id") Long id);
/**
* 批量删除工装定检任务
* @param ids
* @return
*/
public int delByIds(@Param("list") Long[] ids);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.ktg.mes.qc.domain.QcMobParam;
import com.ktg.mes.qc.domain.QcTemplate;
import org.apache.ibatis.annotations.Select;
/**
* 检测模板Mapper接口
@ -13,6 +14,13 @@ import com.ktg.mes.qc.domain.QcTemplate;
*/
public interface QcTemplateMapper
{
/**
* 查询检测模板
*
* @return 检测模板
*/
public List<QcTemplate> getAll();
/**
* 查询检测模板
*

View File

@ -0,0 +1,57 @@
package com.ktg.mes.qc.service;
import com.ktg.mes.qc.domain.InventoryTask;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 工装定检Service接口
*
*/
public interface InventoryTaskService {
/**
* 查询工装定检任务
*
* @param id 工装定检主键
* @return 工装定检
*/
public InventoryTask selectInventoryTaskById(@Param("Id") Long id);
/**
* 查询工装定检任务集合
*
* @param id 工装定检对象
* @return 工装定检集合
*/
List<InventoryTask> getList(InventoryTask inventoryTask);
/**
* 新增工装定检任务
* @param inventoryTask
* @return
*/
public int insertInventoryTask(InventoryTask inventoryTask);
/**
* 修改工装定检任务
* @param inventoryTask
* @return
*/
public int updateInventoryTask(InventoryTask inventoryTask);
/**
* 删除工装定检任务
* @param id
* @return
*/
public int delById(Long id);
/**
* 批量删除工装定检任务
* @param ids
* @return
*/
public int delByIds(Long[] ids);
}

View File

@ -0,0 +1,109 @@
package com.ktg.mes.qc.service.impl;
import com.ktg.common.utils.DateUtils;
import com.ktg.mes.md.domain.MdItem;
import com.ktg.mes.md.mapper.MdItemMapper;
import com.ktg.mes.qc.domain.InventoryTask;
import com.ktg.mes.qc.domain.QcTemplate;
import com.ktg.mes.qc.mapper.InventoryTaskMapper;
import com.ktg.mes.qc.mapper.QcDefectRecordMapper;
import com.ktg.mes.qc.mapper.QcTemplateMapper;
import com.ktg.mes.qc.service.InventoryTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import static com.ktg.common.utils.SecurityUtils.getUsername;
/**
* 工装定检Service业务层处理
*
*/
@Service
public class InventoryTaskServiceImpl implements InventoryTaskService {
@Autowired
private InventoryTaskMapper inventoryTaskMapper;
@Autowired
private MdItemMapper mdItemMapper;
@Autowired
private QcTemplateMapper qcTemplateMapper;
@Override
public InventoryTask selectInventoryTaskById(Long id) {
InventoryTask inventoryTask = inventoryTaskMapper.selectInventoryTaskById(id);
QcTemplate qcTemplate = qcTemplateMapper.selectQcTemplateByTemplateId(Long.parseLong(inventoryTask.getMrlModel()));
inventoryTask.setMrlModelName(qcTemplate.getTemplateName());
MdItem mdItem = mdItemMapper.selectMdItemById(Long.parseLong(inventoryTask.getProductId()));
inventoryTask.setProductName(mdItem.getItemName());
inventoryTask.setUomName(mdItem.getItemTypeName());
return inventoryTask;
}
@Override
public List<InventoryTask> getList(InventoryTask inventoryTask) {
List<InventoryTask> list = inventoryTaskMapper.getList(inventoryTask);
List<QcTemplate> qcTemplates = qcTemplateMapper.getAll();
for (InventoryTask task : list) {
for (QcTemplate qcTemplate : qcTemplates) {
if (Long.parseLong(task.getMrlModel()) == qcTemplate.getTemplateId())
task.setMrlModelName(qcTemplate.getTemplateName());
}
}
List<MdItem> mdItems = mdItemMapper.selectMdItemAll();
for (InventoryTask task : list) {
for (MdItem mdItem : mdItems) {
if (Long.parseLong(task.getProductId()) == mdItem.getItemId()) {
task.setProductName(mdItem.getItemName());
task.setUomName(mdItem.getItemTypeName());
}
}
}
return list;
}
@Override
public int insertInventoryTask(InventoryTask inventoryTask) {
String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
inventoryTask.setCreateBy(getUsername());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parsedDate = format.parse(s);
inventoryTask.setCreateTime(parsedDate);
} catch (ParseException e) {
e.printStackTrace(); // 或记录日志抛出自定义异常等
}
return inventoryTaskMapper.insertInventoryTask(inventoryTask);
}
@Override
public int updateInventoryTask(InventoryTask inventoryTask) {
// String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
// inventoryTask.setUpdatebby(getUsername());
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
// try {
// Date parsedDate = format.parse(s);
// inventoryTask.setUpdateTime(parsedDate);
// } catch (ParseException e) {
// e.printStackTrace(); // 或记录日志抛出自定义异常等
// }
return inventoryTaskMapper.updateInventoryTask(inventoryTask);
}
@Override
public int delById(Long id) {
return inventoryTaskMapper.delById(id);
}
@Override
public int delByIds(Long[] ids) {
return inventoryTaskMapper.delByIds(ids);
}
}

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.qc.mapper.InventoryTaskMapper">
<resultMap type="InventoryTask" id="InventoryTaskResult">
<result property="wmsInventoryID" column="WMS_INVENTORY_ID" />
<result property="wmsInventoryCode" column="WMS_UNVENTORY_CODE" />
<result property="uomId" column="M_UOM_ID" />
<result property="productId" column="M_PRODUCT_ID" />
<result property="name" column="NAME" />
<result property="mrlModel" column="MRL_MODEL" />
<result property="mrlPeriod" column="MRL_PERIOD" />
<result property="planPeriod" column="PLAN_PERIOD" />
<result property="startTime" column="START_TIME" />
<result property="finishTime" column="FINISH_TIME" />
<result property="remark" column="REMARK" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="superiorTime" column="SUPERIOR_TIME"/>
<result property="belowTime" column="BELOW_TIME"/>
<result property="mrlWarning" column="MRL_WARNING"/>
<result property="updatebby" column="UPDATEBBY"/>
<result property="isDelete" column="IS_DELETE"/>
<result property="isDelete" column="IS_ACTIVE"/>
</resultMap>
<sql id="selectInvenroryTaskVo">
select WMS_INVENTORY_ID,WMS_UNVENTORY_CODE,M_UOM_ID,NAME,MRL_MODEL,M_PRODUCT_ID,MRL_PERIOD,PLAN_PERIOD,START_TIME,FINISH_TIME ,REMARK,create_by,create_time,update_by,update_time,SUPERIOR_TIME,BELOW_TIME,MRL_WARNING from WMS_INVENTORY
</sql>
<insert id="insertInventoryTask">
insert into wms_inventory
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="wmsInventoryCode != null and wmsInventoryCode != ''">WMS_UNVENTORY_CODE,</if>
<if test="name != null and name != ''">NAME ,</if>
<if test="uomId != null and uomId != ''">M_UOM_ID,</if>
<if test="productId != null and productId != ''">M_PRODUCT_ID,</if>
<if test="mrlModel != null and mrlModel != ''">MRL_MODEL,</if>
<if test="mrlPeriod != null and mrlPeriod != ''">MRL_PERIOD,</if>
<if test="planPeriod != null and planPeriod != ''">PLAN_PERIOD,</if>
<if test="startTime != null">START_TIME,</if>
<if test="finishTime != null">FINISH_TIME,</if>
<if test="superiorTime != null">SUPERIOR_TIME,</if>
<if test="belowTime != null">BELOW_TIME,</if>
<if test="mrlWarning != null">MRL_WARNING,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="wmsInventoryCode != null and wmsInventoryCode != ''">#{wmsInventoryCode},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="uomId != null and uomId != ''">#{uomId},</if>
<if test="productId != null and productId != ''">#{productId},</if>
<if test="mrlModel != null and mrlModel != ''">#{mrlModel},</if>
<if test="mrlPeriod != null and mrlPeriod != ''">#{mrlPeriod},</if>
<if test="planPeriod != null and planPeriod != ''">#{planPeriod},</if>
<if test="startTime != null">#{startTime},</if>
<if test="finishTime != null">#{finishTime},</if>
<if test="superiorTime != null">#{superiorTime},</if>
<if test="belowTime != null">#{belowTime},</if>
<if test="mrlWarning != null">#{mrlWarning},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateInventoryTask" parameterType="InventoryTask">
update wms_inventory
<trim prefix="SET" suffixOverrides=",">
<if test="wmsInventoryCode != null and wmsInventoryCode != ''">WMS_UNVENTORY_CODE = #{wmsInventoryCode},</if>
<if test="uomId != null and uomId != ''">m_uom_id = #{uomId},</if>
<if test="productId != null and productId != ''">m_product_id = #{productId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="mrlModel != null and mrlModel != ''">mrl_model = #{mrlModel},</if>
<if test="mrlPeriod != null and mrlPeriod != ''">mrl_period = #{mrlPeriod},</if>
<if test="planPeriod != null and planPeriod != ''">plan_period = #{planPeriod},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="finishTime != null">finish_time = #{finishTime},</if>
<if test="superiorTime != null">superior_time = #{superiorTime},</if>
<if test="belowTime != null">below_time = #{belowTime},</if>
<if test="mrlWarning != null">mrl_warning = #{mrlWarning},</if>
<if test="updatebby != null">updatebby = #{updatebby},</if>
<if test="isDelete >= 0">is_delete = #{isDelete},</if>
<if test="isActive >= 0">is_active = #{isActive},</if>
<if test="createBy != null">create_by=#{createBy},</if>
<if test="createTime != null">create_time=#{createTime},</if>
<if test="updateBy != null">update_by=#{updateBy},</if>
<if test="updateTime != null">update_by=#{updateTime},</if>
</trim>
where wms_inventory_id = #{wmsInventoryID}
</update>
<update id="delById">
update wms_inventory set is_delete = 1 where WMS_INVENTORY_ID = #{Id}
</update>
<update id="delByIds">
update wms_inventory
set is_delete = 1
where wms_inventory_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="getList" resultType="com.ktg.mes.qc.domain.InventoryTask" resultMap="com.ktg.mes.qc.mapper.InventoryTaskMapper.InventoryTaskResult">
<include refid="selectInvenroryTaskVo"/>
<where>
<if test="wmsInventoryCode != null and wmsInventoryCode != ''">
AND WMS_UNVENTORY_CODE LIKE CONCAT('%', #{wmsInventoryCode}, '%')
</if>
<if test="name != null and name != ''">
AND NAME LIKE CONCAT('%', #{name}, '%')
</if>
and IS_DELETE = 0
</where>
</select>
<select id="selectInventoryTaskById" resultType="com.ktg.mes.qc.domain.InventoryTask" resultMap="com.ktg.mes.qc.mapper.InventoryTaskMapper.InventoryTaskResult">
<include refid="selectInvenroryTaskVo"></include>
where WMS_INVENTORY_ID = #{Id}
</select>
</mapper>

View File

@ -62,6 +62,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and t.qc_types like concat('%',#{qcType},'%')
limit 1
</select>
<select id="getAll" resultType="com.ktg.mes.qc.domain.QcTemplate" resultMap="QcTemplateResult">
select t.template_id, template_code, template_name, qc_types, enable_flag, t.remark from qc_template t
</select>
<insert id="insertQcTemplate" parameterType="QcTemplate" useGeneratedKeys="true" keyProperty="templateId">
insert into qc_template