Merge remote-tracking branch 'origin/master'

master
zhaoxiaolin 6 months ago
commit 33beab5b92

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.SysDictType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -36,11 +37,11 @@ public class MesBoxController extends BaseController {
@Autowired
private IMesBoxService mesBoxService;
/**
*
*/
@RequiresPermissions("mes:mesBox:list")
@GetMapping("/list")
/**
*
*/
@RequiresPermissions("mes:mesBox:list")
@GetMapping("/list")
public TableDataInfo list(MesBox mesBox) {
startPage();
List<MesBox> list = mesBoxService.selectMesBoxList(mesBox);
@ -55,7 +56,7 @@ public class MesBoxController extends BaseController {
@PostMapping("/export")
public void export(HttpServletResponse response, MesBox mesBox) {
List<MesBox> list = mesBoxService.selectMesBoxList(mesBox);
ExcelUtil<MesBox> util = new ExcelUtil<MesBox>(MesBox. class);
ExcelUtil<MesBox> util = new ExcelUtil<MesBox>(MesBox.class);
util.exportExcel(response, list, "箱体类型数据");
}
@ -75,6 +76,9 @@ public class MesBoxController extends BaseController {
@Log(title = "箱体类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MesBox mesBox) {
if (!mesBoxService.checkBoxTypeUnique(mesBox)) {
return error("新增箱型'" + mesBox.getBoxName() + "'失败,箱体类型已存在");
}
return toAjax(mesBoxService.insertMesBox(mesBox));
}
@ -85,6 +89,9 @@ public class MesBoxController extends BaseController {
@Log(title = "箱体类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MesBox mesBox) {
if (!mesBoxService.checkBoxTypeUnique(mesBox)) {
return error("修改箱型'" + mesBox.getBoxName() + "'失败,箱体类型已存在");
}
return toAjax(mesBoxService.updateMesBox(mesBox));
}

@ -60,4 +60,8 @@ public interface MesBoxMapper {
public int deleteMesBoxByBoxIds(Long[] boxIds);
List<MesBox> selectDictTypeAll();
MesBox checkBoxTypeUnique(String boxType);
int countBoxDataByType(String boxType);
}

@ -60,4 +60,6 @@ public interface IMesBoxService {
public int deleteMesBoxByBoxId(Long boxId);
List<MesBox> selectDictTypeAll();
boolean checkBoxTypeUnique(MesBox mesBox);
}

@ -3,8 +3,13 @@ package com.op.mes.service.impl;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.constant.UserConstants;
import com.op.common.core.exception.ServiceException;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.security.utils.DictUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.SysDictType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.mes.mapper.MesBoxMapper;
@ -55,7 +60,7 @@ public class MesBoxServiceImpl implements IMesBoxService {
@Override
@DS("#header.poolName")
public int insertMesBox(MesBox mesBox) {
mesBox.setUpdateBy(SecurityUtils.getUsername());
mesBox.setCreateBy(SecurityUtils.getUsername());
mesBox.setCreateTime(DateUtils.getNowDate());
return mesBoxMapper.insertMesBox(mesBox);
}
@ -83,7 +88,16 @@ public class MesBoxServiceImpl implements IMesBoxService {
@Override
@DS("#header.poolName")
public int deleteMesBoxByBoxIds(Long[] boxIds) {
return mesBoxMapper.deleteMesBoxByBoxIds(boxIds);
int n = 0;
for (Long boxId : boxIds) {
MesBox boxType = selectMesBoxByBoxId(boxId);
if (mesBoxMapper.countBoxDataByType(boxType.getBoxType()) > 0) {
throw new ServiceException(String.format("%1$s已分配,不能删除", boxType.getBoxName()));
}
n += mesBoxMapper.deleteMesBoxByBoxIds(boxIds);
}
return n;
}
/**
@ -103,4 +117,14 @@ public class MesBoxServiceImpl implements IMesBoxService {
public List<MesBox> selectDictTypeAll() {
return mesBoxMapper.selectDictTypeAll();
}
@Override
public boolean checkBoxTypeUnique(MesBox mesBox) {
Long boxId = StringUtils.isNull(mesBox.getBoxId()) ? -1L : mesBox.getBoxId();
MesBox boxType = mesBoxMapper.checkBoxTypeUnique(mesBox.getBoxType());
if (StringUtils.isNotNull(boxType) && boxType.getBoxId().longValue() != boxId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
}

@ -33,12 +33,13 @@
and status = #{status}
</if>
</where>
where del_flag = '0'
</select>
<select id="selectMesBoxByBoxId" parameterType="Long"
resultMap="MesBoxResult">
<include refid="selectMesBoxVo"/>
where box_id = #{boxId}
where box_id = #{boxId} and del_flag = '0'
</select>
<insert id="insertMesBox" parameterType="MesBox">
@ -88,30 +89,30 @@
<update id="updateMesBox" parameterType="MesBox">
update mes_box
<trim prefix="SET" suffixOverrides=",">
<if test="boxName != null">box_name =
#{boxName},
</if>
<if test="boxType != null">box_type =
#{boxType},
</if>
<if test="status != null">status =
#{status},
</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_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="boxName != null">box_name =
#{boxName},
</if>
<if test="boxType != null">box_type =
#{boxType},
</if>
<if test="status != null">status =
#{status},
</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_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
</trim>
where box_id = #{boxId}
</update>
@ -120,14 +121,24 @@
<include refid="selectMesBoxVo"/>
</select>
<select id="countBoxDataByType" resultType="Integer">
select count(1) from mes_box_detail where box_type=#{boxType}
</select>
<delete id="deleteMesBoxByBoxId" parameterType="Long">
delete from mes_box where box_id = #{boxId}
update mes_box set del_flag = '1' where box_id = #{boxId}
</delete>
<delete id="deleteMesBoxByBoxIds" parameterType="String">
delete from mes_box where box_id in
update mes_box set del_flag = '1' where box_id in
<foreach item="boxId" collection="array" open="(" separator="," close=")">
#{boxId}
</foreach>
</delete>
<select id="checkBoxTypeUnique" parameterType="String" resultMap="MesBoxResult">
select top 1 box_id, box_name, box_type, status, create_by, create_time, remark
from mes_box
where box_type = #{boxType}
</select>
</mapper>

Loading…
Cancel
Save