package com.thhy.engineering.modules.biz.device.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.thhy.engineering.modules.biz.device.entity.TBigInspect; import com.thhy.engineering.modules.biz.device.entity.TBigInspectType; import com.thhy.engineering.modules.biz.device.mapper.TBigInspectMapper; import com.thhy.engineering.modules.biz.device.service.TBigInspectService; import com.thhy.general.common.BasicResult; import com.thhy.general.config.SysUserInfo; import com.thhy.general.utils.UserInfoUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; @Service public class TBigInspectServiceImpl implements TBigInspectService { @Resource private TBigInspectMapper bigInspectMapper; @Override @Transactional public BasicResult bigInspectInsert(Map values) { SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); String userId = sysUserInfo.getUserId(); values.put("bigInspectId",""); values.put("createUser",userId); bigInspectMapper.bigInspectInsert(values); String bigInspectId = values.get("bigInspectId").toString(); List typeIds = (List) values.get("typeIds"); for (String typeId :typeIds){ HashMap hashMap = new HashMap<>(); hashMap.put("bigInspectId",bigInspectId); hashMap.put("typeId",typeId); hashMap.put("inspectTypeId",""); bigInspectMapper.bigInspectTypeInsert(hashMap); } return BasicResult.success("添加成功"); } @Override public BasicResult bigInspectList(Map values) { SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); String companyId = sysUserInfo.getCompanyId(); values.put("companyId",companyId); Integer pageSize = Integer.valueOf(values.get("pageSize").toString()); Integer pageNum = Integer.valueOf(values.get("pageNum").toString()); PageHelper.startPage(pageNum,pageSize); List bigInspects = bigInspectMapper.bigInspectList(values); if(bigInspects!=null&&bigInspects.size()>0){ for (TBigInspect bigInspect:bigInspects){ List inspectTypes = bigInspectMapper.inspectTypes(bigInspect.getBigInspectId()); bigInspect.setInspectTypes(inspectTypes); } } PageInfo tBigInspectPageInfo = new PageInfo<>(bigInspects); return BasicResult.success(tBigInspectPageInfo); } @Override public BasicResult bigInspectInfo(String bigInspectId) { TBigInspect bigInspects = bigInspectMapper.bigInspectInfo(bigInspectId); List inspectTypes = bigInspectMapper.inspectTypes(bigInspects.getBigInspectId()); bigInspects.setInspectTypes(inspectTypes); return BasicResult.success(bigInspects); } @Override @Transactional public BasicResult bigInspectDel(String bigInspectId) { bigInspectMapper.bigTypeDel(bigInspectId); //缺少 更改 设备检查 状态 bigInspectMapper.bigInspectDel(bigInspectId); return BasicResult.success("删除成功"); } @Override public BasicResult bigInspectUpdate(Map values) { String bigInspectId = values.get("bigInspectId").toString(); bigInspectMapper.bigTypeDel(bigInspectId); List typeIds = (List) values.get("typeIds"); for (String typeId :typeIds){ HashMap hashMap = new HashMap<>(); hashMap.put("bigInspectId",bigInspectId); hashMap.put("typeId",typeId); hashMap.put("inspectTypeId",""); bigInspectMapper.bigInspectTypeInsert(hashMap); } bigInspectMapper.bigInspectUpdate(values); return BasicResult.success("修改成功"); } }