app收样管理

This commit is contained in:
hayu 2024-08-05 16:16:11 +08:00
parent 4ba1a81a42
commit dc4e603a41
11 changed files with 210 additions and 109 deletions

View File

@ -6,13 +6,10 @@ import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.app.service.SamplesManageAppService; import com.bonus.aqgqj.app.service.SamplesManageAppService;
import com.bonus.aqgqj.system.vo.EncryptedReq; import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ServerResponse; import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -76,18 +73,6 @@ public class SamplesManageAppController {
return ServerResponse.createErroe("操作失败"); return ServerResponse.createErroe("操作失败");
} }
@PostMapping(value = "allCustomName")
@LogAnnotation(operModul = "收样管理", operation = "查询所有单位", operDesc = "业务级事件",operType="查询")
public ServerResponse getAllCustomName() {
try {
List<SamplesManageAppVo> list = samplesManageAppService.getAllCustomName();
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
/** /**
* @description 新增收样数据 * @description 新增收样数据
*/ */
@ -120,19 +105,6 @@ public class SamplesManageAppController {
} }
} }
@PostMapping(value = "getDeptSelectedById")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "根据单位id获取部门", operDesc = "业务级事件",operType="查询")
public ServerResponse getDeptSelectedById(EncryptedReq<SamplesManageAppVo> data) {
try {
List<SamplesManageAppVo> list = samplesManageAppService.getDeptSelectedById(data.getData());
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
@PostMapping(value = "getAuthority") @PostMapping(value = "getAuthority")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class) @DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
@LogAnnotation(operModul = "收样管理", operation = "查询是否具有派工/收样权限", operDesc = "业务级事件",operType="查询") @LogAnnotation(operModul = "收样管理", operation = "查询是否具有派工/收样权限", operDesc = "业务级事件",operType="查询")

View File

@ -59,4 +59,33 @@ public class SelectAppController {
return ServerResponse.createErroe("操作失败"); return ServerResponse.createErroe("操作失败");
} }
/**
* 查询所有单位
*/
@PostMapping(value = "getCustomNameSelected")
public ServerResponse getCustomNameSelected() {
try {
List<SamplesManageAppVo> list = service.getCustomNameSelected();
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
/**
* 根据单位id获取部门下拉选
*/
@PostMapping(value = "getDeptSelectedById")
@DecryptAndVerify(decryptedClass = SamplesManageAppVo.class)
public ServerResponse getDeptSelectedById(EncryptedReq<SamplesManageAppVo> data) {
try {
List<SamplesManageAppVo> list = service.getDeptSelectedById(data.getData());
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
} }

View File

@ -34,12 +34,6 @@ public interface SamplesManageAppDao {
*/ */
List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data); List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data);
/**
* 获取所有单位名称
* @return
*/
List<SamplesManageAppVo> getAllCustomName();
/** /**
* 新增收样数据 tb_samples * 新增收样数据 tb_samples
* @param SamplesManageAppVo * @param SamplesManageAppVo
@ -75,13 +69,6 @@ public interface SamplesManageAppDao {
*/ */
int updateTeamId(SamplesManageAppVo dto); int updateTeamId(SamplesManageAppVo dto);
/**
* 获取部门
* @param data
* @return
*/
List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data);
/** /**
* 获取标签数据 * 获取标签数据
* @param data * @param data
@ -95,4 +82,18 @@ public interface SamplesManageAppDao {
* @return * @return
*/ */
List<ConfigItemsVo> getTestItemList(SamplesManageAppVo dto); List<ConfigItemsVo> getTestItemList(SamplesManageAppVo dto);
/**
* 获取收样批次编号
* @param nowDate
* @return
*/
String selectBatchCode(String nowDate);
/**
* 根据批次编号获取id
* @param batchCode
* @return
*/
Integer getIdByBatchCode(String batchCode);
} }

View File

@ -26,4 +26,17 @@ public interface SelectAppDao {
* @return List<SamplesManageAppVo> * @return List<SamplesManageAppVo>
*/ */
List<SamplesManageAppVo> getTestTeamSelected(); List<SamplesManageAppVo> getTestTeamSelected();
/**
* 获取所有单位
* @return List<SamplesManageAppVo>
*/
List<SamplesManageAppVo> getCustomNameSelected();
/**
* 根据单位id获取部门
* @param data
* @return List<SamplesManageAppVo>
*/
List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data);
} }

View File

@ -24,12 +24,6 @@ public interface SamplesManageAppService {
*/ */
List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data); List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data);
/**
* 单位列表
* @return
*/
List<SamplesManageAppVo> getAllCustomName();
/** /**
* 新增 * 新增
* @param data * @param data
@ -44,13 +38,6 @@ public interface SamplesManageAppService {
*/ */
ServerResponse dispatchWork(SamplesManageAppVo data); ServerResponse dispatchWork(SamplesManageAppVo data);
/**
* 根据单位Id获取部门列表
* @param data
* @return
*/
List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data);
/** /**
* 查询权限 * 查询权限
* @param data * @param data

View File

@ -27,4 +27,18 @@ public interface SelectAppService {
* @return * @return
*/ */
List<SamplesManageAppVo> getTestTeamSelected(); List<SamplesManageAppVo> getTestTeamSelected();
/**
* 获取单位下拉选
* @param
* @return
*/
List<SamplesManageAppVo> getCustomNameSelected();
/**
* 根据单位id获取部门下拉选
* @param data
* @return
*/
List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data);
} }

