Commit 0158886c authored by wanghao's avatar wanghao

1 托盘和板子绑定 和 解绑处理,涉及到的 老化数据清理。

parent 949911b8
......@@ -52,6 +52,15 @@ public class PalletDeviceBindingController extends BaseController
return AjaxResult.success(palletDeviceBindingService.selectPalletDeviceBindingList(palletDeviceBinding));
}
/**
* 获取所有托盘绑定的设备列列表(排除已解除绑定的设备)
*/
@GetMapping("/getAllExcludeUnbindingTimeByTrayId/{trayId}")
public AjaxResult getAllExcludeUnbindingTimeByTrayId(@PathVariable("trayId") Long trayId) {
return AjaxResult.success(palletDeviceBindingService.getAllExcludeUnbindingTimeByTrayId(trayId));
}
/**
* 导出托盘绑定的设备列列表
*/
......@@ -109,6 +118,12 @@ public class PalletDeviceBindingController extends BaseController
return toAjax(palletDeviceBindingService.batchUpdateDeviceCode(palletDeviceBindings));
}
@PostMapping("/batchUpdateDeviceCodeAndUnbindingTime")
public AjaxResult batchUpdateDeviceCodeAndUnbindingTime(@RequestBody List<PalletDeviceBinding> palletDeviceBindings) {
return toAjax(palletDeviceBindingService.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindings));
}
/**
* 修改托盘绑定的设备列
*/
......@@ -118,6 +133,26 @@ public class PalletDeviceBindingController extends BaseController
return toAjax(palletDeviceBindingService.updatePalletDeviceBinding(palletDeviceBinding));
}
/**
* 解绑设备
* @param palletDeviceBinding p
* @return l
*/
@PostMapping("/unbindDevice")
public AjaxResult unbindDevice(@RequestBody PalletDeviceBinding palletDeviceBinding) {
return palletDeviceBindingService.unbindDevice(palletDeviceBinding);
}
/**
* 解绑所有设备
* @param trayId t
* @return l
*/
@GetMapping("/unbindAllDevice/{trayId}")
public AjaxResult unbindAllDevice(@PathVariable("trayId") Long trayId) {
return palletDeviceBindingService.unbindAllDevice(trayId);
}
/**
* 删除托盘绑定的设备列
*/
......
......@@ -36,6 +36,8 @@ public interface PalletDeviceBindingMapper
*/
public List<PalletDeviceBinding> selectPalletDeviceBindingList(PalletDeviceBinding palletDeviceBinding);
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId);
public int countErrorByTrayId(Long trayId);
/**
......@@ -60,8 +62,14 @@ public interface PalletDeviceBindingMapper
*/
public int updatePalletDeviceBinding(PalletDeviceBinding palletDeviceBinding);
public int unbindDevice(Long palletDeviceBindingId);
public int batchUpdateDeviceCode(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCodeAndUnbindingTime(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int unbindAllDevice(Long trayId);
/**
* 删除托盘绑定的设备列
*
......
......@@ -55,6 +55,10 @@ public interface TTrayInfoMapper
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
public int updateToBoundWhenStateIsIdle(Long trayId);
public int unbindByCode(TTrayInfo tTrayInfo);
/**
* 删除托盘信息
......
......@@ -29,6 +29,8 @@ public interface IPalletDeviceBindingService
*/
public List<PalletDeviceBinding> selectPalletDeviceBindingList(PalletDeviceBinding palletDeviceBinding);
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId);
/**
* 新增托盘绑定的设备列
*
......@@ -42,6 +44,9 @@ public interface IPalletDeviceBindingService
public int batchInsertPalletDeviceBinding(List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCode(List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCodeAndUnbindingTime(List<PalletDeviceBinding> palletDeviceBindingList);
/**
* 修改托盘绑定的设备列
*
......@@ -50,6 +55,10 @@ public interface IPalletDeviceBindingService
*/
public int updatePalletDeviceBinding(PalletDeviceBinding palletDeviceBinding);
public AjaxResult unbindDevice(PalletDeviceBinding palletDeviceBinding);
public AjaxResult unbindAllDevice(Long trayId);
/**
* 批量删除托盘绑定的设备列
*
......
......@@ -46,6 +46,8 @@ public interface ITTrayInfoService
public int updateStatusByTrayCode(TTrayInfo tTrayInfo);
public int updateStatusByTrayId(TTrayInfo tTrayInfo);
/**
* 批量删除托盘信息
*
......
......@@ -4,6 +4,8 @@ import java.util.List;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TTrayInfo;
import com.zehong.system.mapper.TTrayInfoMapper;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.PalletDeviceBindingMapper;
......@@ -51,6 +53,18 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
return palletDeviceBindingMapper.selectPalletDeviceBindingList(palletDeviceBinding);
}
/**
* 获取所有未解除绑定的托盘绑定的设备列
*
* @param trayId 托盘ID
* @return 列表
*/
@Override
public List<PalletDeviceBinding> getAllExcludeUnbindingTimeByTrayId(Long trayId) {
return palletDeviceBindingMapper.getAllExcludeUnbindingTimeByTrayId(trayId);
}
/**
* 新增托盘绑定的设备列
*
......@@ -98,6 +112,12 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
palletDeviceBinding.setCreateTime(DateUtils.getNowDate());
palletDeviceBinding.setBindingTime(DateUtils.getNowDate());
});
TTrayInfo tTrayInfo = new TTrayInfo();
tTrayInfo.setfTrayId(palletDeviceBindingList.get(0).getTrayId());
tTrayInfo.setfStatus("4");
tTrayInfoMapper.updateStatusByTrayId(tTrayInfo);
return palletDeviceBindingMapper.batchInsertPalletDeviceBinding(palletDeviceBindingList);
}
......@@ -107,9 +127,24 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
palletDeviceBinding.setStatus("1");
palletDeviceBinding.setUpdateTime(DateUtils.getNowDate());
});
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
return palletDeviceBindingMapper.batchUpdateDeviceCode(palletDeviceBindingList);
}
@Override
public int batchUpdateDeviceCodeAndUnbindingTime(List<PalletDeviceBinding> palletDeviceBindingList) {
palletDeviceBindingList.forEach(palletDeviceBinding -> {
palletDeviceBinding.setStatus("1");
palletDeviceBinding.setUpdateTime(DateUtils.getNowDate());
});
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
return palletDeviceBindingMapper.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindingList);
}
/**
* 修改托盘绑定的设备列
*
......@@ -145,4 +180,59 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
{
return palletDeviceBindingMapper.deletePalletDeviceBindingById(palletDeviceBindingId);
}
/**
* 批量解绑所有设备
*
* @param trayId 托盘ID
* @return 删除结果
*/
@Override
public AjaxResult unbindAllDevice(Long trayId) {
if(trayId == null) {
return AjaxResult.error("参数错误");
}
int i = palletDeviceBindingMapper.unbindAllDevice(trayId);
if(i <=0) {
return AjaxResult.error("无设备绑定");
}
int i1 = tTrayInfoMapper.initStatusByTrayId(trayId);
if(i1 <=0) {
return AjaxResult.error("更新托盘状态失败");
}
return AjaxResult.success();
}
/**
* 解绑设备
*
* @param palletDeviceBinding 托盘绑定的设备列ID
* @return 删除结果
*/
@Override
public AjaxResult unbindDevice(PalletDeviceBinding palletDeviceBinding) {
if(palletDeviceBinding.getPalletDeviceBindingId() == null || StringUtils.isBlank(palletDeviceBinding.getDeviceCode())) {
return AjaxResult.error("参数错误");
}
PalletDeviceBinding palletDeviceBindingDb = palletDeviceBindingMapper.selectPalletDeviceBindingById(palletDeviceBinding.getPalletDeviceBindingId());
if(palletDeviceBindingDb == null) {
return AjaxResult.error("数据不存在");
}
if(!palletDeviceBindingDb.getDeviceCode().equals(palletDeviceBinding.getDeviceCode())) {
return AjaxResult.error("设备码错误");
}
int i = palletDeviceBindingMapper.unbindDevice(palletDeviceBindingDb.getPalletDeviceBindingId());
if (i > 0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
}
......@@ -84,6 +84,11 @@ public class TTrayInfoServiceImpl implements ITTrayInfoService
return tTrayInfoMapper.updateStatusByTrayCode(tTrayInfo);
}
@Override
public int updateStatusByTrayId(TTrayInfo tTrayInfo) {
return tTrayInfoMapper.initStatusByTrayId(tTrayInfo.getfTrayId());
}
/**
* 批量删除托盘信息
*
......
......@@ -70,6 +70,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null "> and palDeviceBinding.f_create_time = #{createTime}</if>
<if test="status != null and status != '' "> and palDeviceBinding.f_status = #{status}</if>
</where>
order by palDeviceBinding.f_index asc
</select>
<select id="getAllExcludeUnbindingTimeByTrayId" parameterType="long" resultMap="PalletDeviceBindingResult">
<include refid="selectPalletDeviceBindingVo"/>
where palDeviceBinding.f_tray_id = #{trayId}
order by palDeviceBinding.f_index asc
</select>
<select id="selectPalletDeviceBindingById" parameterType="Long" resultMap="PalletDeviceBindingResult">
......@@ -108,13 +114,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="batchInsertPalletDeviceBinding" parameterType="list">
insert into t_pallet_device_binding (f_tray_id, f_device_code,f_row,f_col,f_index,f_binding_time,f_unbinding_time,
insert into t_pallet_device_binding (f_tray_id, f_device_code,f_row,f_col,f_index,f_binding_time,f_binding_time,
f_create_time,f_status)
values
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=",">
(
#{item.trayId}, #{item.deviceCode}, #{item.row}, #{item.col}, #{item.index},#{item.bindingTime},
#{item.unbindingTime},#{item.createTime},#{item.status}
#{item.bindingTime},#{item.createTime},#{item.status}
)
</foreach>
</insert>
......@@ -161,11 +167,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="unbindDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_unbinding_time = NOW(),
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null
where f_pallet_device_binding_id = #{palletDeviceBindingId}
</update>
<update id="updatePalletDeviceBinding" parameterType="PalletDeviceBinding">
update t_pallet_device_binding
<trim prefix="SET" suffixOverrides=",">
<if test="trayId != null">f_tray_id = #{trayId},</if>
<if test="deviceCode != null">f_device_code = #{deviceCode},</if>
<if test="deviceCode == null">f_device_code = null,</if>
<if test="row != null">f_row = #{row},</if>
<if test="col != null">f_col = #{col},</if>
<if test="index != null">f_index = #{index},</if>
......@@ -189,12 +211,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="batchUpdateDeviceCode" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
<set>
f_device_code = #{item.deviceCode}
</set>
<trim prefix="SET" suffixOverrides=",">
<if test="item.deviceCode != null">f_device_code = #{item.deviceCode},</if>
<if test="item.deviceCode == null">f_device_code = null,</if>
</trim>
WHERE f_pallet_device_binding_id = #{item.palletDeviceBindingId}
</foreach>
</update>
<update id="batchUpdateDeviceCodeAndUnbindingTime" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
<trim prefix="SET" suffixOverrides=",">
f_unbinding_time = null,
f_binding_time = NOW(),
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null,
<if test="item.deviceCode != null">f_device_code = #{item.deviceCode},</if>
</trim>
WHERE f_pallet_device_binding_id = #{item.palletDeviceBindingId}
</foreach>
</update>
<update id="unbindAllDevice" parameterType="long">
update t_pallet_device_binding
set f_device_code = null,
f_unbinding_time = NOW(),
f_status = '1',
f_record_year = null,
f_record_month = null,
f_record_date = null,
f_record_hour = null,
f_record_minute = null,
f_write_time_status = null,
f_adjustment_zero_ad = null,
f_calibration_ad = null,
f_concentration = null
where f_tray_id = #{trayId}
</update>
<delete id="deletePalletDeviceBindingById" parameterType="Long">
delete from t_pallet_device_binding where f_pallet_device_binding_id = #{palletDeviceBindingId}
......
......@@ -94,6 +94,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set f_status = #{fStatus}
where f_storey_code = #{fStoreyCode}
</update>
<update id="updateStatusByTrayId" parameterType="TTrayInfo">
update t_tray_info
set f_status = #{fStatus}
where f_tray_id = #{fTrayId}
</update>
<update id="updateToBoundWhenStateIsIdle" parameterType="long">
update t_tray_info
set f_status = '4' where f_status = '0' and f_tray_id = #{fTrayId}
</update>
<update id="clearStoreyCodeByStoreyCode" parameterType="string">
update t_tray_info
set f_storey_code = null
......
......@@ -18,6 +18,13 @@ export function getAllBinding(query) {
})
}
export function getAllExcludeUnbindingTimeByTrayId(trayId) {
return request({
url: '/palletDevice/binding/getAllExcludeUnbindingTimeByTrayId/' + trayId,
method: 'get'
})
}
// 查询托盘绑定的设备列详细
export function getBinding(palletDeviceBindingId) {
return request({
......@@ -44,6 +51,21 @@ export function batchAdd(data) {
})
}
export function unbindSingleDevice(data){
return request({
url: '/palletDevice/binding/unbindDevice/',
method: 'post',
data: data
})
}
export function unbindAllDevice(trayId){
return request({
url: '/palletDevice/binding/unbindAllDevice/' + trayId,
method: 'get'
})
}
// 修改托盘绑定的设备列
export function updateBinding(data) {
return request({
......@@ -62,6 +84,14 @@ export function batchUpdateDeviceCode(data) {
})
}
export function batchUpdateDeviceCodeAndUnbindingTime(data) {
return request({
url: '/palletDevice/binding/batchUpdateDeviceCodeAndUnbindingTime',
method: 'post',
data: data
})
}
// 删除托盘绑定的设备列
export function delBinding(palletDeviceBindingId) {
return request({
......
......@@ -53,6 +53,7 @@
<el-tag :type="statusTagType(scope.row.fStatus)" v-if="scope.row.fStatus === '1'" class="status-tag">运行中</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '2'" class="status-tag">老化完成</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '3'" class="status-tag">标定完成</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else-if="scope.row.fStatus === '4'" class="status-tag">已绑定</el-tag>
<el-tag :type="statusTagType(scope.row.fStatus)" v-else class="status-tag">空闲</el-tag>
</template>
</el-table-column>
......@@ -180,6 +181,7 @@ export default {
'2': 'warning',
'3': 'warning',
'1': 'primary',
'4': 'info',
};
return statusMap[status] || 'info';
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment