收样管理

This commit is contained in:
jjLv 2024-09-04 10:04:02 +08:00
parent 1cb23c6343
commit ac941451de
16 changed files with 556 additions and 331 deletions

View File

@ -202,4 +202,16 @@ public class SamplesManageController {
return ServerResponse.createErroe("操作失败");
}
}
/**
* 是否审核前
* @param data
* @return
*/
@PostMapping(value = "getFlag")
@DecryptAndVerify(decryptedClass = SamplesManageDto.class)//加解密统一管理
// @PreAuthorize("@pms.hasPermission('base:team:query')" )
public ServerResponse getFlag(EncryptedReq<SamplesManageDto> data) {
return samplesManageService.getFlag(data.getData());
}
}

View File

@ -181,4 +181,10 @@ public interface SamplesManageDao {
* @date 2024/9/2 17:46
*/
List<ContractsVo> getSampleList(ParamsDto data);
/**
* 根据id查是否审核前
* @param data
* @return
*/
SamplesManageDto getFlag(SamplesManageDto data);
}

View File

@ -1,6 +1,7 @@
package com.bonus.aqgqj.basis.entity.dto;
import com.bonus.aqgqj.base.entity.PageEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.models.auth.In;
import lombok.Data;
@ -57,6 +58,7 @@ public class SamplesManageDto extends PageEntity {
/**
* 送样时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String sampleTime;
/**
@ -82,6 +84,7 @@ public class SamplesManageDto extends PageEntity {
/**
* 收样时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String collectSamplesTime;
/**
@ -175,4 +178,10 @@ public class SamplesManageDto extends PageEntity {
* 试验费用
*/
private String amountAll;
/**
* 送样数量
*/
private Integer devNum;
}

View File

