库管员bug

This commit is contained in:
mashuai 2024-06-24 17:20:26 +08:00
parent c27986aadc
commit 88001ab860
4 changed files with 42 additions and 15 deletions

View File

@ -171,7 +171,7 @@ public class MaType extends BaseEntity {
/** 库管员id */
@ApiModelProperty(value = "库管员id")
private long keeperUserId;
private List<Long> keeperUserIdList;
/** 库管员名称 */
@ApiModelProperty(value = "库管员名称")
@ -453,12 +453,12 @@ public class MaType extends BaseEntity {
this.isAncuo = isAncuo;
}
public long getKeeperUserId() {
return keeperUserId;
public List<Long> getKeeperUserIdList() {
return keeperUserIdList;
}
public void setKeeperUserId(long keeperUserId) {
this.keeperUserId = keeperUserId;
public void setKeeperUserIdList(List<Long> keeperUserId) {
this.keeperUserIdList = keeperUserIdList;
}
public String getKeeperUserName() {

View File

@ -81,4 +81,6 @@ public interface MaTypeMapper {
int deleteKeeperByTypeId(Long typeId);
int deletePropSetByTypeId(Long typeId);
int getMaType(MaType maType);
}

View File

@ -6,8 +6,10 @@ import com.bonus.sgzb.base.domain.vo.TreeSelect;
import com.bonus.sgzb.base.mapper.MaTypeFileMapper;
import com.bonus.sgzb.base.mapper.MaTypeMapper;
import com.bonus.sgzb.base.service.ITypeService;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -53,6 +55,13 @@ public class MaTypeServiceImpl implements ITypeService {
String level = maType1.getLevel();
maType.setLevel(String.valueOf(Integer.parseInt(level) + 1));
maType.setCreateTime(DateUtils.getNowDate());
//根据类型名称判重
if (maType.getTypeName() != null && maType.getParentId() != null) {
int num = maTypeMapper.getMaType(maType);
if (num > 0) {
throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!");
}
}
int i = maTypeMapper.insertType(maType);
Long typeId = maType.getTypeId();
// 图片路径保存
@ -75,9 +84,13 @@ public class MaTypeServiceImpl implements ITypeService {
}
// 库管员配置
MaTypeKeeper typeKeeper = new MaTypeKeeper();
typeKeeper.setUserId(maType.getKeeperUserId());
typeKeeper.setTypeId(typeId);
maTypeMapper.insertKeeper(typeKeeper);
if (CollectionUtils.isNotEmpty(maType.getKeeperUserIdList())) {
for (Long keeperUserId : maType.getKeeperUserIdList()) {
typeKeeper.setUserId(keeperUserId);
typeKeeper.setTypeId(typeId);
maTypeMapper.insertKeeper(typeKeeper);
}
}
// 维修员配置
MaTypeRepair typeRepair = new MaTypeRepair();
@ -102,6 +115,13 @@ public class MaTypeServiceImpl implements ITypeService {
public int updateMaType(MaType maType) {
Long typeId = maType.getTypeId();
maType.setUpdateTime(DateUtils.getNowDate());
//根据类型名称判重
if (maType.getTypeName() != null && maType.getParentId() != null) {
int num = maTypeMapper.getMaType(maType);
if (num > 0) {
throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!");
}
}
int i = maTypeMapper.updateType(maType);
// 图片路径保存
if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) {
@ -124,14 +144,15 @@ public class MaTypeServiceImpl implements ITypeService {
typeFileMapper.insertMaTypeFile(typeFile1);
}
// 库管员配置
if (maType.getKeeperUserId() >= 0L) {
if (CollectionUtils.isNotEmpty(maType.getKeeperUserIdList())) {
maTypeMapper.deleteKeeperByTypeId(typeId);
MaTypeKeeper typeKeeper = new MaTypeKeeper();
typeKeeper.setUserId(maType.getKeeperUserId());
typeKeeper.setTypeId(typeId);
maTypeMapper.insertKeeper(typeKeeper);
for (Long keeperUserId : maType.getKeeperUserIdList()) {
MaTypeKeeper typeKeeper = new MaTypeKeeper();
typeKeeper.setUserId(keeperUserId);
typeKeeper.setTypeId(typeId);
maTypeMapper.insertKeeper(typeKeeper);
}
}
// 维修员配置
if (maType.getRepairUserId() >= 0L) {
maTypeMapper.deleteTypeByTypeId(typeId);

View File

@ -338,7 +338,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
GROUP_CONCAT(su.nick_name) keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id,m.fac_model as facModel
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id
@ -351,6 +351,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="typeName != null and typeName !=''">
AND type_name like concat('%',#{typeName},'%')
</if>
GROUP BY m.type_id
</select>
<select id="selectMaTypeTreeByLevel" resultMap="MaTypeResult" parameterType="java.lang.String">
@ -415,5 +416,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="getMaType" resultType="java.lang.Integer">
select count(1) from ma_type where parent_id = #{parentId} and type_name = #{typeName}
</select>
</mapper>