增加修改type,brand,specs名称的时候同步修改equipment_info表中对应的名称

This commit is contained in:
wulin 2020-09-27 15:27:24 +08:00
commit a18edeef4e
9 changed files with 115 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import com.lz.modules.equipment.entity.EquipmentBrandReq;
import com.lz.modules.equipment.entity.EquipmentType; import com.lz.modules.equipment.entity.EquipmentType;
import com.lz.modules.equipment.entity.resp.EquipmentBrandResp; import com.lz.modules.equipment.entity.resp.EquipmentBrandResp;
import com.lz.modules.equipment.service.EquipmentBrandService; import com.lz.modules.equipment.service.EquipmentBrandService;
import com.lz.modules.equipment.service.IEquipmentInfoService;
import com.lz.modules.equipment.service.IEquipmentTypeService; import com.lz.modules.equipment.service.IEquipmentTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +40,9 @@ public class EquipmentBrandController {
@Autowired @Autowired
private IEquipmentTypeService equipmentTypeService; private IEquipmentTypeService equipmentTypeService;
@Resource
private IEquipmentInfoService equipmentInfoService;
/** /**
* 添加品牌表页面 * 添加品牌表页面
* *
@ -91,6 +95,7 @@ public class EquipmentBrandController {
EquipmentBrand equipmentBrand = equipmentBrandService.selectEquipmentBrandById(req.getId()); EquipmentBrand equipmentBrand = equipmentBrandService.selectEquipmentBrandById(req.getId());
BeanUtils.copyProperty(equipmentBrand, req, true); BeanUtils.copyProperty(equipmentBrand, req, true);
equipmentBrandService.updateEquipmentBrandById(equipmentBrand); equipmentBrandService.updateEquipmentBrandById(equipmentBrand);
equipmentInfoService.updateCoverEquipmentInfoByBrandId(equipmentBrand.getId(), equipmentBrand.getBrand());
return R.ok("编辑成功"); return R.ok("编辑成功");
} }

View File

@ -64,23 +64,27 @@ public class EquipmentController extends AbstractController {
return R.ok(); return R.ok();
} }
FindEquipmentResModel model = new FindEquipmentResModel(); FindEquipmentResModel model = new FindEquipmentResModel();
/*//下面的逻辑有bug下周修复20200925 20200927修复注释掉
EquipmentType equipmentType = iEquipmentTypeService.selectByType(equipmentInfo.getType()); EquipmentType equipmentType = iEquipmentTypeService.selectByType(equipmentInfo.getType());
EquipmentBrand equipmentBrand = equipmentBrandService.selectByBrand(equipmentInfo.getBrandName()); EquipmentBrand equipmentBrand = equipmentBrandService.selectByBrand(equipmentInfo.getBrandName());
EquipmentSpecs equipmentSpecs = equipmentSpecsService.selectSpecs(equipmentInfo.getSpecType()); EquipmentSpecs equipmentSpecs = equipmentSpecsService.selectSpecs(equipmentInfo.getSpecType());*/
BeanUtils.copyProperties(equipmentInfo,model); BeanUtils.copyProperties(equipmentInfo,model);
model.setState(equipmentInfo.getEquipmentState()); model.setState(equipmentInfo.getEquipmentState());
if(equipmentInfo.getSaiId()!=null){ if(equipmentInfo.getSaiId()!=null){
model.setUserId(equipmentInfo.getSaiId()); model.setUserId(equipmentInfo.getSaiId());
model.setEmployee(false); model.setEmployee(false);
} }
Optional.ofNullable(equipmentType).ifPresent(equipmentType1 -> model.setTypeId(equipmentType1.getId())); model.setTypeId(equipmentInfo.getTypeId());
model.setBrandId(equipmentInfo.getBrandId());
model.setSpecId(equipmentInfo.getSpecsId());
/*Optional.ofNullable(equipmentType).ifPresent(equipmentType1 -> model.setTypeId(equipmentType1.getId()));
Optional.ofNullable(equipmentBrand).ifPresent(equipmentBrand1 -> model.setBrandId(equipmentBrand1.getId())); Optional.ofNullable(equipmentBrand).ifPresent(equipmentBrand1 -> model.setBrandId(equipmentBrand1.getId()));
Optional.ofNullable(equipmentSpecs).ifPresent(new Consumer<EquipmentSpecs>() { Optional.ofNullable(equipmentSpecs).ifPresent(new Consumer<EquipmentSpecs>() {
@Override @Override
public void accept(EquipmentSpecs equipmentSpecs1) { public void accept(EquipmentSpecs equipmentSpecs1) {
model.setSpecId(equipmentSpecs1.getId()); model.setSpecId(equipmentSpecs1.getId());
} }
}); });*/
addRecord(equipmentInfo); addRecord(equipmentInfo);
return R.ok().put("data", model); return R.ok().put("data", model);
@ -112,8 +116,8 @@ public class EquipmentController extends AbstractController {
try { try {
iEquipmentInfoService.changeEquipmentInfo(dto,getUser()); iEquipmentInfoService.changeEquipmentInfo(dto,getUser());
} catch (Exception e) { } catch (Exception e) {
log.error("绑定设备异常",e); log.error("绑定设备异常{}",e);
return R.error(); return R.error(e.getMessage());
} }
return R.ok(); return R.ok();

View File

@ -10,6 +10,7 @@ import com.lz.modules.equipment.entity.EquipmentType;
import com.lz.modules.equipment.entity.resp.EquipmentSpecsResp; import com.lz.modules.equipment.entity.resp.EquipmentSpecsResp;
import com.lz.modules.equipment.service.EquipmentBrandService; import com.lz.modules.equipment.service.EquipmentBrandService;
import com.lz.modules.equipment.service.EquipmentSpecsService; import com.lz.modules.equipment.service.EquipmentSpecsService;
import com.lz.modules.equipment.service.IEquipmentInfoService;
import com.lz.modules.equipment.service.IEquipmentTypeService; import com.lz.modules.equipment.service.IEquipmentTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -40,6 +41,9 @@ public class EquipmentSpecsController {
@Autowired @Autowired
private EquipmentBrandService equipmentBrandService; private EquipmentBrandService equipmentBrandService;
@Resource
private IEquipmentInfoService equipmentInfoService;
/** /**
* 添加规格表页面 * 添加规格表页面
* *
@ -97,6 +101,7 @@ public class EquipmentSpecsController {
equipmentSpecs.setGmtCreate(equipmentSpecs.getGmtCreate()); equipmentSpecs.setGmtCreate(equipmentSpecs.getGmtCreate());
equipmentSpecs.setGmtModified(new Date()); equipmentSpecs.setGmtModified(new Date());
equipmentSpecsService.updateEquipmentSpecsById(equipmentSpecs); equipmentSpecsService.updateEquipmentSpecsById(equipmentSpecs);
equipmentInfoService.updateCoverEquipmentInfoBySpecsId(equipmentSpecs.getId(), equipmentSpecs.getSpecs());
return R.ok("编辑成功"); return R.ok("编辑成功");
} }

View File

@ -6,6 +6,7 @@ import com.lz.common.utils.R;
import com.lz.modules.app.utils.BeanUtils; import com.lz.modules.app.utils.BeanUtils;
import com.lz.modules.equipment.entity.EquipmentType; import com.lz.modules.equipment.entity.EquipmentType;
import com.lz.modules.equipment.entity.EquipmentTypeReq; import com.lz.modules.equipment.entity.EquipmentTypeReq;
import com.lz.modules.equipment.service.IEquipmentInfoService;
import com.lz.modules.equipment.service.IEquipmentTypeService; import com.lz.modules.equipment.service.IEquipmentTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +30,9 @@ public class EquipmentTypeController {
@Resource @Resource
private IEquipmentTypeService equipmentTypeService; private IEquipmentTypeService equipmentTypeService;
@Resource
private IEquipmentInfoService equipmentInfoService;
/** /**
* 添加类型表页面 * 添加类型表页面
@ -79,6 +83,8 @@ public class EquipmentTypeController {
EquipmentType equipmentType = equipmentTypeService.selectEquipmentTypeById(req.getId()); EquipmentType equipmentType = equipmentTypeService.selectEquipmentTypeById(req.getId());
BeanUtils.copyProperty(equipmentType,req,true); BeanUtils.copyProperty(equipmentType,req,true);
equipmentTypeService.updateEquipmentTypeById(equipmentType); equipmentTypeService.updateEquipmentTypeById(equipmentType);
//更新所有再记录中所有的类型名称
equipmentInfoService.updateCoverEquipmentInfoByTypeId(equipmentType.getId(), equipmentType.getType());
return R.ok("编辑成功"); return R.ok("编辑成功");
} }

View File

@ -54,4 +54,8 @@ public interface EquipmentInfoMapper extends BaseMapper<EquipmentInfo> {
int selectCountByNotFind(@Param("num") Integer num); int selectCountByNotFind(@Param("num") Integer num);
int selectCountAllDepartment(@Param("num") Integer num); int selectCountAllDepartment(@Param("num") Integer num);
int updateCoverEquipmentInfoByTypeId(@Param("id") Long id, @Param("type") String type);
int updateCoverEquipmentInfoByBrandId(@Param("id") Long id, @Param("brand") String brand);
int updateCoverEquipmentInfoBySpecsId(@Param("id") Long id, @Param("specs") String specs);
} }

View File

@ -67,6 +67,13 @@ public class EquipmentInfo implements java.io.Serializable {
private Long saiId; private Long saiId;
//第几次盘点 //第几次盘点
private Integer count; private Integer count;
//类型id
private Long typeId;
//品牌id
private Long brandId;
//规格id
private Long specsId;
/** /**
* 主键id * 主键id
* @return * @return
@ -427,6 +434,30 @@ public class EquipmentInfo implements java.io.Serializable {
this.count = count; this.count = count;
} }
public Long getTypeId() {
return typeId;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public Long getBrandId() {
return brandId;
}
public void setBrandId(Long brandId) {
this.brandId = brandId;
}
public Long getSpecsId() {
return specsId;
}
public void setSpecsId(Long specsId) {
this.specsId = specsId;
}
@Override @Override
public String toString() { public String toString() {
return "EquipmentInfo{" + return "EquipmentInfo{" +
@ -454,6 +485,9 @@ public class EquipmentInfo implements java.io.Serializable {
",userId=" + userId + ",userId=" + userId +
",saiId=" + saiId + ",saiId=" + saiId +
",count=" + count + ",count=" + count +
",typeId=" + typeId +
",brandId=" + brandId +
",specsId=" + specsId +
"}"; "}";
} }
} }

View File

@ -61,4 +61,10 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> {
int selectCountByNotFind(Integer num); int selectCountByNotFind(Integer num);
int selectCountAllDepartment(int num); int selectCountAllDepartment(int num);
int updateCoverEquipmentInfoByTypeId(Long id, String type);
int updateCoverEquipmentInfoByBrandId(Long id, String brand);
int updateCoverEquipmentInfoBySpecsId(Long id, String specs);
} }

View File

@ -108,13 +108,13 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
EquipmentBrand equipmentBrand = equipmentBrandMapper.selectEquipmentBrandById(dto.getBrandId()); EquipmentBrand equipmentBrand = equipmentBrandMapper.selectEquipmentBrandById(dto.getBrandId());
EquipmentSpecs equipmentSpecs = equipmentSpecsMapper.selectEquipmentSpecsById(dto.getSpecId()); EquipmentSpecs equipmentSpecs = equipmentSpecsMapper.selectEquipmentSpecsById(dto.getSpecId());
if(equipmentType==null){ if(equipmentType==null){
throw new ZSException("设备类型错误"); throw new ZSException("设备类型错误,不存在或被删除");
} }
if(equipmentBrand==null){ if(equipmentBrand==null){
throw new ZSException("设备品牌错误"); throw new ZSException("设备品牌错误,不存在或被删除");
} }
if(equipmentSpecs==null){ if(equipmentSpecs==null){
throw new ZSException("设备规格错误"); throw new ZSException("设备规格错误,不存在或被删除");
} }
EquipmentInfo info = equipmentInfoMapper.selectEquipmentInfoById(dto.getId()); EquipmentInfo info = equipmentInfoMapper.selectEquipmentInfoById(dto.getId());
@ -302,4 +302,19 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
public int selectCountAllDepartment(int num) { public int selectCountAllDepartment(int num) {
return equipmentInfoMapper.selectCountAllDepartment(num); return equipmentInfoMapper.selectCountAllDepartment(num);
} }
@Override
public int updateCoverEquipmentInfoByTypeId(Long id, String type){
return equipmentInfoMapper.updateCoverEquipmentInfoByTypeId(id, type);
}
@Override
public int updateCoverEquipmentInfoByBrandId(Long id, String brand){
return equipmentInfoMapper.updateCoverEquipmentInfoByBrandId(id, brand);
}
@Override
public int updateCoverEquipmentInfoBySpecsId(Long id, String specs){
return equipmentInfoMapper.updateCoverEquipmentInfoBySpecsId(id, specs);
}
} }

View File

@ -28,12 +28,15 @@
<result column="user_id" property="userId"/> <result column="user_id" property="userId"/>
<result column="sai_id" property="saiId"/> <result column="sai_id" property="saiId"/>
<result column="count" property="count"/> <result column="count" property="count"/>
<result column="type_id" property="typeId"/>
<result column="brand_id" property="brandId"/>
<result column="specs_di" property="specsId"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, brand_name AS brandName, spec_type AS specType, type AS type, num AS num, unit AS unit, user AS user, owner AS owner, qr AS qr, original_code AS originalCode, code AS code, mark AS mark, gmt_outbound AS gmtOutbound, gmt_inbound AS gmtInbound, equipment_state AS equipmentState, buy_amount AS buyAmount, sale_amount AS saleAmount, no AS no, user_id AS userId, sai_id AS saiId, count AS count id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, brand_name AS brandName, spec_type AS specType, type AS type, num AS num, unit AS unit, user AS user, owner AS owner, qr AS qr, original_code AS originalCode, code AS code, mark AS mark, gmt_outbound AS gmtOutbound, gmt_inbound AS gmtInbound, equipment_state AS equipmentState, buy_amount AS buyAmount, sale_amount AS saleAmount, no AS no, user_id AS userId, sai_id AS saiId, count AS count, type_id AS typeId, brand_id AS brandId, specs_id AS specsId
</sql> </sql>
@ -65,6 +68,9 @@
<if test="no != null">no, </if> <if test="no != null">no, </if>
<if test="userId != null">user_id, </if> <if test="userId != null">user_id, </if>
<if test="saiId != null">sai_id, </if> <if test="saiId != null">sai_id, </if>
<if test="typeId != null">type_id, </if>
<if test="brandId != null">brand_id, </if>
<if test="specsId != null">specs_id, </if>
<if test="count != null">count, </if> <if test="count != null">count, </if>
is_delete, is_delete,
gmt_create, gmt_create,
@ -89,6 +95,9 @@
<if test="no != null">#{ no}, </if> <if test="no != null">#{ no}, </if>
<if test="userId != null">#{ userId}, </if> <if test="userId != null">#{ userId}, </if>
<if test="saiId != null">#{ saiId}, </if> <if test="saiId != null">#{ saiId}, </if>
<if test="typeId != null">#{typeId}, </if>
<if test="brandId != null">#{brandId}, </if>
<if test="specsId != null">#{specsId]}, </if>
<if test="count != null">#{ count}, </if> <if test="count != null">#{ count}, </if>
0, 0,
now(), now(),
@ -122,6 +131,9 @@
<if test="no != null">no = #{no},</if> <if test="no != null">no = #{no},</if>
<if test="userId != null">user_id = #{userId},</if> <if test="userId != null">user_id = #{userId},</if>
<if test="saiId != null">sai_id = #{saiId},</if> <if test="saiId != null">sai_id = #{saiId},</if>
<if test="typeId != null">type_id=#{typeId}, </if>
<if test="brandId != null">brand_id=#{brandId}, </if>
<if test="specsId != null">specs_id=#{specsId]}, </if>
<if test="count != null">count = #{count}</if> <if test="count != null">count = #{count}</if>
</trim> </trim>
,gmt_modified = now() ,gmt_modified = now()
@ -154,6 +166,9 @@
no = #{no}, no = #{no},
user_id = #{userId}, user_id = #{userId},
sai_id = #{saiId}, sai_id = #{saiId},
type_id=#{typeId},
brand_id=#{brandId},
specs_id=#{specsId},
count = #{count} count = #{count}
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
@ -278,5 +293,17 @@
select ifnull(count(*),0) from equipment_info where is_delete = 0 and count =#{num} and depart_id is not null and depart_id > 0 select ifnull(count(*),0) from equipment_info where is_delete = 0 and count =#{num} and depart_id is not null and depart_id > 0
</select> </select>
<update id="updateCoverEquipmentInfoByTypeId" parameterType="java.lang.Long">
update equipment_info set type = #{type} where type_id=#{id}
</update>
<update id="updateCoverEquipmentInfoByBrandId" parameterType="java.lang.Long">
update equipment_info set brand_name = #{brand} where type_id=#{id}
</update>
<update id="updateCoverEquipmentInfoBySpecsId" parameterType="java.lang.Long">
update equipment_info set spec_type = #{specs} where type_id=#{id}
</update>
</mapper> </mapper>