| | |
| | | e.printStackTrace(); |
| | | return Result.fail("数字格式异常"); |
| | | } |
| | | |
| | | /** 安全异常 */ |
| | | @ExceptionHandler(SecurityException.class) |
| | | public Result<?> SecurityException(SecurityException e) { |
| | |
| | | e.printStackTrace(); |
| | | return Result.fail("数组越界异常"); |
| | | } |
| | | |
| | | /** sql语法错误异常 */ |
| | | @ExceptionHandler(BadSqlGrammarException.class) |
| | | public Result<?> BadSqlGrammarException(BadSqlGrammarException e) { |
| | |
| | | return Result.fail("网络连接失败,请退出后再试"); |
| | | } |
| | | |
| | | /** |
| | | * 权限 |
| | | * @param e |
| | | * @return |
| | | */ |
| | | @ExceptionHandler({AuthException.class}) |
| | | public Result<?> noAuth(AuthException e){ |
| | | return Result.fail(Integer.valueOf(e.getCode()),e.getMsg()); |
| | |
| | | @ApiImplicitParam(name = "code", value = "申请单编号", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "beginTime", value = "检验开始时间", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "endTime", value = "检验结束时间", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "status", value = "检验结果", dataTypeClass = Integer.class) |
| | | @ApiImplicitParam(name = "status", value = "检验结果", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "isLookMe", value = "是否只看我", dataTypeClass = Boolean.class) |
| | | }) |
| | | @GetMapping("/selectAllPlan") |
| | | @AuthHandler |
| | | public Result selectAllPlan(String code, String beginTime, String endTime, Integer status) { |
| | | return Result.success(planService.selectAllPlan(code, beginTime, endTime, status)); |
| | | public Result selectAllPlan(String code, String beginTime, String endTime, Integer status,boolean isLookMe) { |
| | | return Result.success(planService.selectAllPlan(code, beginTime, endTime, status,isLookMe)); |
| | | } |
| | | |
| | | @ApiOperation("分配-->选择检验人") |
| | |
| | | //查询该月的成品合格率 |
| | | Long getOkFinByMonth(String monthofYear); |
| | | |
| | | List<Map<String, Object>>getInspectionMaterials(Long id); |
| | | |
| | | Map<String, Object> selectImAndUserName(Integer id); |
| | | } |
| | | |
| | |
| | | public interface PlanMapper { |
| | | |
| | | //查询检验计划 |
| | | List<Map<String, Object>> selectAllPlan(String code, String beginTime, String endTime,Integer status); |
| | | List<Map<String, Object>> selectAllPlan(String code, String beginTime, String endTime,Integer status,Boolean isLookMe,Integer id); |
| | | } |
| | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.sql.Date; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author 张宾 |
| | |
| | | private String specifications; |
| | | |
| | | /** |
| | | * 规格型号 |
| | | */ |
| | | private Integer specificationsId; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private String createdUser; |
| | |
| | | * 查询检验计划 |
| | | * @return |
| | | */ |
| | | List<Map<String,Object>> selectAllPlan(String code , String beginTime, String endTime,Integer status); |
| | | List<Map<String,Object>> selectAllPlan(String code , String beginTime, String endTime,Integer status,Boolean isLookMe); |
| | | |
| | | /** |
| | | * 分配-->选择检验人 |
| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.yuanchu.limslaboratory.mapper.*; |
| | | import com.yuanchu.limslaboratory.pojo.Inspection; |
| | | import com.yuanchu.limslaboratory.pojo.InspectionProduct; |
| | | import com.yuanchu.limslaboratory.pojo.NonConformanceReview; |
| | | import com.yuanchu.limslaboratory.pojo.Report; |
| | | import com.yuanchu.limslaboratory.pojo.*; |
| | | import com.yuanchu.limslaboratory.service.PlanService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.utils.ServletUtils; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | //查询检验计划 |
| | | @Override |
| | | public List<Map<String, Object>> selectAllPlan(String code, String beginTime, String endTime, Integer status) { |
| | | return planMapper.selectAllPlan(code, beginTime, endTime, status); |
| | | public List<Map<String, Object>> selectAllPlan(String code, String beginTime, String endTime, Integer status,Boolean isLookMe) { |
| | | Object obj = RedisUtil.get(ServletUtils.getRequest().getHeader("X-Token")); |
| | | Integer id=null; |
| | | if(isLookMe&&!ObjectUtils.isEmpty(obj)){ |
| | | Map loginUser = (Map) obj; |
| | | id=Integer.parseInt(String.valueOf(loginUser.get("id"))); |
| | | } |
| | | return planMapper.selectAllPlan(code, beginTime, endTime, status,isLookMe,id); |
| | | } |
| | | |
| | | //分配-->选择检验人 |
| | |
| | | //更新检验单 |
| | | inspectionMapper.updateById(inspection); |
| | | //添加不合格信息到评审 |
| | | Map<String, Object> map = inspectionMapper.selectImAndUserName(id); |
| | | NonConformanceReview nonConformanceReview = new NonConformanceReview(); |
| | | LocalDateTime localDateTime = DateUtil.toLocalDateTime(DateUtil.date()); |
| | | nonConformanceReview.setCreatedTime(localDateTime); |
| | | nonConformanceReview.setUpdatedTime(localDateTime); |
| | | nonConformanceReview.setMaterialCode(String.valueOf(map.get("code"))); |
| | | nonConformanceReview.setInspectionCode(String.valueOf(map.get("iCode"))); |
| | | nonConformanceReview.setMaterialName(String.valueOf(map.get("name"))); |
| | | nonConformanceReview.setSpecifications(String.valueOf(map.get("specifications"))); |
| | | nonConformanceReview.setSpecificationsId(Integer.valueOf(String.valueOf(map.get("specificationsId")))); |
| | | nonConformanceReview.setState(1); |
| | | Date iCreateTime = DateUtil.parse(String.valueOf(map.get("iCreateTime"))); |
| | | nonConformanceReview.setCreateTime(iCreateTime); |
| | | nonConformanceReview.setTestManager(String.valueOf(map.get("uName"))); |
| | | Object obj = RedisUtil.get(ServletUtils.getRequest().getHeader("X-Token")); |
| | | if (!ObjectUtils.isEmpty(obj)) { |
| | | Map loginUser = (Map) obj; |
| | | nonConformanceReview.setCreatedUser(String.valueOf(loginUser.get("id"))); |
| | | } |
| | | int insert = nonConformanceReviewMapper.insert(nonConformanceReview); |
| | | if(insert<1){ |
| | | return "上报失败"; |
| | | } |
| | | } else if (count == results.size()) { |
| | | Inspection inspection = new Inspection(); |
| | | inspection.setId(id); |
| | |
| | | and inspection_status = 1 |
| | | and DATE_FORMAT(end_time, '%Y-%m') = #{monthofYear} |
| | | </select> |
| | | <select id="getInspectionMaterials" resultType="java.util.Map"> |
| | | |
| | | </select> |
| | | <select id="selectImAndUserName" resultType="java.util.Map"> |
| | | SELECT |
| | | im.`code`, |
| | | im.`name`, |
| | | i.`code` iCode, |
| | | i.create_time iCreateTime, |
| | | im.specifications_id specificationsId, |
| | | im.specifications specifications, |
| | | u.`name` uName |
| | | FROM |
| | | inspection i, |
| | | inspection_material im, |
| | | `user` u |
| | | WHERE |
| | | i.id = im.inspection_id |
| | | AND i.user_id=u.id |
| | | AND i.id=#{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | internal, |
| | | test_value testValue, |
| | | test_state testState, |
| | | u.id uId, |
| | | u.id uId, |
| | | u.name checker, |
| | | isu.id isuId, |
| | | isu.id isuId, |
| | | isu.classify_id classId, |
| | | equipment_name instrumentname |
| | | from lims_laboratory.inspection_product ip |
| | |
| | | <if test="beginTime != null and endTime != null"> |
| | | and i.start_time between #{beginTime} and #{endTime} |
| | | </if> |
| | | <if test="isLookMe != false and id != null"> |
| | | and ip.user_id=#{id} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | public void pointCut() { |
| | | } |
| | | |
| | | private final static String ADMIN = "f5c8bcb7d5a0fd27e2323280f7e98cad"; |
| | | private final static String ADMIN = "c3284d0f94606de1fd2af172aba15bf3"; |
| | | |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Test |
| | | void TT2(){ |
| | | String adminMD5 = SecureUtil.md5(SecureUtil.md5("Fixiaobai")); |
| | | String adminMD5 = SecureUtil.md5(SecureUtil.md5("admin")); |
| | | System.out.println(adminMD5); |
| | | // 构建 |
| | | AES aes = SecureUtil.aes(adminMD5.getBytes(StandardCharsets.UTF_8)); |
| | | String admins = aes.encryptHex("Fixiaobai"); |
| | | System.out.println(SecureUtil.md5(admins)); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.crypto.symmetric.AES; |
| | | import com.yuanchu.limslaboratory.mapper.RoleManageMapper; |
| | | import com.yuanchu.limslaboratory.mapper.UserMapper; |
| | | import com.yuanchu.limslaboratory.pojo.Menu; |
| | | import com.yuanchu.limslaboratory.pojo.RoleMenu; |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.pojo.dto.RoleAndMenuDto; |
| | | import com.yuanchu.limslaboratory.shiro.utils.JwtUtils; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class UserLoginUtils { |
| | | |
| | | @Autowired |
| | | private JwtUtils jwtUtils; |
| | | @Resource |
| | | private UserClient userClient; |
| | | |
| | | @Value("${login.userID}") |
| | | private String LoginUserID; |
| | | |
| | | @Value("${login.secret}") |
| | | private String LoginSecret; |
| | | |
| | | |
| | | |
| | | public Result<Map<String, Object>> LoginExamine(User user){ |
| | | String token = JwtUtils.sign(user.getAccount()); |
| | | HashMap<String, Object> mapRedis = new HashMap<>(); |
| | | mapRedis.put("id", user.getId()); |
| | | mapRedis.put("account", user.getAccount()); |
| | | mapRedis.put("name", user.getName()); |
| | | mapRedis.put("enterpriseId", user.getEnterpriseId()); |
| | | |
| | | |
| | | String adminMD5 = SecureUtil.md5(SecureUtil.md5(user.getAccount())); |
| | | // 构建 |
| | | AES aes = SecureUtil.aes(adminMD5.getBytes(StandardCharsets.UTF_8)); |
| | | String admins = aes.encryptHex(user.getAccount()); |
| | | mapRedis.put("sessionLayerId", SecureUtil.md5(admins)); |
| | | mapRedis.put("roleId",user.getRoleId()); |
| | | |
| | | //存入redis,二个小时后删除 |
| | | RedisUtil.set(token, mapRedis, 120); |
| | | // |
| | | RedisUtil.set("access_token",token,120); |
| | | // 将签发的 JWT token 返回给前端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String refresh = JwtUtils.sign(user.getAccount()); |
| | | map.put("token", token); |
| | | map.put("refresh", refresh); |
| | | RedisUtil.set(user.getAccount(), map, 168); |
| | | return Result.success(map); |
| | | Map<String, Object> mapData = new HashMap<>(); |
| | | mapData.put("LoginUserID", LoginUserID); |
| | | mapData.put("LoginSecret", LoginSecret); |
| | | Result<?> code = userClient.BusynessUserLogin(mapData); |
| | | if (code.getCode() == 200){ |
| | | Result<?> result = userClient.BusynessUserLoginToken(code.getData().toString()); |
| | | if (result.getCode() == 200){ |
| | | Map data = (Map) result.getData(); |
| | | String token = data.get("token").toString(); |
| | | data.remove("token"); |
| | | HashMap<String, Object> mapRedis = new HashMap<>(); |
| | | mapRedis.put("id", user.getId()); |
| | | mapRedis.put("account", user.getAccount()); |
| | | mapRedis.put("name", user.getName()); |
| | | mapRedis.put("enterpriseId", user.getEnterpriseId()); |
| | | mapRedis.put("data", data); |
| | | String adminMD5 = SecureUtil.md5(SecureUtil.md5(user.getAccount())); |
| | | // 构建 |
| | | mapRedis.put("sessionLayerId", adminMD5); |
| | | mapRedis.put("roleId",user.getRoleId()); |
| | | //存入redis,二个小时后删除 |
| | | RedisUtil.set(token, mapRedis, 120); |
| | | // |
| | | RedisUtil.set("access_token",token,120); |
| | | // 将签发的 JWT token 返回给前端 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | String refresh = JwtUtils.sign(user.getAccount()); |
| | | map.put("token", token); |
| | | map.put("refresh", refresh); |
| | | RedisUtil.set(user.getAccount(), map, 168); |
| | | return Result.success(map); |
| | | } else { |
| | | return Result.fail(result.getMessage()); |
| | | } |
| | | } else { |
| | | return Result.fail(code.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | @Repository |
| | | public interface RoleManageMapper extends BaseMapper<RoleInfo> { |
| | | |
| | | int updateRoleMenuStateByRoleId(Long id); |
| | | |
| | | int insertBatchRoleMenu(@Param("roleMenuAddList") List<RoleMenu> roleMenuList); |
| | | |
| | | int insertRole(RoleInfo roleInfo); |
| | |
| | | |
| | | @Override |
| | | public boolean deleteRole(Long id) { |
| | | return roleManageMapper.updateRoleState(id)>0; |
| | | return roleManageMapper.updateRoleState(id)>0&&roleManageMapper.updateRoleMenuStateByRoleId(id)>0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | SET state = 0 |
| | | WHERE (id = #{id}) |
| | | </update> |
| | | <update id="updateRoleMenuStateByRoleId"> |
| | | UPDATE role_menu |
| | | SET state = 0 |
| | | where role_id = #{id} |
| | | and menu_id !=39 |
| | | </update> |
| | | <delete id="deleteRoleMenuByRoleId"> |
| | | delete |
| | | from role_menu |