| | |
| | | //批量删除 |
| | | void delAllDevice(String ids); |
| | | |
| | | //原材料检验-->选择设备 |
| | | List<Map<String, Object>> chooseDevice(); |
| | | |
| | | } |
| | |
| | | */ |
| | | List<Map<String, Object>> selectTreeDevice(Integer type, String father, Integer deviceStatus, String message); |
| | | |
| | | /** |
| | | * 查询所有设备 |
| | | * @return |
| | | */ |
| | | List<Device> selectDevice(); |
| | | |
| | | /** |
| | | * 根据设备id查询设备名称 |
| | | * @param id |
| | | */ |
| | | String getDeviceNameById(Integer id); |
| | | |
| | | /** |
| | | * 新增仪器设备 |
| | |
| | | * @param ids |
| | | */ |
| | | void delAllDevice(String ids); |
| | | |
| | | /** |
| | | * 原材料检验-->选择设备 |
| | | * @return |
| | | */ |
| | | List<Map<String,Object>> chooseDevice(); |
| | | } |
| | |
| | | return deviceMapper.selectTreeDevice(type, father, deviceStatus, message); |
| | | } |
| | | |
| | | //查询所有设备 |
| | | @Override |
| | | public List<Device> selectDevice() { |
| | | return deviceMapper.selectList(new QueryWrapper<>()); |
| | | } |
| | | |
| | | //根据设备id获取设备名称 |
| | | @Override |
| | | public String getDeviceNameById(Integer id) { |
| | | Device device = deviceMapper.selectById(id); |
| | | return device.getName(); |
| | | } |
| | | |
| | | //新增仪器设备 |
| | | @Override |
| | | public Integer addDevice(DeviceDto deviceDto) { |
| | |
| | | public void delAllDevice(String ids) { |
| | | deviceMapper.delAllDevice(ids); |
| | | } |
| | | |
| | | //原材料检验-->选择设备 |
| | | @Override |
| | | public List<Map<String, Object>> chooseDevice() { |
| | | return deviceMapper.chooseDevice(); |
| | | } |
| | | } |
| | |
| | | where state = 1 |
| | | and device_status in (1, 5) |
| | | </select> |
| | | |
| | | <!--原材料检验-选择设备--> |
| | | <select id="chooseDevice" resultType="java.util.Map"> |
| | | select id, name |
| | | from mom_ocean.device |
| | | where state = 1 |
| | | and device_status in (1, 5) |
| | | </select> |
| | | <!--批量删除--> |
| | | <update id="delAllDevice"> |
| | | update mom_ocean.device |
| | |
| | | <resultMap id="selectAllTechNamTowMap" type="map"> |
| | | <id property="id" column="id"/> |
| | | <result property="name" column="name"/> |
| | | <result property="name" column="unit"/> |
| | | <result property="unit" column="unit"/> |
| | | </resultMap> |
| | | <select id="selectAllTechNam" resultMap="selectAllTechNamMap"> |
| | | select id, |
| | |
| | | </resultMap> |
| | | <resultMap id="selectAllTequeMaps" type="map"> |
| | | <id property="id" column="id"/> |
| | | <result property="name" column="father"/> |
| | | <result property="name" column="unit"/> |
| | | <result property="father" column="father"/> |
| | | <result property="unit" column="unit"/> |
| | | <result property="name" column="name"/> |
| | | </resultMap> |
| | | <select id="selectAllTeque" resultMap="selectAllTequeMap"> |
| | |
| | | <resultMap id="chooseProMaps" type="map"> |
| | | <id property="id" column="technicalModelId"/> |
| | | <result property="name" column="name"/> |
| | | <result property="name" column="unit"/> |
| | | <result property="unit" column="unit"/> |
| | | </resultMap> |
| | | <select id="choosePro" resultMap="chooseProMap"> |
| | | select father, |
| | |
| | | |
| | | <!--根据id查看详情--> |
| | | <resultMap id="selecTechByIdMap" type="map"> |
| | | <id property="id" column="type"/> |
| | | <result property="name" column="father"/> |
| | | <id property="type" column="type"/> |
| | | <result property="father" column="father"/> |
| | | <result property="name" column="name"/> |
| | | <result property="name" column="device_group"/> |
| | | <result property="deviceGroup" column="device_group"/> |
| | | <collection property="children" resultMap="selecTechByIdsMap" javaType="List"/> |
| | | </resultMap> |
| | | <resultMap id="selecTechByIdsMap" type="map"> |
| | |
| | | * @author zss |
| | | * @since 2023-08-01 13:52:30 |
| | | */ |
| | | @Api(tags = "QMS管理-->原材料检验-->检验项目") |
| | | @Api(tags = "QMS管理-->原材料检验") |
| | | @RestController |
| | | @RequestMapping("/rawInsProduct") |
| | | public class RawInsProductController { |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @ApiOperation(value = "查询所有设备") |
| | | @ApiOperation(value = "选择设备") |
| | | @GetMapping("/selectDevice") |
| | | public Result selectDevice() { |
| | | return Result.success(deviceService.selectDevice()); |
| | | return Result.success(deviceService.chooseDevice()); |
| | | } |
| | | |
| | | @ApiOperation("选择设备信息") |
| | | @ApiOperation(value = "更新检验项目(填写检验值,检验设备)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "设备ID", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "rpId", value = "原材料检验项目id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "testValue", value = "检测值", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "DevId", value = "设备id", dataTypeClass = Integer.class,required = true) |
| | | }) |
| | | @GetMapping("/selectDeviceById") |
| | | public Result selectDeviceById(Integer id) { |
| | | return Result.success( deviceService.getDeviceNameById(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "更新检验项目") |
| | | @PostMapping("/updaterawInsProduct") |
| | | public Result updaterawInsProduct(@RequestHeader("token") String token, @RequestBody RawInsProduct rawInsProduct) throws Exception { |
| | | public Result updaterawInsProduct(@RequestHeader("token") String token,Integer rpId ,String testValue,Integer devId) throws Exception { |
| | | Map<String, String> map = jwt.readJWT(token); |
| | | String data = map.get("data"); |
| | | JSONObject jsonObject = new JSONObject(data); |
| | | int userId = Integer.parseInt(jsonObject.getString("id")); |
| | | rawInsProductService.updaterawInsProduct(userId,rawInsProduct); |
| | | rawInsProductService.updaterawInsProduct(userId,rpId,testValue,devId); |
| | | return Result.success(); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.yuanchu.mom.pojo.vo.RawInsProductVo; |
| | | import com.yuanchu.mom.pojo.vo.RawInspectVo; |
| | | import com.yuanchu.mom.service.*; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | |
| | | import org.json.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @Resource |
| | | MaterialService materialService; |
| | | |
| | | @Resource |
| | | SpecificationsService specificationsService; |
| | | @ApiOperation(value = "新增原材料检验单") |
| | | @PostMapping("/addRawInspects") |
| | | public Result addRawInspects(@RequestHeader("token") String token, @RequestBody RawInspectVo rawInspectVo) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | return Result.success(rawInspectService.addRawInspects(data.get("name").replaceAll("\"", ""), rawInspectVo)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询原材料检验单列表") |
| | | @ApiOperation(value = "分页查询原材料检验单列表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "formTime", value = "来料日期", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "createTime", value = "报检日期", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "insState", value = "检测状态: 全部默认2", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "judgeState", value = "合格状态: 全部默认2", dataTypeClass = Integer.class, required = true) |
| | | @ApiImplicitParam(name = "code", value = "原材料编码", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "insState", value = "检测状态(为空=全部)", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "name", value = "原材料名称", dataTypeClass = String.class) |
| | | }) |
| | | @PostMapping("/selectRawInspectsList") |
| | | public Result selectRawInspectsList(Integer pageSize, Integer countSize, String formTime, String createTime, Integer insState, Integer judgeState) { |
| | | return Result.success(rawInspectService.selectRawInspectsList(pageSize, countSize, formTime, createTime, insState, judgeState)); |
| | | public Result selectRawInspectsList(Integer pageSize, Integer countSize, String formTime, String code, Integer insState, String name) { |
| | | IPage<Map<String, Object>> page = rawInspectService.selectRawInspectsList(new Page<Object>(pageSize, countSize), formTime, code, insState, name); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", page.getTotal()); |
| | | map.put("row", page.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据检验单id查询原材料检验单详情") |
| | |
| | | return Result.success(rawInspectService.updateRawInspectsById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有原材料信息") |
| | | @GetMapping("/selectMaterial") |
| | | public Result selectMaterial() { |
| | | return Result.success(materialService.selectMaterial()); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料名称查询物料信息(物料id和编码)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "原材料名称(物料名称)", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selectMcodeId") |
| | | public Result selectMcodeId(String name) { |
| | | return Result.success(materialService.selectMcodeId(name)); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料编码(获取物料规格id.名称和型号名称)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "原材料名称(物料名称)", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "code", value = "原材料编号(物料编号)", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selectIdByCoNa") |
| | | public Result selectIdByCoNa(String name, String code) { |
| | | return Result.success(materialService.selectIdByCoNa(name, code)); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料规格(根据规格id获取物料型号)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "物料规格id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectSpBySt") |
| | | public Result selectSpBySt(Integer id) { |
| | | return Result.success(specificationsService.selectSpecificationIdAndName(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "新增检验单") |
| | | @PostMapping("/addRawInspects") |
| | | public Result addRawInspects(@RequestHeader("token") String token, @RequestBody RawInspect rawInspect) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | return Result.success(rawInspectService.addRawInspects(data.get("name").replaceAll("\"", ""), rawInspect)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | public interface RawInsProductMapper extends BaseMapper<RawInsProduct> { |
| | | |
| | | |
| | | //根据原材料检验单id查询检验项目 |
| | | List<Integer> getresult(Integer id); |
| | | } |
| | | |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | */ |
| | | public interface RawInspectMapper extends BaseMapper<RawInspect> { |
| | | |
| | | List<RawInspect> selectRawInspectsByLimit(int pageSize, int countSize, String formTime, String createTime,int insState,int judgeState); |
| | | |
| | | |
| | | //计算原材料在某个范围内的合格或不合格数量 |
| | | Integer selCountRaw(String begin, String end,Integer judgeState); |
| | | |
| | | //计算月总产量 |
| | | Long seAllCount(String begin, String end); |
| | | |
| | | //分页查询原材料检验单列表 |
| | | IPage<Map<String, Object>> selectRawInspectsList(Page<Object> page, String formTime, String code, Integer insState, String name); |
| | | |
| | | //根据原材料检验单id查看详情 |
| | | List<Map<String, Object>> selectRawInspectsListById(Integer id); |
| | | } |
| | | |
| | | |
| | |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 类型0:原材料检验单;1:成品检验单;2:半成品检验单 |
| | | **/ |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 缺陷名称(理由) |
| | | **/ |
| | | private String reason; |
| | |
| | | private Integer number; |
| | | |
| | | /** |
| | | * 供应商 |
| | | */ |
| | | private String supplier; |
| | | |
| | | /** |
| | | * 检验状态 0:未检验;1:已检验 |
| | | */ |
| | | private Integer insState; |
| | |
| | | |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | @Data |
| | | //新增原材料检验单参数 |
| | | public class RawInsProductVo implements Serializable { |
| | | |
| | | /** |
| | | * 项目名称 |
| | | **/ |
| | | @NotBlank(message = "项目名称不能为空!") |
| | | @JsonSerialize |
| | | private String name; |
| | | |
| | |
| | | /** |
| | | * 标准值 |
| | | **/ |
| | | @NotBlank(message = "标准值不能为空!") |
| | | @JsonSerialize |
| | | private String required; |
| | | |
| | | /** |
| | | * 内控值 |
| | | **/ |
| | | @NotBlank(message = "内控值不能为空!") |
| | | @JsonSerialize |
| | | private String internal; |
| | | |
| | | /** |
| | | * 检测值 |
| | | **/ |
| | | @JsonSerialize |
| | | private String testValue; |
| | | |
| | | /** |
| | | * 结论 0:不合格;1:合格 |
| | | **/ |
| | | @JsonSerialize |
| | | private Integer testState; |
| | | |
| | | |
| | | /** |
| | | * 设备名称 |
| | | **/ |
| | | @JsonSerialize |
| | | private String deviceName; |
| | | |
| | | /** |
| | | * 关联 申请单id |
| | | **/ |
| | | @JsonSerialize |
| | | private Integer rawInspectId; |
| | | |
| | | /** |
| | | * 检验员 |
| | | **/ |
| | | @JsonSerialize |
| | | private String userName; |
| | | } |
| | |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | //查询检验单详情(检验基本信息以及检验项目信息) |
| | | //新增原材料检验单参数 |
| | | public class RawInspectVo implements Serializable { |
| | | |
| | | /* 检验详情 */ |
| | | /** |
| | | * 来料日期 |
| | | */ |
| | | @NotNull(message = "来料日期不能为空!") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date formTime; |
| | |
| | | /** |
| | | * 型号规格 |
| | | */ |
| | | @NotBlank(message = "型号规格不能为空!") |
| | | @JsonSerialize |
| | | private String specifications; |
| | | |
| | | /** |
| | | * 原材料编码 |
| | | */ |
| | | @NotBlank(message = "原材料编码不能为空!") |
| | | @JsonSerialize |
| | | private String code; |
| | | |
| | | /** |
| | | * 原材料名称 |
| | | */ |
| | | @NotBlank(message = "原材料名称不能为空!") |
| | | @JsonSerialize |
| | | private String name; |
| | | |
| | | /** |
| | | * 报检日期 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 单位 |
| | | */ |
| | | @NotBlank(message = "单位不能为空!") |
| | | @JsonSerialize |
| | | private String unit; |
| | | |
| | | /** |
| | | * 数量 |
| | | */ |
| | | @NotNull(message = "数量不能为空!") |
| | | @JsonSerialize |
| | | private Integer number; |
| | | |
| | | /** |
| | | * 供应商 |
| | | */ |
| | | @NotBlank(message = "供应商不能为空!") |
| | | private String supplier; |
| | | |
| | | /** |
| | | * 报检人(当前用户名) |
| | | */ |
| | | @NotBlank(message = "报检人不能为空!") |
| | | @JsonSerialize |
| | | private String userName; |
| | | |
| | |
| | | @JsonSerialize |
| | | private List<RawInsProductVo> rawInsProducts; |
| | | |
| | | /* 检验结论 */ |
| | | /** |
| | | * 合格状态 0:不合格;1:合格 |
| | | */ |
| | | @JsonSerialize |
| | | private Integer judgeState; |
| | | |
| | | } |
| | |
| | | public interface RawInsProductService extends IService<RawInsProduct> { |
| | | |
| | | /** |
| | | * 更新检验项目 |
| | | * 更新检验项目(填写检验值,检验设备) |
| | | * @param userId |
| | | * @param rawInsProduct |
| | | */ |
| | | void updaterawInsProduct(int userId, RawInsProduct rawInsProduct); |
| | | void updaterawInsProduct(int userId, Integer rpId ,String testValue,Integer devId); |
| | | |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.mom.pojo.vo.RawInspectVo; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | * @createDate 2023-07-31 14:43:15 |
| | | */ |
| | | public interface RawInspectService extends IService<RawInspect> { |
| | | Map<String, Object> selectRawInspectsList(int pageSize, int countSize, String formTime, String createTime, int insState, int judgeState); |
| | | |
| | | /** |
| | | * 新增原材料检验单 |
| | | * @param userName |
| | | * @param rawInspectVo |
| | | */ |
| | | String addRawInspects(String userName, RawInspectVo rawInspectVo); |
| | | |
| | | /** |
| | | * 分页查询原材料检验单列表 |
| | | * @param formTime |
| | | * @param code |
| | | * @param insState |
| | | * @param name |
| | | * @return |
| | | */ |
| | | IPage<Map<String, Object>> selectRawInspectsList(Page<Object> page, String formTime, String code, Integer insState, String name); |
| | | |
| | | |
| | | /** |
| | | * 根据检验单id查询原材料检验单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | RawInspectVo selectRawInspectsListById(Integer id); |
| | | List<Map<String,Object>> selectRawInspectsListById(Integer id); |
| | | |
| | | /** |
| | | * 更新检验状态 |
| | | * @param id |
| | | */ |
| | | boolean updateRawInspectsById(Integer id); |
| | | String updateRawInspectsById(Integer id); |
| | | |
| | | /** |
| | | * 新增检验单 |
| | | * @param userName |
| | | * @param rawInspect |
| | | */ |
| | | Integer addRawInspects(String userName, RawInspect rawInspect); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.RawInsProductMapper; |
| | | import com.yuanchu.mom.mapper.RawInspectMapper; |
| | | import com.yuanchu.mom.pojo.RawInsProduct; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.yuanchu.mom.service.RawInsProductService; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 原材料申请单中的项目列表(RawInsProduct)表服务实现类 |
| | |
| | | @Resource |
| | | RawInsProductMapper rawInsProductMapper; |
| | | |
| | | //更新检验项目 |
| | | @Resource |
| | | RawInspectMapper rawInspectMapper; |
| | | |
| | | //更新检验项目(填写检验值,检验设备) |
| | | @Override |
| | | public void updaterawInsProduct(int userId, RawInsProduct rawInsProduct) { |
| | | public void updaterawInsProduct(int userId,Integer rpId ,String testValue,Integer devId) { |
| | | RawInsProduct rawInsProduct = rawInsProductMapper.selectById(rpId); |
| | | //赋值设备 |
| | | rawInsProduct.setDeviceId(devId); |
| | | //赋值检验员id |
| | | rawInsProduct.setUserId(userId); |
| | | //判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格0 |
| | | String testValue = rawInsProduct.getTestValue();//检验值 |
| | | String required = rawInsProduct.getRequired();//标准值 |
| | | String internal = rawInsProduct.getInternal();//内控值 |
| | | rawInsProduct.setTestState(checkValues(required, internal, testValue)); |
| | | //根据检验项目名和关联的检验单id来查询检验项目的数据 |
| | | LambdaUpdateWrapper<RawInsProduct> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(RawInsProduct::getRawInspectId, rawInsProduct.getRawInspectId()) |
| | | .eq(RawInsProduct::getName, rawInsProduct.getName()); |
| | | rawInsProductMapper.update(rawInsProduct, updateWrapper); |
| | | rawInsProduct.setTestValue(testValue); |
| | | List<Integer> list = Arrays.stream(testValue.split(",")).map(s -> { |
| | | int values = checkValues(required, internal, s); |
| | | return values; |
| | | }).collect(Collectors.toList()); |
| | | if (list.contains(0)) { |
| | | //如果其中一个检验值不合格则该项目检验不合格 |
| | | rawInsProduct.setTestState(0); |
| | | }else { |
| | | rawInsProduct.setTestState(1); |
| | | } |
| | | /*更新原材料检验项目表*/ |
| | | rawInsProductMapper.updateById(rawInsProduct); |
| | | /*更新原材料检验单*/ |
| | | RawInspect rawInspect = new RawInspect(); |
| | | rawInspect.setId(rawInsProduct.getRawInspectId()); |
| | | rawInspect.setInsState(2); |
| | | rawInspectMapper.updateById(rawInspect); |
| | | } |
| | | |
| | | /*判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格*/ |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | |
| | | * @createDate 2023-07-31 14:43:15 |
| | | */ |
| | | @Service |
| | | public class RawInspectServiceImpl extends ServiceImpl<RawInspectMapper, RawInspect> |
| | | implements RawInspectService { |
| | | public class RawInspectServiceImpl extends ServiceImpl<RawInspectMapper, RawInspect> implements RawInspectService { |
| | | |
| | | @Resource |
| | | RawInspectMapper rawInspectMapper; |
| | |
| | | @Resource |
| | | InspectUnacceptedMapper inspectUnacceptedMapper; |
| | | |
| | | @Resource |
| | | DeviceService deviceService; |
| | | |
| | | @Resource |
| | | MaterialMapper materialMapper; |
| | | |
| | | @Resource |
| | | UserService userService; |
| | | |
| | | @Resource |
| | | SpecificationsService specificationsService; |
| | | |
| | | @Resource |
| | | StandardService standardService; |
| | | |
| | | @Resource |
| | | ProductMapper productMapper; |
| | | |
| | | //分页查询原材料检验单列表 |
| | | @Override |
| | | public Map<String, Object> selectRawInspectsList(int pageSize, int countSize, String formTime, String createTime, int insState, int judgeState) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("count", rawInspectMapper.selectCount(new QueryWrapper<RawInspect>().eq("state", 1))); |
| | | map.put("data", rawInspectMapper.selectRawInspectsByLimit((pageSize - 1) * countSize, pageSize * countSize, formTime, createTime, insState, judgeState)); |
| | | return map; |
| | | public IPage<Map<String, Object>> selectRawInspectsList(Page<Object> page, String formTime, String code, Integer insState, String name) { |
| | | return rawInspectMapper.selectRawInspectsList(page, formTime, code, insState, name); |
| | | } |
| | | |
| | | //根据检验单id查询原材料检验单详情 |
| | | @Override |
| | | public RawInspectVo selectRawInspectsListById(Integer id) { |
| | | //将检验单基本信息查询出来并封装到RawInspectVo对象中 |
| | | RawInspect rawInspect = rawInspectMapper.selectById(id); |
| | | RawInspectVo rawInspectVo = new RawInspectVo(); |
| | | BeanUtils.copyProperties(rawInspect, rawInspectVo); |
| | | //查询检验单里面的检验项目,并封装到RawInspectVo对象中 |
| | | LambdaQueryWrapper<RawInsProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(RawInsProduct::getRawInspectId, id); |
| | | List<RawInsProduct> rawInsProducts = rawInsProductMapper.selectList(queryWrapper); |
| | | //这里查到的设备id和检验员id要查询名称 |
| | | List<RawInsProductVo> rawInsProductVos = rawInsProducts.stream().map(rawInsProduct -> { |
| | | //将一个对象的值赋值给另一个对象 |
| | | RawInsProductVo rawInsProductVo = new RawInsProductVo(); |
| | | BeanUtils.copyProperties(rawInsProduct, rawInsProductVo); |
| | | //获取设备名(前提是如果存在) |
| | | if (rawInsProduct.getDeviceId() != null) { |
| | | String deviceName = deviceService.getDeviceNameById(rawInsProduct.getDeviceId()); |
| | | rawInsProductVo.setDeviceName(deviceName); |
| | | } |
| | | //获取用户名(前提是如果存在) |
| | | if (rawInsProduct.getUserId() != null) { |
| | | String userName = userService.selectNameById(rawInsProduct.getUserId()); |
| | | rawInsProductVo.setUserName(userName); |
| | | } |
| | | return rawInsProductVo; |
| | | }).collect(Collectors.toList()); |
| | | rawInspectVo.setRawInsProducts(rawInsProductVos); |
| | | return rawInspectVo; |
| | | public List<Map<String, Object>> selectRawInspectsListById(Integer id) { |
| | | return rawInspectMapper.selectRawInspectsListById(id); |
| | | } |
| | | |
| | | //更新检验状态(上报) |
| | | @Override |
| | | public boolean updateRawInspectsById(Integer id) { |
| | | //更新检验单里面的检验状态和检验结论 |
| | | RawInspectVo rawInspectVo = selectRawInspectsListById(id); |
| | | RawInspect rawInspect = RawInspect.builder() |
| | | .id(id) |
| | | .insState(1) |
| | | .insTime(new Date()) |
| | | .judgeState(rawInspectVo.getJudgeState()) |
| | | .build(); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateRawInspectsById(Integer id) { |
| | | /*更新检验单里面的检验结论*/ |
| | | //先判断检验结果 |
| | | List<Integer> results = rawInsProductMapper.getresult(id); |
| | | int count = 0; |
| | | for (Integer result : results) { |
| | | if (result != null && result == 1) { |
| | | count++; |
| | | } |
| | | } |
| | | RawInspect rawInspect = new RawInspect(); |
| | | rawInspect.setId(id); |
| | | rawInspect.setInsState(1); |
| | | //如果检验项目中的结论包含不合格则检验单不合格 |
| | | if (results.contains(0)) { |
| | | rawInspect.setJudgeState(0); |
| | | //更新检验单 |
| | | rawInspectMapper.updateById(rawInspect); |
| | | //不管检验合格与不合格,都要新增到原材料库存 |
| | | |
| | | /* //如果检验结论为不合格,则需要新增不合格检验单 |
| | | if (rawInspectVo.getJudgeState() == 0) { |
| | | } else if (count == results.size()) { |
| | | rawInspect.setJudgeState(1); |
| | | rawInspectMapper.updateById(rawInspect); |
| | | } else return "项目未检验完!"; |
| | | /*如果检验结论为不合格,则需要新增不合格检验单*/ |
| | | if (rawInspect.getJudgeState() == 0) { |
| | | InspectUnaccepted rawUnaccepted = InspectUnaccepted.builder() |
| | | .reason(rawInspectVo.getName() + "不合格") //暂且定义为原材料不合格 |
| | | .reason(rawInspect.getName() + "不合格") //暂且定义为原材料不合格 |
| | | .rawInspectId(id) |
| | | .type(2) //类型为原材料 |
| | | .type(0) //类型为原材料 |
| | | .build(); |
| | | inspectUnacceptedMapper.insert(rawUnaccepted); |
| | | }*/ |
| | | return true; |
| | | } |
| | | return "上报成功!"; |
| | | } |
| | | |
| | | |
| | | //新增检验单 |
| | | //新增原材料检验单 |
| | | @Override |
| | | public Integer addRawInspects(String userName, RawInspect rawInspect) { |
| | | rawInspect.setUserName(userName); |
| | | //新增检验单 |
| | | rawInspectMapper.insert(rawInspect); |
| | | //获取物料id |
| | | Material material = materialMapper.selectOne(Wrappers.<Material>query() |
| | | .eq("name", rawInspect.getName()) |
| | | .eq("code", rawInspect.getCode())); |
| | | //获取规格名称和型号名称 |
| | | String specification = rawInspect.getSpecifications(); |
| | | String[] strings = specification.split("-"); |
| | | String stName = strings[0];//规格名称 |
| | | String spName = strings[1];//型号名称 |
| | | //获取规格id |
| | | Standard standard = standardService.getOne(Wrappers.<Standard>query() |
| | | .eq("name", stName) |
| | | .eq("material_id", material.getId())); |
| | | //获取型号id |
| | | Specifications specifications = specificationsService.selectSpIdByname(standard.getId(), spName); |
| | | //根据型号id查询项目信息 |
| | | List<Product> productList = productMapper.selectList(Wrappers.<Product>query().eq("specifications_id", specifications.getId())); |
| | | ArrayList<RawInsProduct> list = new ArrayList<>(); |
| | | for (Product product : productList) { |
| | | RawInsProduct rawInsProduct = RawInsProduct.builder() |
| | | .name(product.getName()) |
| | | .unit(product.getUnit()) |
| | | .required(product.getRequired()) |
| | | .internal(product.getInternal()) |
| | | .rawInspectId(rawInspect.getId()) |
| | | .build(); |
| | | list.add(rawInsProduct); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addRawInspects(String userName, RawInspectVo rawInspectVo) { |
| | | //报检人(新增检验单的人) |
| | | rawInspectVo.setUserName(userName); |
| | | //校验标准值,内控值格式 |
| | | List<RawInsProductVo> rawInsProductVos = rawInspectVo.getRawInsProducts(); |
| | | for (RawInsProductVo rawInsProductVo : rawInsProductVos) { |
| | | char internal = rawInsProductVo.getInternal().charAt(0); |
| | | char required = rawInsProductVo.getRequired().charAt(0); |
| | | if (internal != '>' && internal != '<' && internal != '=') { |
| | | if (required != '>' && required != '<' && required != '=') { |
| | | return "标准值输入格式有问题!"; |
| | | } |
| | | return "内控值输入格式有问题!"; |
| | | } |
| | | } |
| | | /*新增原材料检验单*/ |
| | | RawInspect rawInspect = new RawInspect(); |
| | | BeanUtils.copyProperties(rawInspectVo, rawInspect); |
| | | rawInspectMapper.insert(rawInspect); |
| | | /*新增原材料检验项目单*/ |
| | | List<RawInsProduct> rawInsProductList = rawInsProductVos.stream().map(rawInsProVo -> { |
| | | RawInsProduct rawInsProduct = new RawInsProduct(); |
| | | BeanUtils.copyProperties(rawInsProVo, rawInsProduct); |
| | | rawInsProduct.setRawInspectId(rawInspect.getId()); |
| | | return rawInsProduct; |
| | | }).collect(Collectors.toList()); |
| | | //检验项目批量添加 |
| | | rawInsProductService.saveBatch(list); |
| | | return rawInspect.getId(); |
| | | rawInsProductService.saveBatch(rawInsProductList); |
| | | return "新增检验单成功!"; |
| | | } |
| | | } |
| | | |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.yuanchu.mom.mapper.RawInsProductMapper"> |
| | | <!--根据原材料检验单id查询检验项目--> |
| | | <select id="getresult" resultType="java.lang.Integer"> |
| | | select test_state |
| | | from mom_ocean.raw_ins_product |
| | | where state = 1 |
| | | and raw_inspect_id = #{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.yuanchu.mom.mapper.RawInspectMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.RawInspect"> |
| | | <id property="id" column="id" jdbcType="INTEGER"/> |
| | | <result property="code" column="code" jdbcType="VARCHAR"/> |
| | | <result property="name" column="name" jdbcType="VARCHAR"/> |
| | | <result property="specifications" column="specifications" jdbcType="VARCHAR"/> |
| | | <result property="unit" column="unit" jdbcType="VARCHAR"/> |
| | | <result property="number" column="number" jdbcType="INTEGER"/> |
| | | <result property="insState" column="ins_state" jdbcType="INTEGER"/> |
| | | <result property="judgeState" column="judge_state" jdbcType="INTEGER"/> |
| | | <result property="insTime" column="ins_time" jdbcType="DATE"/> |
| | | <result property="userName" column="user_name" jdbcType="VARCHAR"/> |
| | | <result property="state" column="state" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="DATE"/> |
| | | <result property="updateTime" column="update_time" jdbcType="DATE"/> |
| | | <result property="formTime" column="form_time" jdbcType="DATE"/> |
| | | </resultMap> |
| | | <select id="selectRawInspectsByLimit" resultType="com.yuanchu.mom.pojo.RawInspect"> |
| | | select id, code, name, specifications, unit, number, ins_state, judge_state, ins_time, user_name, create_time, |
| | | form_time |
| | | from mom_ocean.raw_inspect |
| | | where state = 1 |
| | | <if test="formTime!=null and formTime!=''"> |
| | | and form_time = #{formTime} |
| | | </if> |
| | | <if test="createTime!=null and createTime!=''"> |
| | | and create_time = #{createTime} |
| | | </if> |
| | | <if test="insState!=2"> |
| | | and ins_state = #{insState} |
| | | </if> |
| | | <if test="judgeState!=2"> |
| | | and judge_state = #{judgeState} |
| | | </if> |
| | | order by id desc |
| | | limit #{pageSize},#{countSize} |
| | | </select> |
| | | <select id="selCountRaw" resultType="java.lang.Integer"> |
| | | select count(id) |
| | | from mom_ocean.raw_inspect |
| | |
| | | and raw_inspect.create_time <= #{end} |
| | | </if> |
| | | </select> |
| | | |
| | | <!--分页查询原材料检验单列表--> |
| | | <select id="selectRawInspectsList" resultType="java.util.Map"> |
| | | select id, |
| | | DATE_FORMAT(form_time, '%Y-%m-%d') formTime, |
| | | code, |
| | | name, |
| | | specifications, |
| | | unit, |
| | | number, |
| | | DATE_FORMAT(create_time, '%Y-%m-%d') createTime, |
| | | user_name, |
| | | DATE_FORMAT(ins_time, '%Y-%m-%d') insTime, |
| | | ins_state, |
| | | judge_state |
| | | from mom_ocean.raw_inspect |
| | | where state=1 |
| | | <if test="formTime!=null and formTime!=''"> |
| | | and form_time=#{formTime} |
| | | </if> |
| | | <if test="code!=null and code!=''"> |
| | | and code like concat('%',#{code},'%') |
| | | </if> |
| | | <if test="insState!=null"> |
| | | and ins_state=#{insState} |
| | | </if> |
| | | <if test="name!=null and name!=''"> |
| | | and name like concat('%',#{name},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | <!--根据原材料检验单id查看详情--> |
| | | <resultMap id="oneMap" type="map"> |
| | | <id property="rcode" column="rcode"/> |
| | | <result property="formTime" column="formTime"/> |
| | | <result property="rname" column="rname"/> |
| | | <result property="specifications" column="specifications"/> |
| | | <result property="runit" column="runit"/> |
| | | <result property="number" column="number"/> |
| | | <result property="supplier" column="supplier"/> |
| | | <result property="judgeState" column="judge_state"/> |
| | | <result property="userName" column="user_name"/> |
| | | <collection property="children" resultMap="twoMap" javaType="List"/> |
| | | </resultMap> |
| | | <resultMap id="twoMap" type="map"> |
| | | <id property="rpId" column="rpId"/> |
| | | <result property="rpName" column="rpName"/> |
| | | <result property="rpUnit" column="rpUnit"/> |
| | | <result property="required" column="required"/> |
| | | <result property="internal" column="internal"/> |
| | | <result property="testValue" column="test_value"/> |
| | | <result property="testState" column="test_state"/> |
| | | <result property="devName" column="devName"/> |
| | | <result property="uName" column="uName"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectRawInspectsListById" resultMap="oneMap"> |
| | | select DATE_FORMAT(form_time, '%Y-%m-%d') formTime, |
| | | r.code rcode, |
| | | r.name rname, |
| | | specifications, |
| | | r.unit runit, |
| | | number, |
| | | supplier, |
| | | judge_state, |
| | | user_name, |
| | | rp.id rpId, |
| | | rp.name rpName, |
| | | rp.unit rpUnit, |
| | | required, |
| | | internal, |
| | | test_value, |
| | | test_state, |
| | | device.name devName, |
| | | user.name uName |
| | | from mom_ocean.raw_ins_product rp |
| | | left join mom_ocean.raw_inspect r on rp.raw_inspect_id = r.id |
| | | left join mom_ocean.device |
| | | on rp.device_id = device.id |
| | | left join mom_ocean.user on rp.user_id = user.id |
| | | where r.state = 1 |
| | | and rp.state = 1 |
| | | and r.id = #{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | //标准MOM-->左侧五级树展示 |
| | | List<Map<String,Object>> selectTreeByMaterial(); |
| | | |
| | | //根据物料名称查询物料id和物料编码 |
| | | List<Material> selectMcodeId(String name); |
| | | |
| | | //根据物料名称和物料编码查询物料id,规格信息和型号信息 |
| | | List<Map> selectIdByCoNa(String name, String code); |
| | | |
| | | //根据标准id查询物料 |
| | | Material selFath(Integer id); |
| | | } |
| | |
| | | */ |
| | | void addMaterial(MaterialDto materialDto); |
| | | |
| | | /** |
| | | * 根据物料名称查询物料id和物料编码 |
| | | * @param name |
| | | * @return |
| | | */ |
| | | List<Material> selectMcodeId(String name); |
| | | |
| | | /** |
| | | * 根据物料名称和物料编码查询物料id |
| | | * @param name |
| | | * @param code |
| | | * @return |
| | | */ |
| | | List<Map> selectIdByCoNa(String name, String code); |
| | | |
| | | /** |
| | | * 检验模块-->QMS管理-->成品检验-->新增(项目名称下拉框:Id与名称,编码) |
| | | */ |
| | | List<Map<String, Object>> selectMaterialIdAndNameAndCode(); |
| | | |
| | | /** |
| | | * 查询所有物料信息 |
| | | * @return |
| | | */ |
| | | List<Material> selectMaterial(); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 根据规格id和型号名称查询型号信息 |
| | | * @param id |
| | | * @param name |
| | | * @return |
| | | */ |
| | | Specifications selectSpIdByname(Integer id, String name); |
| | | |
| | | /** |
| | | * 检验模块-->OMS管理-->成品检验-->新增(需要规格型号的Id与名称) |
| | | */ |
| | | List<Map<String, Object>> selectSpecificationIdAndName(Integer materialId); |
| | |
| | | return materialMapper.selectMaps(wrapper); |
| | | } |
| | | |
| | | //查询所有物料信息 |
| | | @Override |
| | | public List<Material> selectMaterial() { |
| | | return materialMapper.selectList(Wrappers.<Material>query()); |
| | | } |
| | | |
| | | //根据物料名称查询物料id和物料编码 |
| | | @Override |
| | | public List<Material> selectMcodeId(String name) { |
| | | return materialMapper.selectMcodeId(name); |
| | | } |
| | | |
| | | //根据物料名称和物料编码查询物料id,规格信息和型号信息 |
| | | @Override |
| | | public List<Map> selectIdByCoNa(String name, String code) { |
| | | return materialMapper.selectIdByCoNa(name, code); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return maps; |
| | | } |
| | | |
| | | |
| | | //根据规格id和型号名称查询型号信息 |
| | | @Override |
| | | public Specifications selectSpIdByname(Integer id, String name) { |
| | | Specifications specifications = specificationsMapper.selectOne(Wrappers.<Specifications>query() |
| | | .eq("standard_id", id) |
| | | .eq("name", name)); |
| | | return specifications; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | on sp.standard_id = s.id |
| | | </select> |
| | | |
| | | <select id="selectMcodeId" resultType="com.yuanchu.mom.pojo.Material"> |
| | | select id, code |
| | | from mom_ocean.material |
| | | where name = #{name} |
| | | </select> |
| | | |
| | | <select id="selectIdByCoNa" resultType="java.util.Map"> |
| | | select m.id '物料id', |
| | | st.id '规格id', |
| | | st.name '规格名称', |
| | | sp.name '型号名称' |
| | | from mom_ocean.material m, |
| | | mom_ocean.standard st, |
| | | mom_ocean.specifications sp |
| | | where m.id = material_id |
| | | and material_id = standard_id |
| | | and m.name = #{name} |
| | | and code = #{code} |
| | | </select> |
| | | |
| | | <!--根据标准id查询物料--> |
| | | <select id="selFath" resultType="com.yuanchu.mom.pojo.Material"> |
| | | select * |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://192.168.191.113:3306/mom_ocean?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 |
| | | url: jdbc:mysql://192.168.73.113:3306/mom_ocean?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 |
| | | username: user |
| | | password: 123456 |
| | | druid: |
| | |
| | | # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 |
| | | database: 0 |
| | | # redis服务器地址(默认为localhost) |
| | | host: 192.168.191.113 |
| | | host: 192.168.73.113 |
| | | # redis端口(默认为6379) |
| | | port: 6379 |
| | | # redis访问密码(默认为空) |