View File

@ -52,62 +52,80 @@ public class SamplesManageAppServiceImpl implements SamplesManageAppService {
public List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data) { public List<SamplesManageAppVo> getDetailsList(SamplesManageAppVo data) {
return samplesManageAppDao.getDetailsList(data); return samplesManageAppDao.getDetailsList(data);
} }
/**
* 查询所有单位列表
* @return
*/
@Override
public List<SamplesManageAppVo> getAllCustomName() {
return samplesManageAppDao.getAllCustomName();
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ServerResponse addSamples(SamplesManageAppVo data) { public ServerResponse addSamples(SamplesManageAppVo data) {
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList()); JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<SamplesManageAppVo> SamplesManageAppVos = jsonArray.toJavaList(SamplesManageAppVo.class); List<SamplesManageAppVo> SamplesManageAppVos = jsonArray.toJavaList(SamplesManageAppVo.class);
if (SamplesManageAppVos.size() > 0){ if (SamplesManageAppVos.size() > 0){
//先增加基础数据表并返回Id //获取登录人id
Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString()); Integer userId = Integer.parseInt(UserUtil.getLoginUser().getId().toString());
SamplesManageAppVos.get(0).setCreateBy(userId); //先查看收样批次编号是否为空
int re= samplesManageAppDao.addSamples(SamplesManageAppVos.get(0)); String batchCode = SamplesManageAppVos.get(0).getBatchCode();
if (re>0){ if (StringHelper.isEmpty(batchCode)){
//添加详情数据 //为空则该批次首次上传数据需要新增tb_sample表并且需要生成批次编号
for (SamplesManageAppVo dto : SamplesManageAppVos){ //生成编号
//查询设备类型编码 String batchCode2 =batchCodeRule();
if (dto.getSampleToolsId()!=null){ SamplesManageAppVos.get(0).setBatchCode(batchCode2);
String devTypeCode = samplesManageAppDao.getDevTypeCodeById(dto.getSampleToolsId()); SamplesManageAppVos.get(0).setCreateBy(userId);
dto.setDevTypeCode(devTypeCode); int re= samplesManageAppDao.addSamples(SamplesManageAppVos.get(0));
} if (re>0){
//生成设备编码 //添加tb_sample_device数据
String customerCode = customerCodeRule(); Boolean state = addSamplesDevice(SamplesManageAppVos);
dto.setCustomerCode(customerCode); if (state){
dto.setId(SamplesManageAppVos.get(0).getId()); return ServerResponse.createBySuccessMsg(batchCode2);
dto.setCreateBy(userId);
int res= samplesManageAppDao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
} }
}else {
throw new RuntimeException("收样单位信息表添加失败");
} }
}else { }else {
throw new RuntimeException("收样单位信息表添加失败"); //不为空则该批次已上传过数据在该批次下新增tb_sample_device表数据
//查询该编号的id
Integer sampleId = samplesManageAppDao.getIdByBatchCode(batchCode);
if (sampleId!=null){
//添加tb_sample_device数据
SamplesManageAppVos.get(0).setId(sampleId);
SamplesManageAppVos.get(0).setCreateBy(userId);
Boolean state = addSamplesDevice(SamplesManageAppVos);
if (state){
return ServerResponse.createBySuccessMsg(batchCode);
}
}else {
throw new RuntimeException("收样批次编号不存在");
}
} }
}else { }else {
throw new RuntimeException("未获取到数据"); throw new RuntimeException("未获取到数据");
} }
return ServerResponse.createBySuccessMsg("上传成功"); return ServerResponse.createErroe("收样数据添加失败");
} }
/** /**
* 根据单位Id获取部门列表 * 添加tb_sample_device数据
* @param data
*/ */
@Override public Boolean addSamplesDevice(List<SamplesManageAppVo> data) {
public List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data) { for (SamplesManageAppVo dto : data){
List<SamplesManageAppVo> list = samplesManageAppDao.getDeptSelectedById(data); //查询设备类型编码
return list; if (dto.getSampleToolsId()!=null){
String devTypeCode = samplesManageAppDao.getDevTypeCodeById(dto.getSampleToolsId());
dto.setDevTypeCode(devTypeCode);
}
//生成设备编码
String customerCode = customerCodeRule();
dto.setCustomerCode(customerCode);
dto.setId(data.get(0).getId());
dto.setCreateBy(data.get(0).getCreateBy());
int res= samplesManageAppDao.addSamplesDevice(dto);
if (res<=0){
throw new RuntimeException("收样设备信息表添加失败");
}
}
return true;
} }
@Override @Override
public Boolean getAuthority(SamplesManageAppVo data) { public Boolean getAuthority(SamplesManageAppVo data) {
if (StringHelper.isNotEmpty(data.getName())){ if (StringHelper.isNotEmpty(data.getName())){
@ -159,6 +177,34 @@ public class SamplesManageAppServiceImpl implements SamplesManageAppService {
return ServerResponse.createBySuccessMsg("派工成功"); return ServerResponse.createBySuccessMsg("派工成功");
} }
/**
* 收样批次编号--自动生成
* 格式PYYYYMMDD-NN
* P表示批次编号的前缀
* YYYY年份4位数字
* MM月份2位数字
* DD日期2位数字
* NN当天的批次序号2位数字按当天批次顺序递增
* 每天的批次编号从 01 开始按批次顺序递增
*/
private String batchCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样批次流水号
String batchCode = samplesManageAppDao.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 * 格式SYYYYMMDD-XXX

View File

@ -45,4 +45,20 @@ public class SelectServiceAppImpl implements SelectAppService {
public List<SamplesManageAppVo> getTestTeamSelected() { public List<SamplesManageAppVo> getTestTeamSelected() {
return mapper.getTestTeamSelected(); return mapper.getTestTeamSelected();
} }
/**
* 获取单位下拉选
*/
@Override
public List<SamplesManageAppVo> getCustomNameSelected() {
return mapper.getCustomNameSelected();
}
/**
* 根据单位id获取部门下拉选
*/
@Override
public List<SamplesManageAppVo> getDeptSelectedById(SamplesManageAppVo data) {
return mapper.getDeptSelectedById(data);
}
} }

View File

@ -97,6 +97,9 @@ public class DateTimeHelper {
return time; return time;
} }
/**
* 获取当前年月日格式yyyyMMdd
*/
public static String getNowYMD() { public static String getNowYMD() {
String time = new SimpleDateFormat("yyyyMMdd").format(new Date()); String time = new SimpleDateFormat("yyyyMMdd").format(new Date());
return time; return time;

View File

@ -8,14 +8,16 @@
sample_time, sample_time,
create_time, create_time,
create_user, create_user,
sample_date) sample_date,
batch_code)
VALUES (#{customId}, VALUES (#{customId},
#{customName}, #{customName},
#{sampleUser}, #{sampleUser},
#{sampleTime}, #{sampleTime},
NOW(), NOW(),
#{createBy}, #{createBy},
#{sampleTime}) #{sampleTime},
#{batchCode})
</insert> </insert>
<insert id="addSamplesDevice"> <insert id="addSamplesDevice">
INSERT INTO tb_sample_device(sample_id, INSERT INTO tb_sample_device(sample_id,
@ -115,14 +117,6 @@
) )
</if> </if>
</select> </select>
<select id="getAllCustomName" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT id,
custom_name AS name
FROM tb_custom
WHERE del_flag = 0
and custom_status = 0
and dept_id = 0
</select>
<select id="getDevTypeCodeById" resultType="java.lang.String"> <select id="getDevTypeCodeById" resultType="java.lang.String">
select sd.dict_code select sd.dict_code
from sys_distinct sd from sys_distinct sd
@ -141,15 +135,6 @@
customer_code DESC customer_code DESC
LIMIT 1 LIMIT 1
</select> </select>
<select id="getDeptSelectedById" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT id,
custom_name as name
FROM tb_custom
WHERE p_id = #{customId}
and del_flag = 0
and custom_status = 0
and dept_id = 1
</select>
<select id="getSampleLabelData" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo"> <select id="getSampleLabelData" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT SELECT
te.submit_location as submitLocation, te.submit_location as submitLocation,
@ -179,4 +164,22 @@
WHERE WHERE
tsd.id=#{id} tsd.id=#{id}
</select> </select>
<select id="selectBatchCode" resultType="java.lang.String">
SELECT
SUBSTRING( batch_code, - 2 ) AS CODE
FROM
tb_sample
WHERE
SUBSTRING( batch_code, 2, 8 )= #{nowDate}
and del_flag = 0
ORDER BY
batch_code DESC
LIMIT 1
</select>
<select id="getIdByBatchCode" resultType="java.lang.Integer">
SELECT id
FROM tb_sample
WHERE batch_code = #{batchCode}
and del_flag = 0
</select>
</mapper> </mapper>

View File

@ -23,4 +23,21 @@
del_flag = 0 del_flag = 0
AND team_type_code =2 AND team_type_code =2
</select> </select>
<select id="getCustomNameSelected" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT id,
custom_name AS name
FROM tb_custom
WHERE del_flag = 0
and custom_status = 0
and dept_id = 0
</select>
<select id="getDeptSelectedById" resultType="com.bonus.aqgqj.app.entity.SamplesManageAppVo">
SELECT id,
custom_name as name
FROM tb_custom
WHERE p_id = #{customId}
and del_flag = 0
and custom_status = 0
and dept_id = 1
</select>
</mapper> </mapper>