| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.thhy.general.common.BasicResult; |
| | | import com.thhy.general.config.SysUserInfo; |
| | | import com.thhy.general.utils.ExcelUtils; |
| | | import com.thhy.general.utils.UUIDUtils; |
| | | import com.thhy.general.utils.UserInfoUtils; |
| | | import com.thhy.secure.modules.biz.hiddenDanger.entity.HiddenDangerEntity; |
| | | import com.thhy.secure.modules.biz.hiddenDanger.mapper.HiddenDangerMapper; |
| | | import com.thhy.secure.modules.biz.hiddenDanger.service.HiddenDangerService; |
| | | import com.thhy.secure.modules.biz.integralAccount.entity.IntegralAccountEntity; |
| | | import com.thhy.secure.modules.biz.integralAccount.entity.IntegralDetailEntity; |
| | | import com.thhy.secure.modules.biz.integralAccount.mapper.IntegralDetailMapper; |
| | | import com.thhy.secure.modules.biz.regionInspection.mapper.RegionInspectionRecordMapper; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Author QiuYuHao |
| | |
| | | @Autowired |
| | | private HiddenDangerMapper hiddenDangerMapper; |
| | | |
| | | @Autowired |
| | | private IntegralDetailMapper integralDetailMapper; |
| | | |
| | | @Autowired |
| | | private RegionInspectionRecordMapper regionInspectionRecordMapper; |
| | | private static final Object Lock = new Object(); |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | map.put("companyId",sysUserInfo.getCompanyId()); |
| | | int pageNum = (int) map.get("pageNum"); |
| | | int pageSize = (int) map.get("pageSize"); |
| | | int type = 0; |
| | | if( map.get("type")!= null){ |
| | | type = (int) map.get("type");//type =1 小程序来的 |
| | | } |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<HiddenDangerEntity> hiddenDangerEntities = hiddenDangerMapper.selectPageList(map); |
| | | List<HiddenDangerEntity> hiddenDangerEntities = new ArrayList<>(); |
| | | if(type == 1){//审核列表 |
| | | if (sysUserInfo.getUserType() == 2){ |
| | | map.put("createUser",sysUserInfo.getUserId()); |
| | | } |
| | | //小程序 待审核排前面 待审核按时间正序 审核成功的倒叙 |
| | | hiddenDangerEntities = hiddenDangerMapper.selectAppList(map); |
| | | }else if(type == 2){//隐患举报详情列表 |
| | | if (sysUserInfo.getUserType() == 2){ |
| | | map.put("createUser",sysUserInfo.getUserId()); |
| | | } |
| | | //小程序 待审核排前面 待审核按时间正序 审核成功的倒叙 |
| | | hiddenDangerEntities = hiddenDangerMapper.selectPageList(map); |
| | | } |
| | | else { |
| | | //web 按时间倒序 |
| | | hiddenDangerEntities = hiddenDangerMapper.selectPageList(map); |
| | | } |
| | | hiddenDangerEntities.forEach(obj ->{ |
| | | String id = obj.getId(); |
| | | obj.setImgEntities(hiddenDangerMapper.selectImgList(id)); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BasicResult selectNoPageList(Map<String, Object> map) { |
| | | public void export(Map<String, Object> map, HttpServletResponse response) { |
| | | SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); |
| | | map.put("companyId",sysUserInfo.getCompanyId()); |
| | | List<HiddenDangerEntity> hiddenDangerEntities = hiddenDangerMapper.selectPageList(map); |
| | | hiddenDangerEntities.forEach(obj ->{ |
| | | String id = obj.getId(); |
| | | obj.setImgEntities(hiddenDangerMapper.selectImgList(id)); |
| | | Integer auditStatus = obj.getAuditStatus(); |
| | | Integer level = obj.getLevel(); |
| | | switch (auditStatus){ |
| | | case 0: |
| | | obj.setAuditStatusName("未审核"); |
| | | break; |
| | | case 1: |
| | | obj.setAuditStatusName("已审核"); |
| | | break; |
| | | case 2: |
| | | obj.setAuditStatusName("审核失败"); |
| | | break; |
| | | } |
| | | if (level != null){ |
| | | switch (level){ |
| | | case 1: |
| | | obj.setLevelName("一般隐患"); |
| | | break; |
| | | case 2: |
| | | obj.setLevelName("重大隐患"); |
| | | break; |
| | | case 3: |
| | | obj.setLevelName("不存在"); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | return BasicResult.success(hiddenDangerEntities); |
| | | ExcelUtils.downExcel(hiddenDangerEntities,HiddenDangerEntity.class,response,"隐患举报"); |
| | | } |
| | | |
| | | @Override |
| | | public BasicResult selectInfo(String id) { |
| | | return BasicResult.success(hiddenDangerMapper.selectInfo(id)); |
| | | HiddenDangerEntity hiddenDangerEntity = hiddenDangerMapper.selectInfo(id); |
| | | hiddenDangerEntity.setImgEntities(hiddenDangerMapper.selectImgList(id)); |
| | | return BasicResult.success(hiddenDangerEntity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BasicResult examine(HiddenDangerEntity hiddenDangerEntity) { |
| | | hiddenDangerMapper.update(hiddenDangerEntity); |
| | | SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(); |
| | | String platUserId = regionInspectionRecordMapper.selectPlatUserId(hiddenDangerEntity.getCreateUser()); |
| | | |
| | | Map account = new HashMap(); |
| | | account.put("userId",platUserId); |
| | | //查询账户 |
| | | IntegralAccountEntity queryAccount = integralDetailMapper.selectByOne(account); |
| | | Double accumulateIntegral = 0.0; |
| | | Double totalIntegral = 0.0; |
| | | if (queryAccount != null){ |
| | | accumulateIntegral = queryAccount.getAccumulateIntegral();//累计积分 |
| | | totalIntegral = queryAccount.getTotalIntegral();//当前余额 |
| | | } |
| | | hiddenDangerEntity.setAuditStatus(1);//1审核通过 |
| | | hiddenDangerEntity.setDangerLocation(null); |
| | | synchronized (Lock){ |
| | | hiddenDangerMapper.update(hiddenDangerEntity); |
| | | IntegralAccountEntity integralAccountEntity = IntegralAccountEntity |
| | | .builder() |
| | | .userId(platUserId) |
| | | .id(UUIDUtils.create()) |
| | | .accumulateIntegral(accumulateIntegral+hiddenDangerEntity.getIntegral()) |
| | | .totalIntegral(totalIntegral+hiddenDangerEntity.getIntegral()) |
| | | .userType(sysUserInfo.getUserType()) |
| | | .build(); |
| | | |
| | | IntegralDetailEntity integralDetailEntity = IntegralDetailEntity |
| | | .builder() |
| | | .id(UUIDUtils.create()) |
| | | .balanc(totalIntegral+hiddenDangerEntity.getIntegral()) |
| | | .integralSource("隐患审核") |
| | | .integralWater(hiddenDangerEntity.getIntegral()) |
| | | .createTime(new Date()) |
| | | .createUser(sysUserInfo.getUserId()) |
| | | .userType(sysUserInfo.getUserType()) |
| | | .userId(platUserId) |
| | | .type(1) |
| | | .remark("隐患审核") |
| | | .companyId(sysUserInfo.getCompanyId()) |
| | | .build(); |
| | | |
| | | integralDetailMapper.insertAndUpdateAccount(integralAccountEntity); |
| | | integralDetailMapper.insertDetailAndUpdate(integralDetailEntity); |
| | | } |
| | | return BasicResult.success(); |
| | | } |
| | | } |