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.TBigOverhaul; import com.thhy.engineering.modules.biz.device.entity.TBigOverhaulPath; import com.thhy.engineering.modules.biz.device.mapper.TBigOverhaulMapper; import com.thhy.engineering.modules.biz.device.service.TBigOverhaulService; 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 TBigOverhaulServiceImpl implements TBigOverhaulService { @Resource private TBigOverhaulMapper overhaulMapper; @Override public BasicResult overhaulInsert(Map values) { SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); String userId = sysUserInfo.getUserId(); values.put("createUser",userId); values.put("bigOverhaulId",""); overhaulMapper.overhaulInsert(values); List files = (List) values.get("files"); if(files!=null && files.size()>0){ for (String file :files){ HashMap hashMap = new HashMap<>(); hashMap.put("overhaulPathId",""); hashMap.put("bigOverhaulId",values.get("bigOverhaulId").toString()); hashMap.put("overhaulPath",file); overhaulMapper.overhaulPathInsert(hashMap); } } return BasicResult.success("添加成功"); } @Override public BasicResult overhaulList(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 bigOverhauls = overhaulMapper.overhaulList(values); PageInfo tBigOverhaulPageInfo = new PageInfo<>(bigOverhauls); return BasicResult.success(tBigOverhaulPageInfo); } @Override public BasicResult overhaulInfo(String bigOverhaulId) { TBigOverhaul bigOverhaul = overhaulMapper.overhaulInfo(bigOverhaulId); List overhaulPaths= overhaulMapper.overhaulPath(bigOverhaulId); bigOverhaul.setOverhaulPaths(overhaulPaths); return BasicResult.success(bigOverhaul); } @Override @Transactional public BasicResult overhaulDel(String bigOverhaulId) { overhaulMapper.overhaulDel(bigOverhaulId); overhaulMapper.overhaulPathDel(bigOverhaulId); return BasicResult.success("删除成功"); } @Override public BasicResult overhaulUpdate(Map values) { String bigOverhaulId = values.get("bigOverhaulId").toString(); overhaulMapper.overhaulPathDel(bigOverhaulId); List files = (List) values.get("files"); if(files!=null && files.size()>0){ for (String file :files){ HashMap hashMap = new HashMap<>(); hashMap.put("overhaulPathId",""); hashMap.put("bigOverhaulId",values.get("bigOverhaulId").toString()); hashMap.put("overhaulPath",file); overhaulMapper.overhaulPathInsert(hashMap); } } overhaulMapper.overhaulUpdate(values); return BasicResult.success("修改成功"); } }