AI创建折点字典

This commit is contained in:
tangw 2026-09-24 20:46:19 +08:00
parent bf6a44d1d2
commit 4effe7b7ca
9 changed files with 57 additions and 16 deletions

View File

@ -86,45 +86,52 @@ public class LisUtil {
* 按GBK编码的字节宽度截取字符串,最多取cutlens个字节(避免截取半个汉字)
*
* @param str 原始字符串
* @param beginidx 起始位置
* @param cutlens 截取长度
* @param beginidx 起始GBK字节偏移,从0开始
* @param cutlens 需要截取的最大GBK字节长度
* @return 截取后的字符串
*/
public static String substringByGbkWidth(String str, int beginidx, int cutlens) {
if (str == null || str.isEmpty()) {
return "";
}
if (beginidx < 0 || cutlens <= 0) {
return "";
}
int targetWidth = cutlens; // 目标字节宽度
int currentWidth = beginidx; // 当前累计字节宽度
int skipBytes = beginidx; // 需要跳过的GBK字节数
int takeBytes = cutlens; // 需要截取的GBK字节数
int currentTake = 0;
StringBuilder result = new StringBuilder();
for (char c : str.toCharArray()) {
// 计算当前字符在GBK编码下的字节数
int charWidth;
try {
// GBK编码中,汉字占2字节,英文等占1字节
charWidth = String.valueOf(c).getBytes("GBK").length;
} catch (UnsupportedEncodingException e) {
// 理论上GBK是Java默认支持的编码,不会走到这里
throw new RuntimeException("不支持GBK编码", e);
}
// 判断加上当前字符后是否超过目标宽度
if (currentWidth + charWidth > targetWidth) {
break; // 超过则停止,不截取当前字符
// 阶段1:还在跳过前置字节
if (skipBytes > 0) {
if (charWidth <= skipBytes) {
skipBytes -= charWidth;
} else {
// 当前字符跨起始边界,直接丢弃,不能切半个汉字
skipBytes = 0;
}
continue;
}
// 未超过则累加宽度并添加字符
currentWidth += charWidth;
// 阶段2:开始收集字符
if (currentTake + charWidth > takeBytes) {
break;
}
currentTake += charWidth;
result.append(c);
// 如果刚好达到目标宽度,提前结束
if (currentWidth == targetWidth) {
if (currentTake == takeBytes) {
break;
}
}
return result.toString();
}

View File

@ -210,6 +210,11 @@ public class ReportItemController extends BaseController {
public Result getitemtdh(String yq){
return reportItemService.getitemtdh(yq);
}
@ApiOperation("根据项目代号查询通道号")
@GetMapping("/queryTdhByXmdh")
public Result queryTdhByXmdh(String yq, String xmdh){
return reportItemService.queryTdhByXmdh(yq, xmdh);
}
@ApiOperation("保存检验项目通道号")
@PostMapping("/saveitemtdh")
public Result saveitemtdh(@RequestBody List<XmInter> XmInterList){

View File

@ -63,6 +63,12 @@ public class XmReqitemVsReportitemController extends BaseController {
return xmReqitemVsReportitemService.update(xmReqitemVsReportitem);
}
@ApiOperation("查询未对应收费项目")
@GetMapping("/queryUnmapped")
public Result queryUnmapped(String yq){
return xmReqitemVsReportitemService.queryUnmapped(yq);
}
@Log(title = SysLogConstants.XMREQITEMVSREPORTITEM_LOG ,businessType = BusinessType.UPDATE)
@ApiOperation("搜索项目")
@GetMapping("/search")

View File

@ -13,6 +13,7 @@ public interface XmReqitemVsReportitemMapper {
void update(XmReqitemVsReportitem xmReqitemVsReportitem);
XmReqitemVsReportitem queryOne(XmReqitemVsReportitem xmReqitemVsReportitem);
List<Map<String, Object>> queryList(XmReqitemVsReportitem xmReqitemVsReportitem);
List<Map<String, Object>> queryUnmapped(@Param("yq") String yq);
String getSqxmdhOne(String yq);
void searchXmdh(String yq);

View File

@ -60,6 +60,7 @@ public interface ReportItemService {
Result updateXminfoVsDYXH(List<XmInfoVs> list);
Result getitemtdh(String yq);
Result queryTdhByXmdh(String yq, String xmdh);
Result saveitemtdh(List<XmInter> list);
Result delitemtdh(String yq,String tdh);
Result getdouble(String yq ,String xmdh);

View File

@ -13,5 +13,7 @@ public interface XmReqitemVsReportitemService {
Result queryList(XmReqitemVsReportitem xmReqitemVsReportitem);
Result queryUnmapped(String yq);
Result searchXmdh(String yq);
}

View File

@ -446,6 +446,13 @@ public class ReportItemServiceImpl implements ReportItemService {
return new Result("0","成功!",reportItemMapper.queryXmInter(xmInter));
}
@Override
public Result queryTdhByXmdh(String yq, String xmdh){
XmInter xmInter=new XmInter();
xmInter.setYq(yq);
xmInter.setXmdh(xmdh);
return new Result("0","成功!",reportItemMapper.queryXmInter(xmInter));
}
@Transactional(rollbackFor = Exception.class)
@Override
public Result delitemtdh(String yq,String tdh){

View File

@ -69,6 +69,11 @@ public class XmReqitemVsReportitemImpl implements XmReqitemVsReportitemService {
return new Result("0","获取数据成功!",xmReqitemVsReportitemList);
}
@Override
public Result queryUnmapped(String yq) {
return new Result("0","获取数据成功!",xmReqitemVsReportitemMapper.queryUnmapped(yq));
}
@Override
public Result searchXmdh(String yq) {
String sqxmdhOne = xmReqitemVsReportitemMapper.getSqxmdhOne(yq);

View File

@ -80,4 +80,11 @@
</update>
<select id="queryUnmapped">
select xm_feeinstr.yq, xm_feeinstr.sfxmdh as sqxmdh, xm_fee.sfxmmc as sqxmmc
from xm_feeinstr join xm_fee on xm_feeinstr.sfxmdh = xm_fee.sfxmdh
where xm_feeinstr.yq = #{yq}
and xm_feeinstr.sfxmdh not in (select distinct sqxmdh from dbo.xm_reqitem_vs_reportitem where yq = #{yq})
</select>
</mapper>