@ -91,6 +91,8 @@ public interface SamplesManageService {
ServerResponse getSampleById(SamplesManageDto data);
ServerResponse getFlag(SamplesManageDto data);
/**
* 查询收样设备
* @param dto

View File

@ -10,9 +10,9 @@ import com.bonus.aqgqj.basis.entity.vo.ContractsVo;
import com.bonus.aqgqj.basis.service.SamplesManageService;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.*;
import com.bonus.aqgqj.webResult.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -25,104 +25,110 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @author hay
* @description 收样管理
* @date 2024/7/20 16:10
*/
* @description 收样管理
* @author hay
* @date 2024/7/20 16:10
*/
@Slf4j
@Service
public class SamplesManageServiceImpl implements SamplesManageService {
@Resource
private SamplesManageDao samplesManageDao;
@Resource
private SamplesManageDao samplesManageDao;
/**
* 查询列表
*
* @param bean
* @return
*/
@Override
public List<SamplesManageDto> list(SamplesManageDto bean) {
List<SamplesManageDto> list = samplesManageDao.list(bean);
for (SamplesManageDto dto : list) {
String sampleTools = samplesManageDao.getSampleTools(dto.getId());
dto.setSampleTools(sampleTools);
}
return list;
}
/**
* 查询列表
* @param bean
* @return
*/
@Override
public List<SamplesManageDto> list(SamplesManageDto bean) {
List<SamplesManageDto> list = samplesManageDao.list(bean);
for (SamplesManageDto dto : list){
String sampleTools = samplesManageDao.getSampleTools(dto.getId());
dto.setSampleTools(sampleTools);
}
return list;
}
/**
* 查询详情列表
*
* @param data
* @return
*/
@Override
public List<SamplesManageDto> getDetailsList(SamplesManageDto data) {
return samplesManageDao.getDetailsList(data);
}
/**
* 查询详情列表
* @param data
* @return
*/
@Override
public List<SamplesManageDto> getDetailsList(SamplesManageDto data) {
return samplesManageDao.getDetailsList(data);
}
@Override
public List<SamplesManageDto> listTools() {
List<SamplesManageDto> list = samplesManageDao.listTools();
return list;
}
/**
* 查询所有单位列表
* @return
*/
@Override
public List<SamplesManageDto> getAllCustomName() {
return samplesManageDao.getAllCustomName();
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse addSamples(SamplesManageDto data) {
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<SamplesManageDto> samplesManageDtos = jsonArray.toJavaList(SamplesManageDto.class);
if (samplesManageDtos.size() > 0){
//先增加基础数据表并返回Id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//生成编号
String batchCode2 =batchCodeRule();
samplesManageDtos.get(0).setCreateBy(userId);
samplesManageDtos.get(0).setBatchCode(batchCode2);
int re= samplesManageDao.addSamples(samplesManageDtos.get(0));
if (re>0){
//添加详情数据
for (SamplesManageDto dto : samplesManageDtos){
//查询设备类型编码
if (dto.getSampleToolsId()!=null){
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(samplesManageDtos.get(0).getId());
dto.setCreateBy(userId);
dto.setCreateBy(userId);
Date date = new Date();
String formattedDate = outputFormat.format(date);
dto.setDevCode(formattedDate +"-" + dto.getDevCode());
int res= samplesManageDao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
}
}
}else {
throw new RuntimeException("收样单位信息表添加失败");
}
}else {
throw new RuntimeException("未获取到数据");
}
return ServerResponse.createBySuccessMsg("上传成功");
}
@Override
public List<SamplesManageDto> listTools() {
List<SamplesManageDto> list = samplesManageDao.listTools();
return list;
}
/**
* 查询所有单位列表
*
* @return
*/
@Override
public List<SamplesManageDto> getAllCustomName() {
return samplesManageDao.getAllCustomName();
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse addSamples(SamplesManageDto data) {
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<SamplesManageDto> samplesManageDtos = jsonArray.toJavaList(SamplesManageDto.class);
if (samplesManageDtos.size() > 0) {
//先增加基础数据表并返回Id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//生成编号
String batchCode2 = batchCodeRule();
samplesManageDtos.get(0).setCreateBy(userId);
samplesManageDtos.get(0).setBatchCode(batchCode2);
int re = samplesManageDao.addSamples(samplesManageDtos.get(0));
if (re > 0) {
//添加详情数据
for (SamplesManageDto dto : samplesManageDtos) {
//查询设备类型编码
if (dto.getSampleToolsId() != null) {
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(samplesManageDtos.get(0).getId());
dto.setCreateBy(userId);
int res = samplesManageDao.addSamplesDevice(dto);
if (res <= 0) {
throw new RuntimeException("收样设备信息表添加失败");
}
}
} else {
throw new RuntimeException("收样单位信息表添加失败");
}
} else {
throw new RuntimeException("未获取到数据");
}
return ServerResponse.createBySuccessMsg("上传成功");
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse addSamplesAll(SamplesManageDto data) {
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<SamplesManageDto> samplesManageDtos = jsonArray.toJavaList(SamplesManageDto.class);
List<SamplesManageDto> fileterList = samplesManageDtos.stream().filter(vo -> (vo.getIdSy() != null)).collect(Collectors.toList());
@ -163,69 +169,74 @@ public class SamplesManageServiceImpl implements SamplesManageService {
// fileterListNew.get(0).setCreateBy(userId);
// fileterListNew.get(0).setBatchCode(batchCode2);
// int re= samplesManageDao.addSamples(fileterListNew.get(0));
//添加详情数据
for (SamplesManageDto dto : fileterListNew) {
//查询设备类型编码
dto.setId(list.get(0).getId());
if (dto.getSampleToolsId() != null) {
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(fileterListNew.get(0).getId());
dto.setCreateBy(userId);
int res = samplesManageDao.addSamplesDevice(dto);
if (res <= 0) {
throw new RuntimeException("收样设备信息表添加失败");
}
}
} else {
throw new RuntimeException("未获取到数据");
}
return ServerResponse.createBySuccessMsg("上传成功");
} else {
if (fileterListNew.size() == 1 && fileterListNew.get(0).getCustomId() == null) {
int reOne = samplesManageDao.delOld(fileterListNew.get(0));
if (reOne == 0) {
throw new RuntimeException("收样信息表删除失败");
}
return ServerResponse.createBySuccessMsg("上传成功");
}
if (fileterListNew.size() > 0) {
//先增加基础数据表并返回Id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//生成编号
String batchCode2 = batchCodeRule();
fileterListNew.get(0).setCreateBy(userId);
fileterListNew.get(0).setBatchCode(batchCode2);
int re = samplesManageDao.addSamples(fileterListNew.get(0));
if (re > 0) {
//添加详情数据
for (SamplesManageDto dto : fileterListNew) {
//查询设备类型编码
if (dto.getSampleToolsId() != null) {
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(samplesManageDtos.get(0).getId());
dto.setCreateBy(userId);
int res = samplesManageDao.addSamplesDevice(dto);
if (res <= 0) {
throw new RuntimeException("收样设备信息表添加失败");
}
}
} else {
throw new RuntimeException("收样单位信息表添加失败");
}
}
return ServerResponse.createBySuccessMsg("上传成功");
}
}
//添加详情数据
for (SamplesManageDto dto : fileterListNew){
//查询设备类型编码
dto.setId(list.get(0).getId());
if (dto.getSampleToolsId()!=null){
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(fileterListNew.get(0).getId());
dto.setCreateBy(userId);
Date date = new Date();
String formattedDate = outputFormat.format(date);
dto.setDevCode(formattedDate +"-" + dto.getDevCode());
int res= samplesManageDao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
}
}
}else {
throw new RuntimeException("未获取到数据");
}
return ServerResponse.createBySuccessMsg("上传成功");
}else{
if(fileterListNew.size()==1 && fileterListNew.get(0).getCustomId()==null)
{
int reOne = samplesManageDao.delOld(fileterListNew.get(0));
if(reOne==0){
throw new RuntimeException("收样信息表删除失败");
}
return ServerResponse.createBySuccessMsg("上传成功");
}
if (fileterListNew.size() > 0){
//先增加基础数据表并返回Id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
//生成编号
String batchCode2 =batchCodeRule();
fileterListNew.get(0).setCreateBy(userId);
fileterListNew.get(0).setBatchCode(batchCode2);
int re= samplesManageDao.addSamples(fileterListNew.get(0));
if (re>0){
//添加详情数据
for (SamplesManageDto dto : fileterListNew){
//查询设备类型编码
if (dto.getSampleToolsId()!=null){
String devTypeCode = samplesManageDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(samplesManageDtos.get(0).getId());
dto.setCreateBy(userId);
int res= samplesManageDao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
}
}
}else {
throw new RuntimeException("收样单位信息表添加失败");
}
}
return ServerResponse.createBySuccessMsg("上传成功");
}
}
/**
* 查询所有班组
@ -237,123 +248,136 @@ public class SamplesManageServiceImpl implements SamplesManageService {
return samplesManageDao.getTeamSelected();
}
/**
* 根据单位Id获取部门列表
*/
@Override
public List<SamplesManageDto> getDeptSelectedById(SamplesManageDto data) {
List<SamplesManageDto> list = samplesManageDao.getDeptSelectedById(data);
return list;
}
/**
* 根据单位Id获取部门列表
*/
@Override
public List<SamplesManageDto> getDeptSelectedById(SamplesManageDto data) {
List<SamplesManageDto> list = samplesManageDao.getDeptSelectedById(data);
return list;
}
/**
* 获取总金额
*/
@Override
public String getAmount(SamplesManageDto data) {
String amountAll = samplesManageDao.getAmount(data);
return amountAll;
}
/**
* 获取总金额
*/
@Override
public String getAmount(SamplesManageDto data) {
String amountAll = samplesManageDao.getAmount(data);
return amountAll;
}
@Override
public Boolean getAuthority(SamplesManageDto data) {
if (StringHelper.isNotEmpty(data.getName())) {
if ("派工".equals(data.getName())) {
return SystemUtils.isComprehensiveTeamLeader();
} else if ("收样".equals(data.getName())) {
return (SystemUtils.isComprehensiveTeam() || SystemUtils.isComprehensiveTeamLeader());
}
}
return false;
}
@Override
public Boolean getAuthority(SamplesManageDto data) {
if (StringHelper.isNotEmpty(data.getName())){
if ("派工".equals(data.getName())){
return SystemUtils.isComprehensiveTeamLeader();
}else if ("收样".equals(data.getName())){
return (SystemUtils.isComprehensiveTeam() || SystemUtils.isComprehensiveTeamLeader());
}
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse dispatchWork(SamplesManageDto data) {
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
if (StringHelper.isNotEmpty(data.getIds())) {
//拆分用逗号分隔的数据
String[] ids = data.getIds().split(",");
for (String id : ids) {
SamplesManageDto dto = new SamplesManageDto();
dto.setId(Integer.parseInt(id));
dto.setTeamId(data.getTeamId());
dto.setUpdateBy(userId);
//更新班组数据
int res = samplesManageDao.updateTeamId(dto);
if (res <= 0) {
throw new RuntimeException("派工失败");
}
}
}
return ServerResponse.createBySuccessMsg("派工成功");
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse dispatchWork(SamplesManageDto data) {
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
if (StringHelper.isNotEmpty(data.getIds())){
//拆分用逗号分隔的数据
String[] ids = data.getIds().split(",");
for (String id : ids){
SamplesManageDto dto = new SamplesManageDto();
dto.setId(Integer.parseInt(id));
dto.setTeamId(data.getTeamId());
dto.setUpdateBy(userId);
//更新班组数据
int res = samplesManageDao.updateTeamId(dto);
if (res<=0){
throw new RuntimeException("派工失败");
}
}
}
return ServerResponse.createBySuccessMsg("派工成功");
}
/**
* 收样批次编号--自动生成
* 格式PYYYYMMDD-NN
* P表示批次编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* NN当天的批次序号2位数字按当天批次顺序递增
* 每天的批次编号从 01 开始按批次顺序递增
*/
private String batchCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样批次流水号
String batchCode = samplesManageDao.selectBatchCode(nowDate);
if (StringHelper.isNotEmpty(batchCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(batchCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
batchCode = String.format("%02d", num);
} else {
batchCode = "01";
}
String code = "P" + nowDate + "-" + batchCode;
return code;
}
/**
* 收样批次编号--自动生成
* 格式PYYYYMMDD-NN
* P表示批次编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* NN当天的批次序号2位数字按当天批次顺序递增
* 每天的批次编号从 01 开始按批次顺序递增
*/
private String batchCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样批次流水号
String batchCode = samplesManageDao.selectBatchCode(nowDate);
if (StringHelper.isNotEmpty(batchCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(batchCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
batchCode = String.format("%02d", num);
} else {
batchCode = "01";
}
String code = "P" + nowDate + "-" + batchCode;
return code;
}
/**
* 设备编号--自动生成
* 格式SYYYYMMDD-XXX
* S表示收样编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* XXX当天的收样序号3位数字按当天收样顺序递增
* 每天的设备收样编号从 001 开始按收样顺序递增
*/
private String customerCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样流水号
String customerCode = samplesManageDao.selectCustomerCode(nowDate);
if (StringHelper.isNotEmpty(customerCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(customerCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
customerCode = String.format("%03d", num);
} else {
customerCode = "001";
}
String code = "S" + nowDate + "-" + customerCode;
return code;
}
/**
* 设备编号--自动生成
* 格式SYYYYMMDD-XXX
* S表示收样编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* XXX当天的收样序号3位数字按当天收样顺序递增
* 每天的设备收样编号从 001 开始按收样顺序递增
*/
private String customerCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样流水号
String customerCode = samplesManageDao.selectCustomerCode(nowDate);
if (StringHelper.isNotEmpty(customerCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(customerCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
customerCode = String.format("%03d", num);
} else {
customerCode = "001";
}
String code = "S" + nowDate + "-" + customerCode;
return code;
}
@Override
public ServerResponse getSampleById(SamplesManageDto data) {
try {
List<SamplesManageDto> list = samplesManageDao.getSampleById(data);
return ServerResponse.createSuccess(list);
} catch (Exception e) {
return ServerResponse.createErroe("查询失败");
}
}
@Override
public ServerResponse getSampleById(SamplesManageDto data) {
try{
List<SamplesManageDto> list= samplesManageDao.getSampleById(data);
return ServerResponse.createSuccess(list);
}catch (Exception e){
return ServerResponse.createErroe("查询失败");
}
}
@Override
public ServerResponse getFlag(SamplesManageDto data) {
try{
SamplesManageDto vo= samplesManageDao.getFlag(data);
if(vo==null){
return ServerResponse.createErroe("无法新增,只能在审核前上传");
}
return ServerResponse.createSuccess("查询成功");
}catch (Exception e){
return ServerResponse.createErroe("查询失败");
}
}
@Override
public List<ContractsVo> getSamplesDevList(ParamsDto dto) {

View File

@ -417,7 +417,7 @@
te.dev_module AS devModule,
te.sample_date AS sampleDate,
DATE_FORMAT(te.exper_time, '%Y-%m-%d') AS experTime,
DATE_FORMAT(te.next_exper_time, '%Y-%m-%d') AS nextExperTime,
DATE_FORMAT(DATE_ADD(te.exper_time,INTERVAL tcmd.times YEAR), '%Y-%m-%d') AS nextExperTime,
te.submit_unit AS customId,
tc.custom_name AS customName,
te.submit_location AS experLocal,
@ -433,6 +433,8 @@
FROM tb_exper te
LEFT JOIN tb_custom tc ON te.submit_unit = tc.id AND tc.del_flag = 0
LEFT JOIN sys_user su ON te.update_user = su.id AND su.del_flag = 0
LEFT JOIN tb_exper_config tec on te.dev_type_code = tec.dev_type_code and tec.del_flag = 0
LEFT JOIN tb_config_man_dev tcmd on tec.id = tcmd.config_id
WHERE te.id = #{id}
</select>
<!--试验依据信息-->

View File

@ -195,18 +195,19 @@
<select id="getSampleById" resultType="com.bonus.aqgqj.basis.entity.dto.SamplesManageDto">
SELECT
ts.id as id,
tc.id as customId,
tsd.id as idSy,
tc.custom_name as customName,
ts.sample_user as sampleUser,
ts.sample_time as sampleTime,
tsd.dev_type_name as sampleTools,
tsd.dev_code as devCode,
tsd.create_time as collectSamplesTime
FROM tb_sample ts
LEFT JOIN tb_custom tc on tc.id = ts.custom_id
LEFT JOIN tb_sample_device tsd on tsd.sample_id = ts.id and tsd.del_falg = 0
ts.id as id,
tc.id as customId,
tsd.id as idSy,
tc.custom_name as customName,
ts.sample_user as sampleUser,
DATE(tsd.sample_time) as sampleTime,
DATE(ts.sample_time) as collectSamplesTime,
tsd.dev_type_name as sampleTools,
tsd.dev_code as devCode,
tsd.create_time as collectSamplesTime
FROM tb_sample_device tsd
LEFT JOIN tb_sample ts on ts.id = tsd.sample_id and tsd.del_falg = 0
LEFT JOIN tb_custom tc on tc.id = ts.custom_id
WHERE ts.del_flag = 0
and tc.del_flag = 0
and tc.custom_status = 0
@ -273,4 +274,11 @@
SET del_falg = 1
WHERE id = #{idSy}
</update>
<select id="getFlag" resultType="com.bonus.aqgqj.basis.entity.dto.SamplesManageDto">
select id
from tb_sample ts
where ts.id = #{id} and ts.del_flag = 0 and ((audti_status = 0 and process_status is null) or (audti_status = 0 and process_status = 0 )
or (audti_status = 2 and process_status = 1 ) or (audti_status = 2 and process_status = 2 ) or (audti_status = 2 and process_status = 3 ))
</select>
</mapper>

View File

@ -2,6 +2,10 @@ let form, layer,laydate, table, tableIns;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为10
let orgData,selectOrgId;
let idParam;
let amountTemp = 0.00;
let devNumTemp=0;
let devNumAll = 0 ;
let listLength = 0;
let listData=[];
let sampleName=0.00;
function setParams(params) {
@ -22,8 +26,9 @@ function setParams(params) {
});
document.getElementById('amountAll').value = '0.00';
form.on('submit(formData)', function (data) {
console.log(data.field)
pages(data.field)
$('#devCode').val('')
// $('#devCode').val('')
});
form.on('select(customName)', function (data) {
// 获得被选中的值
@ -35,6 +40,8 @@ function setParams(params) {
var sampleToolsValue =$('#sampleTools').val()
var sampleToolsText = $('#sampleTools option[value="' + sampleToolsValue + '"]').text();
let url = dataUrl + '/samples/getAmount';
devNumTemp = document.getElementById('devNum').value
// console.log(devNumTemp)
let obj = {
sampleTools:sampleToolsText
}
@ -46,8 +53,9 @@ function setParams(params) {
if (result.code === 200) {
console.log(result.data)
sampleName = parseFloat(result.data) || 0.00;
console.log(sampleName)
document.getElementById('amountAll').value = sampleName.toFixed(2);
amountTemp = sampleName;
// console.log(listData.devNum)
document.getElementById('amountAll').value = (sampleName * devNumTemp).toFixed(2);
} else {
}
})
@ -55,6 +63,15 @@ function setParams(params) {
})
}
function updateAmountTwo(){
if(input.value <0||input.value>100){
input.value = '';
input.placeholder = '请输入0~100内的数据'
}
const devNumTwo = document.getElementById('devNum').value || 1
document.getElementById('amountAll').value = (amountTemp * devNumTwo).toFixed(2);
}
/**
* 数据处理
* @param data
@ -71,20 +88,40 @@ function pages(data) {
var sampleToolsValue =$('#sampleTools').val()
// 2. 查找对应的选项文本
var sampleToolsText = $('#sampleTools option[value="' + sampleToolsValue + '"]').text();
// 向数组中添加数据
listData.push({
customId: data.customName,
customName: selectedText,
sampleUser: data.sampleUser,
sampleTime: $('#sampleTime').val(),
departmentId: data.sampleDepartment,
sampleDepartment: sampleDepartmentText,
sampleToolsId: data.sampleTools,
sampleTools: sampleToolsText,
devModule: data.devModule,
devCode: data.devCode,
});
var num = parseInt($('#devNum').val())
for (let i = devNumAll; i < (num + devNumAll) ; i++) {
let dataString = getFormattedDate(i+1)
listData.push({
customId: data.customName,
customName: selectedText,
sampleUser: data.sampleUser,
sampleTime: $('#sampleTime').val(),
departmentId: data.sampleDepartment,
sampleDepartment: sampleDepartmentText,
sampleToolsId: data.sampleTools,
sampleTools: sampleToolsText,
devModule: data.devModule,
devCode: dataString,
})
}
devNumAll = num + devNumAll;
// 向数组中添加数据
// listData.push({
// customId: data.customName,
// customName: selectedText,
// sampleUser: data.sampleUser,
// sampleTime: $('#sampleTime').val(),
//
// departmentId: data.sampleDepartment,
// sampleDepartment: sampleDepartmentText,
// sampleToolsId: data.sampleTools,
// sampleTools: sampleToolsText,
// devModule: data.devModule,
// devCode: data.devCode,
// });
console.log("listData:",listData)
//启用/禁用控件
enableDisableControl();
@ -134,6 +171,24 @@ function enableDisableControl() {
// // document.getElementById('amountAll').value = total.toFixed(2);
// }
function getFormattedDate(sequenceNumber){
const now = new Date();
// // 获取年、月、日、小时和分钟
// const year = now.getFullYear();
// const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始所以要加1
// const day = String(now.getDate()).padStart(2, '0');
// const hour = String(now.getHours()).padStart(2, '0');
// const minute = String(now.getMinutes()).padStart(2, '0');
// const second = String(now.getSeconds()).padStart(2, '0');
// // 格式化为 YYYYMMDDHHmm
// const dateTimeString = `${year}${month}${day}${hour}${minute}${second}`;
// 格式化序号为两位数
const formattedSequence = String(sequenceNumber).padStart(3, '0');
return `${formattedSequence}`;
}
/*初始化表格*/
function initTable(dataList) {
@ -164,7 +219,12 @@ function handleClick1(index) {
console.log(index)
// 根据行索引删除 listData 中对应的数据
listData.splice(index, 1);
listLength = listData.length;
for (let i = 0; i < listLength; i++) {
let dataString = getFormattedDate(i+1)
listData[i].devCode = dataString;
}
devNumAll = listLength;
// 更新表格
initTable(listData);

View File

@ -2,6 +2,11 @@ let form, layer,laydate, table, tableIns;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为10
let orgData,selectOrgId;
let idParam;
let amountTemp = 0.00;
let devNumTemp= 0;
let devNumAll = 0 ;
let listLength = 0;
let listLengthTwo = 0;
let listData=[];
let sampleName=0.00;
let idSample;
@ -28,8 +33,11 @@ function setParams(params) {
getFormbyId();
}
form.on('submit(formData)', function (data) {
pages(data.field)
$('#devCode').val('')
getFlag(data);
// if(flag==1){
// pages(data.field)
// }
// $('#devCode').val('')
});
// form.on('select(customName)', function (data) {
// // 获得被选中的值
@ -41,6 +49,7 @@ function setParams(params) {
var sampleToolsValue =$('#sampleTools').val()
var sampleToolsText = $('#sampleTools option[value="' + sampleToolsValue + '"]').text();
let url = dataUrl + '/samples/getAmount';
devNumTemp = document.getElementById('devNum').value
let obj = {
sampleTools:sampleToolsText
}
@ -52,8 +61,8 @@ function setParams(params) {
if (result.code === 200) {
console.log(result.data)
sampleName = parseFloat(result.data) || 0.00;
console.log(sampleName)
document.getElementById('amountAll').value = sampleName.toFixed(2);
amountTemp = sampleName;
document.getElementById('amountAll').value = (sampleName * devNumTemp).toFixed(2);
} else {
}
})
@ -61,6 +70,40 @@ function setParams(params) {
})
}
function updateAmountTwo(input){
if(input.value <0||input.value>100){
input.value = '';
input.placeholder = '请输入0~100内的数据'
}
const devNumTwo = document.getElementById('devNum').value || 1
document.getElementById('amountAll').value = (amountTemp * devNumTwo).toFixed(2);
}
function getFlag(data){
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
let url = dataUrl + "/samples/getFlag?token=" + tokens;
let params = {
id: idParam
}
params={
encryptedData:encryptCBC(JSON.stringify(params))
}
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
// setFormData(result.data);
pages(data.field)
} else {
layer.alert(result.msg, {icon: 2})
}
}, function (xhr) {
layer.close(loadingMsg); // 关闭提示层
error(xhr)
});
}
/**
* 数据处理
* @param data
@ -78,7 +121,7 @@ function pages(data) {
// 2. 查找对应的选项文本
var sampleToolsText = $('#sampleTools option[value="' + sampleToolsValue + '"]').text();
var num = parseInt($('#devNum').val())
const now = new Date();
// 获取年份
const year = now.getFullYear();
@ -97,23 +140,28 @@ function pages(data) {
// 获取秒钟
const seconds = String(now.getSeconds()).padStart(2, '0');
const formattedDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
const formattedDateTime = `${year}-${month}-${day}`;
// 向数组中添加数据
listData.push({
id: idSample,
collectSamplesTime:null,
customId: data.customName,
customName: selectedText,
sampleUser: data.sampleUser,
sampleTime: formattedDateTime,
idSY:null,
departmentId: data.sampleDepartment,
sampleDepartment: sampleDepartmentText,
sampleToolsId: data.sampleTools,
sampleTools: sampleToolsText,
devModule: data.devModule,
devCode: data.devCode,
});
for (let i = devNumAll; i < (num + devNumAll) ; i++) {
let dataString = getFormattedDate(i+1)
listData.push({
id: idSample,
collectSamplesTime:null,
customId: data.customName,
customName: selectedText,
sampleUser: data.sampleUser,
sampleTime: formattedDateTime,
idSY:null,
departmentId: data.sampleDepartment,
sampleDepartment: sampleDepartmentText,
sampleToolsId: data.sampleTools,
sampleTools: sampleToolsText,
devModule: data.devModule,
devCode: dataString,
});
}
devNumAll = num + devNumAll;
console.log("listData:",listData)
//启用/禁用控件
enableDisableControl();
@ -139,6 +187,25 @@ function enableDisableControl() {
}
}
function getFormattedDate(sequenceNumber){
// const now = new Date();
//
// // 获取年、月、日、小时和分钟
// const year = now.getFullYear();
// const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始所以要加1
// const day = String(now.getDate()).padStart(2, '0');
// const hour = String(now.getHours()).padStart(2, '0');
// const minute = String(now.getMinutes()).padStart(2, '0');
// const second = String(now.getSeconds()).padStart(2, '0');
// // 格式化为 YYYYMMDDHHmm
// const dateTimeString = `${year}${month}${day}${hour}${minute}${second}`;
// 格式化序号为两位数
const formattedSequence = String(sequenceNumber).padStart(3, '0');
return `${formattedSequence}`;
}
// 根据id获取收样信息
function getFormbyId() {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
@ -166,11 +233,18 @@ function getFormbyId() {
function setFormData(data) {
console.log(data)
listLength = data.length;
console.log(listLength)
if(data){
$('#customName').val(data[0].customId)
getDeptSelectedById(data[0].customId);
$('#sampleUser').val(data[0].sampleUser)
$('#sampleTime').val(data[0].sampleTime.split(' ')[0])
if(data[0].collectSamplesTime!=null){
$('#sampleTime').val(data[0].collectSamplesTime)
}else{
$('#sampleTime').val(null)
}
data.forEach(item =>{
listData.push({
id:item.id,
@ -190,6 +264,7 @@ function setFormData(data) {
});
idSample = item.id;
})
console.log(listData);
enableDisableControl()
initTable(listData)
}
@ -223,8 +298,21 @@ function initTable(dataList) {
function handleClick1(index) {
console.log(index)
// 根据行索引删除 listData 中对应的数据
listData.splice(index, 1);
if(listData[index].idSY!=null){
alert("已收样的数据不能删除");
// throw new Error("已收样的数据不能删除!")
}else{
listData.splice(index, 1);
listLengthTwo = listData.length - listLength;
console.log(listLength);
console.log(listLengthTwo)
for (let i = 0; i < listLengthTwo; i++) {
let dataString = getFormattedDate(i+1)
listData[(i+listLength)].devCode = dataString;
}
// devNumAll = listLengthTwo;
}
devNumAll = listLengthTwo;
// 更新表格
initTable(listData);

View File

@ -131,7 +131,7 @@ function initTable(dataList, limit, page) {
let html = '';
let download = `<a class=\"layui-icon layui-icon-download-circle\" style='cursor:pointer;' title="下载委托书" onclick="downloadContract('${d.id}')"></a>`;
let edit=`<a class=\"layui-icon layui-icon-edit\" style='cursor:pointer;' title='修改' onclick="edit('${d.id}')"></a>`;
let view = `<a style='cursor:pointer;' onclick="addData('${d.id}')">详情</a>`;
let view = `<a class=\"layui-icon layui-icon-search\" style='cursor:pointer;' title="详情" onclick="addData('${d.id}')"></a>`;
if(d.delFlag == 1){
return '';
}

View File

@ -124,14 +124,14 @@
<div class="layui-inline">
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>试验日期</label>
<div class="layui-input-inline" >
<input type="text" id="experTime" name="experTime" lay-verify="required" class="layui-input" placeholder="请选择试验日期" readonly />
<input type="text" id="experTime" name="experTime" lay-verify="required" class="layui-input" placeholder="请选择试验日期" readonly />
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>下次试验日期</label>
<div class="layui-input-inline" >
<input type="text" id="nextExperTime" name="nextExperTime" lay-verify="required" class="layui-input" placeholder="请选择下次试验日期" readonly />
<input type="text" id="nextExperTime" name="nextExperTime" lay-verify="required" style="background-color: #f0f0f0;" class="layui-input" placeholder="请选择下次试验日期" disabled />
</div>
</div>
</div>

View File

@ -133,7 +133,7 @@
<div class="layui-inline">
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>下次试验日期</label>
<div class="layui-input-inline" >
<input type="text" id="nextExperTime" name="nextExperTime" lay-verify="required" class="layui-input" placeholder="请选择下次试验日期" readonly />
<input type="text" id="nextExperTime" name="nextExperTime" lay-verify="required" style="background-color: #f0f0f0;" class="layui-input" placeholder="请选择下次试验日期" disabled />
</div>
</div>
</div>

View File

@ -149,7 +149,7 @@
<div class="layui-inline">
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>实验周期</label>
<div class="layui-input-inline" >
<input type="text" id="times" name="times" lay-verify="required" class="layui-input" placeholder="请输入实验周期" maxlength="3" />
<input type="number" id="times" name="times" min="1" lay-verify="required" class="layui-input" placeholder="请输入实验周期" maxlength="3" />
</div>
<div class="layui-input-inlineTwo" >
<span style="display: flex;margin: 10px 10px;"></span>

View File

@ -151,7 +151,7 @@
<div class="layui-inline">
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>实验周期</label>
<div class="layui-input-inline" >
<input type="text" id="times" name="times" lay-verify="required" class="layui-input" placeholder="请输入实验周期" maxlength="3" />
<input type="number" id="times" name="times" min="1" lay-verify="required" class="layui-input" placeholder="请输入实验周期" maxlength="3" />
</div>
<div class="layui-input-inlineTwo" >
<span style="display: flex;margin: 10px 10px;"></span>

View File

@ -118,13 +118,20 @@
lay-verify="required" maxlength="30">
</div>
</div>
<div class="layui-form-item" style="margin-top: 5%;">
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备编号</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="请输入设备编号" id="devCode" name="devCode" autocomplete="off"
lay-verify="required" maxlength="30">
</div>
</div>
<!-- <div class="layui-form-item" style="margin-top: 5%;">-->
<!-- <label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备编号</label>-->
<!-- <div class="layui-input-inline">-->
<!-- <input class="layui-input" placeholder="请输入设备编号" id="devCode" name="devCode" autocomplete="off"-->
<!-- lay-verify="required" maxlength="30">-->
<!-- </div>-->
<!-- </div>-->
<div class="layui-form-item" style="margin-top: 5%;">
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备数量</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="请输入设备数量" type="number" id="devNum" name="devNum" min="1" max="100" value="1" autocomplete="off"
lay-verify="required" oninput="updateAmountTwo(this)" maxlength="3" >
</div>
</div>
<div class="layui-form-item" style="margin-top: 5%;">
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>总金额</label>
<div class="layui-input-inline" >

View File

@ -118,12 +118,19 @@
lay-verify="required" maxlength="30">
</div>
</div>
<!-- <div class="layui-form-item" style="margin-top: 5%;">-->
<!-- <label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备编号</label>-->
<!-- <div class="layui-input-inline">-->
<!-- <input class="layui-input" placeholder="请输入设备编号" id="devCode" name="devCode" autocomplete="off"-->
<!-- lay-verify="required" maxlength="30">-->
<!-- </div>-->
<!-- </div>-->
<div class="layui-form-item" style="margin-top: 5%;">
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备编号</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="请输入设备编号" id="devCode" name="devCode" autocomplete="off"
lay-verify="required" maxlength="30">
</div>
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>设备数量</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="请输入设备数量" type="number" id="devNum" name="devNum" min="1" max = "100" value="1" autocomplete="off"
lay-verify="required" oninput="updateAmountTwo(this)" maxlength="3" >
</div>
</div>
<div class="layui-form-item" style="margin-top: 5%;">
<label class="layui-form-label"><i style="padding: 0 10px; color: red;">*</i>总金额</label>